#[repr(u8)]
pub enum Color {
+Color in arduboy_rust::arduboy2 - Rust#[repr(u8)]
pub enum Color {
Black,
White,
}
Expand description
This item is to chose between Black or White
Performs copy-assignment from
source
.
Read more
Formats the value using the given formatter.
Read more
Feeds this value into the given [
Hasher
].
Read more
Performs copy-assignment from
source
.
Read more
Formats the value using the given formatter.
Read more
Feeds this value into the given [
Hasher
].
Read more
Feeds a slice of this type into the given [
Hasher
].
Read more
The resulting type after applying the !
operator.
This method returns an [
Ordering
] between
self
and
other
.
Read more
Feeds a slice of this type into the given [
Hasher
].
Read more
The resulting type after applying the !
operator.
This method returns an [
Ordering
] between
self
and
other
.
Read more
Compares and returns the maximum of two values.
Read more
Compares and returns the minimum of two values.
Read more
Restrict a value to a certain interval.
Read more
This method tests for
self
and
other
values to be equal, and is used
+ Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval.
Read more
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
-sufficient, and should not be overridden without very good reason.
This method returns an ordering between
self
and
other
values if one exists.
Read more
This method tests less than (for
self
and
other
) and is used by the
<
operator.
Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
+sufficient, and should not be overridden without very good reason.
This method returns an ordering between
self
and
other
values if one exists.
Read more
This method tests less than (for
self
and
other
) and is used by the
<
operator.
Read more
This method tests less than or equal to (for
self
and
other
) and is used by the
<=
operator.
Read more
This method tests greater than (for
self
and
other
) and is used by the
>
operator.
Read more
This method tests greater than or equal to (for
self
and
other
) and is used by the
>=
-operator.
Read more
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
diff --git a/docs/doc/arduboy_rust/arduboy2/index.html b/docs/doc/arduboy_rust/arduboy2/index.html
index aad1156..eb9cd96 100644
--- a/docs/doc/arduboy_rust/arduboy2/index.html
+++ b/docs/doc/arduboy_rust/arduboy2/index.html
@@ -1,3 +1,3 @@
-
arduboy_rust::arduboy2 - RustExpand description
This is the Module to interact in a save way with the Arduboy2 C++ library.
+
arduboy_rust::arduboy2 - RustExpand description
This is the Module to interact in a save way with the Arduboy2 C++ library.
All of the functions are safe wrapped inside the Arduboy2 struct.
This is the struct to interact in a save way with the Arduboy2 C++ library.
This struct is used by a few Arduboy functions.
This struct is used by a few Arduboy functions.
The standard font size of the arduboy
The standard height of the arduboy
The standard width of the arduboy
\ No newline at end of file
diff --git a/docs/doc/arduboy_rust/arduboy2/struct.Arduboy2.html b/docs/doc/arduboy_rust/arduboy2/struct.Arduboy2.html
index 5d52c79..894f1a6 100644
--- a/docs/doc/arduboy_rust/arduboy2/struct.Arduboy2.html
+++ b/docs/doc/arduboy_rust/arduboy2/struct.Arduboy2.html
@@ -1,15 +1,17 @@
-
Arduboy2 in arduboy_rust::arduboy2 - Rustpub struct Arduboy2 {}
Expand description
This is the struct to interact in a save way with the Arduboy2 C++ library.
-
gives you a new instance of the Arduboy2
+
Arduboy2 in arduboy_rust::arduboy2 - Rustpub struct Arduboy2 {}
Expand description
This is the struct to interact in a save way with the Arduboy2 C++ library.
+
gives you a new instance of the Arduboy2
-
const arduboy: Arduboy2 = Arduboy2::new();
-
Initialize the hardware, display the boot logo, provide boot utilities, etc.
+
#![allow(non_upper_case_globals)]
+use arduboy_rust::prelude::*;
+const arduboy: Arduboy2 = Arduboy2::new();
+
Initialize the hardware, display the boot logo, provide boot utilities, etc.
This function should be called once near the start of the sketch, usually in setup(), before using any other functions in this class. It initializes the display, displays the boot logo, provides “flashlight†and system control features and initializes audio control.
-
Clear the display buffer and set the text cursor to location 0, 0.
-
Copy the contents of the display buffer to the display.
+
Clear the display buffer and set the text cursor to location 0, 0.
+
Copy the contents of the display buffer to the display.
The contents of the display buffer in RAM are copied to the display and will appear on the screen.
-
Copy the contents of the display buffer to the display. The display buffer will be cleared to zero.
+
Copy the contents of the display buffer to the display. The display buffer will be cleared to zero.
Operation is the same as calling display() without parameters except additionally the display buffer will be cleared.
-
Draw a horizontal line.
+
Draw a horizontal line.
- x The X coordinate of the left start point.
@@ -17,7 +19,7 @@ The contents of the display buffer in RAM are copied to the display and will app
- w The width of the line.
color The color of the line (optional; defaults to WHITE).
-
Draw a vertical line.
- x The X coordinate of the left start point.
@@ -25,7 +27,7 @@ The contents of the display buffer in RAM are copied to the display and will app
- h The height of the line.
color The color of the line (optional; defaults to WHITE).
-
Set a single pixel in the display buffer to the specified color.
+
Set a single pixel in the display buffer to the specified color.
- x The X coordinate of the pixel.
@@ -33,7 +35,7 @@ The contents of the display buffer in RAM are copied to the display and will app
- color The color of the pixel (optional; defaults to WHITE).
The single pixel specified location in the display buffer is set to the specified color. The values WHITE or BLACK can be used for the color. If the color parameter isn’t included, the pixel will be set to WHITE.
-
Draw a filled-in rectangle of a specified width and height.
+
Draw a filled-in rectangle of a specified width and height.
- x The X coordinate of the upper left corner.
@@ -42,7 +44,7 @@ The contents of the display buffer in RAM are copied to the display and will app
- h The height of the rectangle.
color The color of the pixel (optional; defaults to WHITE).
-
Draw a rectangle of a specified width and height.
+
Draw a rectangle of a specified width and height.
Parameters
- x The X coordinate of the upper left corner.
@@ -51,7 +53,7 @@ The contents of the display buffer in RAM are copied to the display and will app
- h The height of the rectangle.
- color The color of the pixel (optional; defaults to WHITE).
-
Draw a circle of a given radius.
+
Draw a circle of a given radius.
Parameters
- x0 The X coordinate of the circle’s center.
@@ -59,7 +61,7 @@ The contents of the display buffer in RAM are copied to the display and will app
- r The radius of the circle in pixels.
- color The circle’s color (optional; defaults to WHITE).
-
Draw a filled-in circle of a given radius.
+
Draw a filled-in circle of a given radius.
- x The X coordinate of the circle’s center.
@@ -67,7 +69,7 @@ The contents of the display buffer in RAM are copied to the display and will app
- r The radius of the circle in pixels.
color The circle’s color (optional; defaults to WHITE).
-
Draw a filled-in rectangle with rounded corners.
+
Draw a filled-in rectangle with rounded corners.
Parameters
- x The X coordinate of the left edge.
@@ -77,7 +79,7 @@ The contents of the display buffer in RAM are copied to the display and will app
- r The radius of the semicircles forming the corners.
- color The color of the rectangle (optional; defaults to WHITE).
-
Draw a rectangle with rounded corners.
+
Draw a rectangle with rounded corners.
Parameters
- x The X coordinate of the left edge.
@@ -87,7 +89,7 @@ The contents of the display buffer in RAM are copied to the display and will app
- r The radius of the semicircles forming the corners.
- color The color of the rectangle (optional; defaults to WHITE).
-
sourcecolor The triangle’s color (optional; defaults to WHITE).
A triangle is drawn by specifying each of the three corner locations. The corners can be at any position with respect to the others.
-
sourcecolor The triangle’s color (optional; defaults to WHITE).
A triangle is drawn by specifying each of the three corner locations. The corners can be at any position with respect to the others.
-
Returns the state of the given pixel in the screen buffer.
+
Returns the state of the given pixel in the screen buffer.
- x The X coordinate of the pixel.
@@ -129,9 +131,9 @@ The contents of the display buffer in RAM are copied to the display and will app
WHITE if the pixel is on or BLACK if the pixel is off.
-
Seed the random number generator with a random value.
+
Seed the random number generator with a random value.
The Arduino pseudorandom number generator is seeded with the random value returned from a call to generateRandomSeed().
-
Check if a button has just been pressed.
+
Check if a button has just been pressed.
- button The button to test for. Only one button should be specified.
@@ -141,7 +143,7 @@ The contents of the display buffer in RAM are copied to the display and will app
Return true if the given button was pressed between the latest call to pollButtons() and previous call to pollButtons(). If the button has been held down over multiple polls, this function will return false.
There is no need to check for the release of the button since it must have been released for this function to return true when pressed again.
This function should only be used to test a single button.
-
Check if a button has just been released.
+
Check if a button has just been released.
- button The button to test for. Only one button should be specified.
@@ -151,7 +153,7 @@ The contents of the display buffer in RAM are copied to the display and will app
Return true if the given button was released between the latest call to pollButtons() and previous call to pollButtons(). If the button has been held down over multiple polls, this function will return false.
There is no need to check for the released of the button since it must have been pressed for this function to return true when pressed again.
This function should only be used to test a single button.
-
Test if the specified buttons are not pressed.
+
Test if the specified buttons are not pressed.
- buttons A bit mask indicating which buttons to test. (Can be a single button)
@@ -159,16 +161,16 @@ The contents of the display buffer in RAM are copied to the display and will app
True if all buttons in the provided mask are currently released.
Read the state of the buttons and return true if all the buttons in the specified mask are currently released.
-
Indicate that it’s time to render the next frame.
+
Indicate that it’s time to render the next frame.
true if it’s time for the next frame.
When this function returns true, the amount of time has elapsed to display the next frame, as specified by setFrameRate() or setFrameDuration().
This function will normally be called at the start of the rendering loop which would wait for true to be returned before rendering and displaying the next frame.
-
Poll the buttons and track their state over time.
+
Poll the buttons and track their state over time.
Read and save the current state of the buttons and also keep track of the button state when this function was previously called. These states are used by the justPressed() and justReleased() functions to determine if a button has changed state between now and the previous call to pollButtons().
This function should be called once at the start of each new frame.
The justPressed() and justReleased() functions rely on this function.
-
Test if the all of the specified buttons are pressed.
+
Test if the all of the specified buttons are pressed.
- buttons A bit mask indicating which buttons to test. (Can be a single button)
@@ -176,16 +178,18 @@ The contents of the display buffer in RAM are copied to the display and will app
true if all buttons in the provided mask are currently pressed.
Read the state of the buttons and return true if all of the buttons in the specified mask are being pressed.
-
The Arduino Print class is available for writing text to the screen buffer.
+
The Arduino Print class is available for writing text to the screen buffer.
For an Arduboy2 class object, functions provided by the Arduino Print class can be used to write text to the screen buffer, in the same manner as the Arduino Serial.print(), etc., functions.
Print will use the write() function to actually draw each character in the screen buffer, using the library’s font5x7 font. Two character values are handled specially:
- ASCII newline/line feed (\n, 0x0A, inverse white circle). This will move the text cursor position to the start of the next line, based on the current text size.
- ASCII carriage return (\r, 0x0D, musical eighth note). This character will be ignored.
-
Example
-
-
let value: i16 = 42;
+
+#![allow(non_upper_case_globals)]
+use arduboy_rust::prelude::*;
+const arduboy: Arduboy2 = Arduboy2::new();
+let value: i16 = 42;
arduboy.print(b"Hello World\n\0"[..]);
-
Set the location of the text cursor.
+
Set the location of the text cursor.
-
@@ -204,41 +208,41 @@ arduboy.print(b"Hello World\n\0"[..]);
The location of the text cursor is set the the specified coordinates. The coordinates are in pixels. Since the coordinates can specify any pixel location, the text does not have to be placed on specific rows. As with all drawing functions, location 0, 0 is the top left corner of the display. The cursor location represents the top left corner of the next character written.
-
Set the frame rate used by the frame control functions.
+
Set the frame rate used by the frame control functions.
- rate The desired frame rate in frames per second.
Normally, the frame rate would be set to the desired value once, at the start of the game, but it can be changed at any time to alter the frame update rate.
-
Set the text character size.
+
Set the text character size.
- s The text size multiplier. Must be 1 or higher.
Setting a text size of 1 will result in standard size characters with one pixel for each bit in the bitmap for a character. The value specified is a multiplier. A value of 2 will double the width and height. A value of 3 will triple the dimensions, etc.
-
Turn sound on.
The system is configured to generate sound. This function sets the sound mode only until the unit is powered off.
-
Turn sound off (mute).
The system is configured to not produce sound (mute). This function sets the sound mode only until the unit is powered off.
-
Save the current sound state in EEPROM.
+
Save the current sound state in EEPROM.
The current sound state, set by on() or off(), is saved to the reserved system area in EEPROM. This allows the state to carry over between power cycles and after uploading a different sketch.
Note
EEPROM is limited in the number of times it can be written to. Sketches should not continuously change and then save the state rapidly.
-
Toggle the sound on/off state.
+
Toggle the sound on/off state.
If the system is configured for sound on, it will be changed to sound off (mute). If sound is off, it will be changed to on. This function sets the sound mode only until the unit is powered off. To save the current mode use saveOnOff().
-
Combines the use function of audio_on()
and audio_save_on_off()
-
Get the current sound state.
+
Combines the use function of audio_on()
and audio_save_on_off()
+
Get the current sound state.
true if sound is currently enabled (not muted).
This function should be used by code that actually generates sound. If true is returned, sound can be produced. If false is returned, sound should be muted.
-
Invert the entire display or set it back to normal.
+
Invert the entire display or set it back to normal.
- inverse true will invert the display. false will set the display to no-inverted.
Calling this function with a value of true will set the display to inverted mode. A pixel with a value of 0 will be on and a pixel set to 1 will be off.
Once in inverted mode, the display will remain this way until it is set back to non-inverted mode by calling this function with false.
-
Test if a point falls within a rectangle.
+
Test if a point falls within a rectangle.
Parameters
- point A structure describing the location of the point.
@@ -247,7 +251,7 @@ EEPROM is limited in the number of times it can be written to. Sketches should n
Returns
true if the specified point is within the specified rectangle.
This function is intended to detemine if an object, whose boundaries are defined by the given rectangle, is in contact with the given point.
-
Test if a rectangle is intersecting with another rectangle.
+
Test if a rectangle is intersecting with another rectangle.
Parameters
- rect1,rect2 Structures describing the size and locations of the rectangles.
@@ -255,14 +259,14 @@ true if the specified point is within the specified rectangle.
Returns
true if the first rectangle is intersecting the second.
This function is intended to detemine if an object, whose boundaries are defined by the given rectangle, is in contact with another rectangular object.
-
Set one of the RGB LEDs digitally, to either fully on or fully off.
+
Set one of the RGB LEDs digitally, to either fully on or fully off.
Parameters
- color The name of the LED to set. The value given should be one of RED_LED, GREEN_LED or BLUE_LED.
- val Indicates whether to turn the specified LED on or off. The value given should be RGB_ON or RGB_OFF.
This 2 parameter version of the function will set a single LED within the RGB LED either fully on or fully off. See the description of the 3 parameter version of this function for more details on the RGB LED.
-
Set the RGB LEDs digitally, to either fully on or fully off.
+
Set the RGB LEDs digitally, to either fully on or fully off.
Parameters
- red,green,blue Use value RGB_ON or RGB_OFF to set each LED.
@@ -278,7 +282,7 @@ true if the first rectangle is intersecting the second.
RGB_ON RGB_OFF RGB_ON Magenta
RGB_ON RGB_ON RGB_OFF Yellow
RGB_ON RGB_ON RGB_ON White
-
Set the brightness of one of the RGB LEDs without affecting the others.
+
Set the brightness of one of the RGB LEDs without affecting the others.
Parameters
- color The name of the LED to set. The value given should be one of RED_LED, GREEN_LED or BLUE_LED.
@@ -289,7 +293,7 @@ true if the first rectangle is intersecting the second.
In order to use this function, the 3 parameter version must first be called at least once, in order to initialize the hardware.
This 2 parameter version of the function will set the brightness of a single LED within the RGB LED without affecting the current brightness of the other two. See the description of the 3 parameter version of this function for more details on the RGB LED.
-
Set the light output of the RGB LED.
+
Set the light output of the RGB LED.
Parameters
- red,green,blue The brightness value for each LED.
@@ -303,7 +307,7 @@ true if the first rectangle is intersecting the second.
Many of the Kickstarter Arduboys were accidentally shipped with the RGB LED installed incorrectly. For these units, the green LED cannot be lit. As long as the green led is set to off, setting the red LED will actually control the blue LED and setting the blue LED will actually control the red LED. If the green LED is turned fully on, none of the LEDs will light.
-
Indicate if the specified number of frames has elapsed.
+
Indicate if the specified number of frames has elapsed.
Parameters
- frames The desired number of elapsed frames.
@@ -311,61 +315,75 @@ true if the first rectangle is intersecting the second.
Returns
true if the specified number of frames has elapsed.
This function should be called with the same value each time for a given event. It will return true if the given number of frames has elapsed since the previous frame in which it returned true.
-
+
If you wanted to fire a shot every 5 frames while the A button is being held down:
-if arduboy.everyXFrames(5) {
- if arduboy.pressed(A_BUTTON) {
- fireShot();
- }
-}
-
Flip the display vertically or set it back to normal.
+
#![allow(non_upper_case_globals)]
+ use arduboy_rust::prelude::*;
+ const arduboy: Arduboy2 = Arduboy2::new();
+
+ if arduboy.everyXFrames(5) {
+ if arduboy.pressed(A_BUTTON) {
+ }
+ }
+
Flip the display vertically or set it back to normal.
Parameters
- flipped true will set vertical flip mode. false will set normal vertical orientation.
Calling this function with a value of true will cause the Y coordinate to start at the bottom edge of the display instead of the top, effectively flipping the display vertically.
Once in vertical flip mode, it will remain this way until normal vertical mode is set by calling this function with a value of false.
-
Flip the display horizontally or set it back to normal.
+
Flip the display horizontally or set it back to normal.
Parameters
- flipped true will set horizontal flip mode. false will set normal horizontal orientation.
Calling this function with a value of true will cause the X coordinate to start at the left edge of the display instead of the right, effectively flipping the display horizontally.
Once in horizontal flip mode, it will remain this way until normal horizontal mode is set by calling this function with a value of false.
-
Set the text foreground color.
+
Set the text foreground color.
Parameters
- color The color to be used for following text. The values WHITE or BLACK should be used.
-
Set the text background color.
+
Set the text background color.
Parameters
- color The background color to be used for following text. The values WHITE or BLACK should be used.
The background pixels of following characters will be set to the specified color.
However, if the background color is set to be the same as the text color, the background will be transparent. Only the foreground pixels will be drawn. The background pixels will remain as they were before the character was drawn.
-
Set the X coordinate of the text cursor location.
+
Set the X coordinate of the text cursor location.
Parameters
- x The X (horizontal) coordinate, in pixels, for the new location of the text cursor.
The X coordinate for the location of the text cursor is set to the specified value, leaving the Y coordinate unchanged. For more details about the text cursor, see the setCursor() function.
-
Set the Y coordinate of the text cursor location.
+
Set the Y coordinate of the text cursor location.
Parameters
- y The Y (vertical) coordinate, in pixels, for the new location of the text cursor.
The Y coordinate for the location of the text cursor is set to the specified value, leaving the X coordinate unchanged. For more details about the text cursor, see the setCursor() function.
-
Set or disable text wrap mode.
+
Set or disable text wrap mode.
Parameters
- w true enables text wrap mode. false disables it.
Text wrap mode is enabled by specifying true. In wrap mode, if a character to be drawn would end up partially or fully past the right edge of the screen (based on the current text size), it will be placed at the start of the next line. The text cursor will be adjusted accordingly.
If wrap mode is disabled, characters will always be written at the current text cursor position. A character near the right edge of the screen may only be partially displayed and characters drawn at a position past the right edge of the screen will remain off screen.
-
Idle the CPU to save power.
+
Idle the CPU to save power.
This puts the CPU in idle sleep mode. You should call this as often as you can for the best power savings. The timer 0 overflow interrupt will wake up the chip every 1ms, so even at 60 FPS a well written app should be able to sleep maybe half the time in between rendering it’s own frames.
+
Get the current state of all buttons as a bitmask.
+
+
A bitmask of the state of all the buttons.
+
The returned mask contains a bit for each button. For any pressed button, its bit will be 1. For released buttons their associated bits will be 0.
+
The following defined mask values should be used for the buttons:
+LEFT_BUTTON, RIGHT_BUTTON, UP_BUTTON, DOWN_BUTTON, A_BUTTON, B_BUTTON
+
Exit the sketch and start the bootloader.
+
The sketch will exit and the bootloader will be started in command mode. The effect will be similar to pressing the reset button.
+
This function is intended to be used to allow uploading a new sketch, when the USB code has been removed to gain more code space. Ideally, the sketch would present a “New Sketch Upload†menu or prompt telling the user to “Press and hold the DOWN button when the procedure to upload a new sketch has been initiatedâ€.
+The sketch would then wait for the DOWN button to be pressed and then call this function.
Immutably borrows from an owned value.
Read more