reordering the crate and addind more documentation

This commit is contained in:
ZennDev1337 2023-08-15 11:34:37 +02:00
parent 2111e26566
commit 6fb155dff3
14 changed files with 637 additions and 174 deletions

View file

@ -47,6 +47,59 @@ extern "C"
{ {
arduboy.drawRect(x, y, w, h, color); arduboy.drawRect(x, y, w, h, color);
} }
void arduboy_fill_round_rect(int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t r, uint8_t color)
{
arduboy.fillRoundRect(x, y, w, h, r, color);
}
void arduboy_draw_round_rect(int16_t x, int16_t y, uint8_t w, uint8_t h, uint8_t r, uint8_t color)
{
arduboy.drawRoundRect(x, y, w, h, r, color);
}
void arduboy_fill_triangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color)
{
arduboy.fillTriangle(x0, y0, x1, y1, x2, y2, color);
}
void arduboy_draw_triangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color)
{
arduboy.drawTriangle(x0, y0, x1, y1, x2, y2, color);
}
bool arduboy_every_x_frames(uint8_t frames)
{
return arduboy.everyXFrames(frames);
}
void arduboy_flip_horizontal(bool flipped)
{
arduboy.flipHorizontal(flipped);
}
void arduboy_flip_vertical(bool flipped)
{
arduboy.flipVertical(flipped);
}
void arduboy_set_text_color(uint8_t color)
{
arduboy.setTextColor(color);
}
void arduboy_set_text_background_color(uint8_t color)
{
arduboy.setTextBackground(color);
}
void arduboy_set_cursor_x(int16_t x)
{
arduboy.setCursorX(x);
}
void arduboy_set_cursor_y(int16_t y)
{
arduboy.setCursorY(y);
}
void arduboy_set_text_wrap(bool w)
{
arduboy.setTextWrap(w);
}
void arduboy_idle()
{
arduboy.idle();
}
unsigned long arduboy_generate_random_seed() unsigned long arduboy_generate_random_seed()
{ {
return arduboy.generateRandomSeed(); return arduboy.generateRandomSeed();
@ -131,4 +184,12 @@ extern "C"
{ {
arduboy.invert(inverse); arduboy.invert(inverse);
} }
void arduboy_digital_write_rgb_single(uint8_t color, uint8_t val)
{
arduboy.digitalWriteRGB(color, val);
}
void arduboy_digital_write_rgb(uint8_t red, uint8_t green, uint8_t blue)
{
arduboy.digitalWriteRGB(red, green, blue);
}
} }

View file

@ -43,18 +43,18 @@ pub struct ButtonSet {
impl ButtonSet { impl ButtonSet {
pub unsafe fn pressed(&self) -> bool { pub unsafe fn pressed(&self) -> bool {
crate::library::arduboy::pressed(self.flag_set) crate::library::arduboy2::pressed(self.flag_set)
} }
pub unsafe fn just_pressed(&self) -> bool { pub unsafe fn just_pressed(&self) -> bool {
crate::library::arduboy::just_pressed(self.flag_set) crate::library::arduboy2::just_pressed(self.flag_set)
} }
pub unsafe fn just_released(&self) -> bool { pub unsafe fn just_released(&self) -> bool {
crate::library::arduboy::just_released(self.flag_set) crate::library::arduboy2::just_released(self.flag_set)
} }
pub unsafe fn not_pressed(&self) -> bool { pub unsafe fn not_pressed(&self) -> bool {
crate::library::arduboy::not_pressed(self.flag_set) crate::library::arduboy2::not_pressed(self.flag_set)
} }
} }

View file

@ -0,0 +1,11 @@
//! A list of all LED variables available
///Just a `const` for the red led
pub const RED_LED: u8 = 10;
///Just a `const` for the green led
pub const GREEN_LED: u8 = 11;
///Just a `const` for the blue led
pub const BLUE_LED: u8 = 9;
///Just a `const` for led on
pub const RGB_ON: u8 = 1;
///Just a `const` for led off
pub const RGB_OFF: u8 = 0;

View file

@ -1 +1,2 @@
pub mod buttons; pub mod buttons;
pub mod led;

View file

@ -1,14 +1,14 @@
#![cfg(target_arch = "avr")] #![cfg(target_arch = "avr")]
#![no_std] #![no_std]
#![feature(c_size_t)] #![feature(c_size_t)]
extern crate panic_halt; extern crate panic_halt;
mod hardware; mod hardware;
mod library; mod library;
pub mod prelude; pub mod prelude;
mod print; mod print;
pub use crate::library::arduboy::{Arduboy, Color, FONT_SIZE, HEIGHT, WIDTH}; pub use crate::library::arduboy2::{self, Arduboy2, Color, FONT_SIZE, HEIGHT, WIDTH};
pub use crate::library::arduboy_tone::Sound; pub use crate::library::arduboy_tone::ArduboyTones;
pub use crate::library::eeprom::{EEPROM, EEPROMBYTE}; pub use crate::library::eeprom::{EEPROM, EEPROMBYTE};
pub use crate::library::{arduboy_tone_pitch, c, sprites}; pub use crate::library::{arduboy_tone_pitch, c, sprites};
pub use hardware::*;
pub use hardware::buttons;

View file

@ -1,7 +1,6 @@
//! This is the Module to interact in a save way with the Arduboy2 C++ library. //! This is the Module to interact in a save way with the Arduboy2 C++ library.
//! //!
//! Ignore the functions here you only need to import the prelude here you will find all sorts of unsafe functions //! All of the functions are safe wrapped inside the struct.
//! All of them are safe wrapped inside the struct.
#![allow(dead_code)] #![allow(dead_code)]
use crate::prelude::ButtonSet; use crate::prelude::ButtonSet;
use crate::print::Printable; use crate::print::Printable;
@ -60,10 +59,15 @@ pub struct Point {
} }
/// This is the struct to interact in a save way with the Arduboy2 C++ library. /// This is the struct to interact in a save way with the Arduboy2 C++ library.
pub struct Arduboy {} pub struct Arduboy2 {}
impl Arduboy { impl Arduboy2 {
/// gives you a new instans of the [Arduboy2]
/// ## Example
/// ```
/// const arduboy: Arduboy2 = Arduboy2::new();
/// ```
pub fn new() -> Self { pub fn new() -> Self {
Arduboy {} Arduboy2 {}
} }
/// Initialize the hardware, display the boot logo, provide boot utilities, etc. /// 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. /// 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.
@ -143,9 +147,24 @@ impl Arduboy {
pub fn fill_rect(&self, x: i16, y: i16, w: u8, h: u8, color: Color) { pub fn fill_rect(&self, x: i16, y: i16, w: u8, h: u8, color: Color) {
unsafe { fill_rect_raw(x, y, w, h, color as u8) } unsafe { fill_rect_raw(x, y, w, h, color as u8) }
} }
///Draw a rectangle of a specified width and height.
///
///Parameters
///- x The X coordinate of the upper left corner.
///- y The Y coordinate of the upper left corner.
///- w The width of the rectangle.
///- h The height of the rectangle.
///- color The color of the pixel (optional; defaults to WHITE).
pub fn draw_rect(&self, x: i16, y: i16, w: u8, h: u8, color: Color) { pub fn draw_rect(&self, x: i16, y: i16, w: u8, h: u8, color: Color) {
unsafe { draw_rect_raw(x, y, w, h, color as u8) } unsafe { draw_rect_raw(x, y, w, h, color as u8) }
} }
///Draw a circle of a given radius.
///
///Parameters
///- x0 The X coordinate of the circle's center.
///- y0 The Y coordinate of the circle's center.
///- r The radius of the circle in pixels.
///- color The circle's color (optional; defaults to WHITE).
pub fn draw_circle(&self, x: i16, y: i16, r: u8, color: Color) { pub fn draw_circle(&self, x: i16, y: i16, r: u8, color: Color) {
unsafe { draw_circle_raw(x, y, r, color as u8) } unsafe { draw_circle_raw(x, y, r, color as u8) }
} }
@ -163,6 +182,70 @@ impl Arduboy {
pub fn fill_circle(&self, x: i16, y: i16, r: u8, color: Color) { pub fn fill_circle(&self, x: i16, y: i16, r: u8, color: Color) {
unsafe { fill_circle_raw(x, y, r, color as u8) } unsafe { fill_circle_raw(x, y, r, color as u8) }
} }
///Draw a filled-in rectangle with rounded corners.
///
///Parameters
///- x The X coordinate of the left edge.
///- y The Y coordinate of the top edge.
///- w The width of the rectangle.
///- h The height of the rectangle.
///- r The radius of the semicircles forming the corners.
///- color The color of the rectangle (optional; defaults to WHITE).
pub fn fill_round_rect(&self, x: i16, y: i16, w: u8, h: u8, r: u8, color: Color) {
unsafe { fill_round_rect(x, y, w, h, r, color as u8) }
}
///Draw a rectangle with rounded corners.
///
///Parameters
///- x The X coordinate of the left edge.
///- y The Y coordinate of the top edge.
///- w The width of the rectangle.
///- h The height of the rectangle.
///- r The radius of the semicircles forming the corners.
///- color The color of the rectangle (optional; defaults to WHITE).
pub fn draw_round_rect(&self, x: i16, y: i16, w: u8, h: u8, r: u8, color: Color) {
unsafe { draw_round_rect(x, y, w, h, r, color as u8) }
}
///Draw a triangle given the coordinates of each corner.
///
///Parameters
///- x0,x1,x2 The X coordinates of the corners.
///- y0,y1,y2 The Y coordinates of the corners.
///- color 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.
pub fn draw_triangle(
&self,
x0: i16,
y0: i16,
x1: i16,
y1: i16,
x2: i16,
y2: i16,
color: Color,
) {
unsafe { draw_triangle(x0, y0, x1, y1, x2, y2, color as u8) }
}
///Draw a filled-in triangle given the coordinates of each corner.
///
///Parameters
///- x0,x1,x2 The X coordinates of the corners.
///- y0,y1,y2 The Y coordinates of the corners.
///- color 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.
pub fn fill_triangle(
&self,
x0: i16,
y0: i16,
x1: i16,
y1: i16,
x2: i16,
y2: i16,
color: Color,
) {
unsafe { fill_triangle(x0, y0, x1, y1, x2, y2, color as u8) }
}
///Returns the state of the given pixel in the screen buffer. ///Returns the state of the given pixel in the screen buffer.
/// ///
///### Parameters ///### Parameters
@ -325,12 +408,22 @@ impl Arduboy {
pub fn audio_off(&self) { pub fn audio_off(&self) {
unsafe { arduboy_audio_off() } unsafe { arduboy_audio_off() }
} }
/// 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.
pub fn audio_save_on_off(&self) { pub fn audio_save_on_off(&self) {
unsafe { arduboy_audio_save_on_off() } unsafe { arduboy_audio_save_on_off() }
} }
///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().
pub fn audio_toggle(&self) { pub fn audio_toggle(&self) {
unsafe { arduboy_audio_toggle() } unsafe { arduboy_audio_toggle() }
} }
/// Combines the use function of `audio_on()` and `audio_save_on_off()`
pub fn audio_on_and_save(&self) { pub fn audio_on_and_save(&self) {
unsafe { unsafe {
arduboy_audio_on(); arduboy_audio_on();
@ -357,33 +450,181 @@ impl Arduboy {
pub fn invert(&self, inverse: bool) { pub fn invert(&self, inverse: bool) {
unsafe { arduboy_invert(inverse) } unsafe { arduboy_invert(inverse) }
} }
pub fn collide_point(point: Point, rect: Rect) -> bool { ///Test if a point falls within a rectangle.
///
///Parameters
///- point A structure describing the location of the point.
///- rect A structure describing the location and size of the rectangle.
///
///Returns
/// true if the specified point is within the specified rectangle.
///
///This function is intended to detemine if an object, whose boundaries are are defined by the given rectangle, is in contact with the given point.
pub fn collide_point(&self, point: Point, rect: Rect) -> bool {
point.x >= rect.x point.x >= rect.x
&& point.x < rect.x + rect.width as i16 && point.x < rect.x + rect.width as i16
&& point.y >= rect.y && point.y >= rect.y
&& point.y < rect.y + rect.height as i16 && point.y < rect.y + rect.height as i16
} }
pub fn collide_rect(rect1: Rect, rect2: Rect) -> bool { ///Test if a rectangle is intersecting with another rectangle.
///
///Parameters
/// - rect1,rect2 Structures describing the size and locations of the rectangles.
///
///Returns
/// true if the first rectangle is intersecting the second.
///
///This function is intended to detemine if an object, whose boundaries are are defined by the given rectangle, is in contact with another rectangular object.
pub fn collide_rect(&self, rect1: Rect, rect2: Rect) -> bool {
!(rect2.x >= rect1.x + rect1.width as i16 !(rect2.x >= rect1.x + rect1.width as i16
|| rect2.x + rect2.width as i16 <= rect1.x || rect2.x + rect2.width as i16 <= rect1.x
|| rect2.y >= rect1.y + rect1.height as i16 || rect2.y >= rect1.y + rect1.height as i16
|| rect2.y + rect2.height as i16 <= rect1.y) || rect2.y + rect2.height as i16 <= rect1.y)
} }
/// 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.
pub fn digital_write_rgb_single(&self, color: u8, val: u8) {
unsafe { digital_write_rgb_single(color, val) }
}
///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.
///
///The RGB LED is actually individual red, green and blue LEDs placed very close together in a single package. This 3 parameter version of the function will set each LED either on or off, to set the RGB LED to 7 different colors at their highest brightness or turn it off.
///```text
/// The colors are as follows:
/// RED LED GREEN LED BLUE LED COLOR
/// RGB_OFF RGB_OFF RGB_OFF OFF
/// RGB_OFF RGB_OFF RGB_ON Blue
/// RGB_OFF RGB_ON RGB_OFF Green
/// RGB_OFF RGB_ON RGB_ON Cyan
/// RGB_ON RGB_OFF RGB_OFF Red
/// RGB_ON RGB_OFF RGB_ON Magenta
/// RGB_ON RGB_ON RGB_OFF Yellow
/// RGB_ON RGB_ON RGB_ON White
/// ```
pub fn digital_write_rgb(&self, red: u8, green: u8, blue: u8) {
unsafe { digital_write_rgb(red, green, blue) }
}
///Indicate if the specified number of frames has elapsed.
///
///Parameters
/// frames The desired number of elapsed frames.
///
///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.
///
///## Example
///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();
/// }
/// }
/// ```
pub fn every_x_frames(&self, frames: u8) -> bool {
unsafe { every_x_frames(frames) }
}
///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.
pub fn flip_vertical(&self, flipped: bool) {
unsafe { flip_vertical(flipped) }
}
///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.
pub fn flip_horizontal(&self, flipped: bool) {
unsafe { flip_horizontal(flipped) }
}
///Set the text foreground color.
///
///Parameters
///- color The color to be used for following text. The values WHITE or BLACK should be used.
pub fn set_text_color(&self, color: Color) {
unsafe { set_text_color(color as u8) }
}
///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.
pub fn set_text_background_color(&self, color: Color) {
unsafe { set_text_background_color(color as u8) }
}
///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.
pub fn set_cursor_x(&self, x: i16) {
unsafe { set_cursor_x(x) }
}
///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.
pub fn set_cursor_y(&self, y: i16) {
unsafe { set_cursor_y(y) }
}
///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.
pub fn set_text_wrap(&self, w: bool) {
unsafe { set_text_wrap(w) }
}
///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.
pub fn idle(&self) {
unsafe { idle() }
}
} }
extern "C" { extern "C" {
#[doc(hidden)]
#[link_name = "arduboy_begin"] #[link_name = "arduboy_begin"]
pub fn begin(); fn begin();
#[doc(hidden)]
#[link_name = "arduboy_clear"] #[link_name = "arduboy_clear"]
pub fn clear(); fn clear();
#[doc(hidden)]
#[link_name = "arduboy_display"] #[link_name = "arduboy_display"]
pub fn display(); fn display();
#[doc(hidden)]
#[link_name = "arduboy_display_and_clear_buffer"] #[link_name = "arduboy_display_and_clear_buffer"]
pub fn display_and_clear_buffer(); fn display_and_clear_buffer();
#[doc(hidden)]
#[link_name = "arduboy_draw_fast_hline"] #[link_name = "arduboy_draw_fast_hline"]
fn draw_fast_hline_raw(x: i16, y: i16, w: u8, color: u8); fn draw_fast_hline_raw(x: i16, y: i16, w: u8, color: u8);
@ -405,63 +646,75 @@ extern "C" {
#[link_name = "arduboy_fill_rect"] #[link_name = "arduboy_fill_rect"]
fn fill_rect_raw(x: i16, y: i16, w: u8, h: u8, color: u8); fn fill_rect_raw(x: i16, y: i16, w: u8, h: u8, color: u8);
#[link_name = "arduboy_fill_round_rect"]
fn fill_round_rect(x: i16, y: i16, w: u8, h: u8, r: u8, color: u8);
#[link_name = "arduboy_draw_round_rect"]
fn draw_round_rect(x: i16, y: i16, w: u8, h: u8, r: u8, color: u8);
#[link_name = "arduboy_fill_triangle"]
fn fill_triangle(x0: i16, y0: i16, x1: i16, y1: i16, x2: i16, y2: i16, color: u8);
#[link_name = "arduboy_draw_triangle"]
fn draw_triangle(x0: i16, y0: i16, x1: i16, y1: i16, x2: i16, y2: i16, color: u8);
#[link_name = "arduboy_get_pixel"] #[link_name = "arduboy_get_pixel"]
fn get_pixel_raw(x: u8, y: u8) -> u8; fn get_pixel_raw(x: u8, y: u8) -> u8;
#[doc(hidden)]
#[link_name = "arduboy_init_random_seed"] #[link_name = "arduboy_init_random_seed"]
pub fn init_random_seed(); fn init_random_seed();
#[doc(hidden)]
#[link_name = "arduboy_just_pressed"] #[link_name = "arduboy_just_pressed"]
pub fn just_pressed(button: u8) -> bool; pub fn just_pressed(button: u8) -> bool;
#[doc(hidden)]
#[link_name = "arduboy_just_released"] #[link_name = "arduboy_just_released"]
pub fn just_released(button: u8) -> bool; pub fn just_released(button: u8) -> bool;
#[doc(hidden)]
#[link_name = "arduboy_not_pressed"] #[link_name = "arduboy_not_pressed"]
pub fn not_pressed(button: u8) -> bool; pub fn not_pressed(button: u8) -> bool;
#[doc(hidden)]
#[link_name = "arduboy_next_frame"] #[link_name = "arduboy_next_frame"]
pub fn next_frame() -> bool; fn next_frame() -> bool;
#[doc(hidden)]
#[link_name = "arduboy_poll_buttons"] #[link_name = "arduboy_poll_buttons"]
pub fn poll_buttons(); fn poll_buttons();
#[doc(hidden)]
#[link_name = "arduboy_pressed"] #[link_name = "arduboy_pressed"]
pub fn pressed(buttons: u8) -> bool; pub fn pressed(buttons: u8) -> bool;
#[doc(hidden)]
#[link_name = "arduboy_print_chars"] #[link_name = "arduboy_print_chars"]
pub fn print_chars(cstr: *const c_char); pub fn print_chars(cstr: *const c_char);
#[doc(hidden)]
#[link_name = "arduboy_print_chars_progmem"] #[link_name = "arduboy_print_chars_progmem"]
pub fn print_chars_progmem(pstring: *const c_char); pub fn print_chars_progmem(pstring: *const c_char);
// #[link_name = "arduboy_print_char"] // #[link_name = "arduboy_print_char"]
// fn print_char(c: c_char) -> c_size_t; // fn print_char(c: c_char) -> c_size_t;
#[doc(hidden)]
#[link_name = "arduboy_print_int"] #[link_name = "arduboy_print_int"]
pub fn print_int(n: c_int, base: c_int) -> c_size_t; pub fn print_int(n: c_int, base: c_int) -> c_size_t;
#[doc(hidden)]
#[link_name = "arduboy_print_long"] #[link_name = "arduboy_print_long"]
pub fn print_long(n: c_long, base: c_int) -> c_size_t; pub fn print_long(n: c_long, base: c_int) -> c_size_t;
#[doc(hidden)]
#[link_name = "arduboy_print_unsigned_char"] #[link_name = "arduboy_print_unsigned_char"]
pub fn print_unsigned_char(n: c_uchar, base: c_int) -> c_size_t; pub fn print_unsigned_char(n: c_uchar, base: c_int) -> c_size_t;
#[doc(hidden)]
#[link_name = "arduboy_print_unsigned_int"] #[link_name = "arduboy_print_unsigned_int"]
pub fn print_unsigned_int(n: c_uint, base: c_int) -> c_size_t; pub fn print_unsigned_int(n: c_uint, base: c_int) -> c_size_t;
#[doc(hidden)]
#[link_name = "arduboy_print_unsigned_long"] #[link_name = "arduboy_print_unsigned_long"]
pub fn print_unsigned_long(n: c_ulong, base: c_int) -> c_size_t; pub fn print_unsigned_long(n: c_ulong, base: c_int) -> c_size_t;
#[doc(hidden)]
#[link_name = "arduboy_set_cursor"] #[link_name = "arduboy_set_cursor"]
pub fn set_cursor(x: i16, y: i16); fn set_cursor(x: i16, y: i16);
#[doc(hidden)]
#[link_name = "arduboy_set_frame_rate"] #[link_name = "arduboy_set_frame_rate"]
pub fn set_frame_rate(rate: u8); fn set_frame_rate(rate: u8);
#[doc(hidden)]
#[link_name = "arduboy_set_text_size"] #[link_name = "arduboy_set_text_size"]
pub fn set_text_size(size: u8); fn set_text_size(size: u8);
#[doc(hidden)]
#[link_name = "arduboy_audio_on"] #[link_name = "arduboy_audio_on"]
fn arduboy_audio_on(); fn arduboy_audio_on();
@ -479,32 +732,64 @@ extern "C" {
#[link_name = "arduboy_invert"] #[link_name = "arduboy_invert"]
fn arduboy_invert(inverse: bool); fn arduboy_invert(inverse: bool);
#[link_name = "arduboy_every_x_frames"]
fn every_x_frames(frames: u8) -> bool;
#[link_name = "arduboy_flip_horizontal"]
fn flip_horizontal(flipped: bool);
#[link_name = "arduboy_flip_vertical"]
fn flip_vertical(flipped: bool);
#[link_name = "arduboy_set_text_color"]
fn set_text_color(color: u8);
#[link_name = "arduboy_set_text_background_color"]
fn set_text_background_color(color: u8);
#[link_name = "arduboy_set_cursor_x"]
fn set_cursor_x(x: i16);
#[link_name = "arduboy_set_cursor_y"]
fn set_cursor_y(y: i16);
#[link_name = "arduboy_set_text_wrap"]
fn set_text_wrap(w: bool);
#[link_name = "arduboy_idle"]
fn idle();
#[link_name = "arduboy_digital_write_rgb_single"]
fn digital_write_rgb_single(color: c_uchar, val: c_uchar);
#[link_name = "arduboy_digital_write_rgb"]
fn digital_write_rgb(red: c_uchar, green: c_uchar, blue: c_uchar);
} }
pub unsafe fn print(x: impl Printable) { // pub unsafe fn print(x: impl Printable) {
x.print(); // x.print();
} // }
pub unsafe fn draw_fast_hline(x: i16, y: i16, w: u8, color: Color) { // pub unsafe fn draw_fast_hline(x: i16, y: i16, w: u8, color: Color) {
draw_fast_hline_raw(x, y, w, color as u8); // draw_fast_hline_raw(x, y, w, color as u8);
} // }
pub unsafe fn draw_fast_vline(x: i16, y: i16, h: u8, color: Color) { // pub unsafe fn draw_fast_vline(x: i16, y: i16, h: u8, color: Color) {
draw_fast_vline_raw(x, y, h, color as u8); // draw_fast_vline_raw(x, y, h, color as u8);
} // }
pub unsafe fn draw_pixel(x: i16, y: i16, color: Color) { // pub unsafe fn draw_pixel(x: i16, y: i16, color: Color) {
draw_pixel_raw(x, y, color as u8); // draw_pixel_raw(x, y, color as u8);
} // }
pub unsafe fn fill_rect(x: i16, y: i16, w: u8, h: u8, color: Color) { // pub unsafe fn fill_rect(x: i16, y: i16, w: u8, h: u8, color: Color) {
fill_rect_raw(x, y, w, h, color as u8); // fill_rect_raw(x, y, w, h, color as u8);
} // }
pub unsafe fn draw_circle(x: i16, y: i16, r: u8, color: Color) { // pub unsafe fn draw_circle(x: i16, y: i16, r: u8, color: Color) {
draw_circle_raw(x, y, r, color as u8); // draw_circle_raw(x, y, r, color as u8);
} // }
pub unsafe fn get_pixel(x: u8, y: u8) -> Color { // pub unsafe fn get_pixel(x: u8, y: u8) -> Color {
mem::transmute::<u8, Color>(get_pixel_raw(x, y)) // mem::transmute::<u8, Color>(get_pixel_raw(x, y))
} // }

View file

@ -33,14 +33,39 @@ extern "C" {
} }
///This is the struct to interact in a save way with the Arduboy2Audio C++ library. ///This is the struct to interact in a save way with the Arduboy2Audio C++ library.
pub struct Sound {} pub struct ArduboyTones {}
impl Sound { impl ArduboyTones {
///Get a new instance of [ArduboyTones]
/// ## Example
/// ```
/// const sound: ArduboyTones = ArduboyTones::new();
/// ```
pub fn new() -> ArduboyTones {
ArduboyTones {}
}
///Play a single tone.
///
///- freq The frequency of the tone, in hertz.
///- dur The duration to play the tone for, in 1024ths of a
///second (very close to milliseconds). A duration of 0, or if not provided,
///means play forever, or until `noTone()` is called or a new tone or
///sequence is started.
pub fn tone(&self, frequency: u16, duration: u32) { pub fn tone(&self, frequency: u16, duration: u32) {
unsafe { sound_tone(frequency, duration) } unsafe { sound_tone(frequency, duration) }
} }
/// Play two tones in sequence.
///
/// - freq1,freq2 The frequency of the tone in hertz.
/// - dur1,dur2 The duration to play the tone for, in 1024ths of a
/// second (very close to milliseconds).
pub fn tone2(&self, frequency1: u16, duration1: u32, frequency2: u16, duration2: u32) { pub fn tone2(&self, frequency1: u16, duration1: u32, frequency2: u16, duration2: u32) {
unsafe { sound_tone2(frequency1, duration1, frequency2, duration2) } unsafe { sound_tone2(frequency1, duration1, frequency2, duration2) }
} }
/// Play three tones in sequence.
///
/// - freq1,freq2,freq3 The frequency of the tone, in hertz.
/// - dur1,dur2,dur3 The duration to play the tone for, in 1024ths of a
/// second (very close to milliseconds).
pub fn tone3( pub fn tone3(
&self, &self,
frequency1: u16, frequency1: u16,
@ -52,18 +77,71 @@ impl Sound {
) { ) {
unsafe { sound_tone3(frequency1, duration1, frequency2, duration2, frequency3, duration3) } unsafe { sound_tone3(frequency1, duration1, frequency2, duration2, frequency3, duration3) }
} }
/// Play a tone sequence from frequency/duration pairs in a PROGMEM array.
///
/// - tones A pointer to an array of frequency/duration pairs.
///
/// The array must be placed in code space using `PROGMEM`.
///
/// See the `tone()` function for details on the frequency and duration values.
/// A frequency of 0 for any tone means silence (a musical rest).
///
/// The last element of the array must be `TONES_END` or `TONES_REPEAT`.
///
/// Example:
/// ```
/// progmem!(
/// static sound1:[u8;_]=[220,1000, 0,250, 440,500, 880,2000,TONES_END]
/// );
///
/// tones(get_tones_addr!(sound1));
/// ```
pub fn tones(&self, tones: *const u16) { pub fn tones(&self, tones: *const u16) {
unsafe { sound_tones(tones) } unsafe { sound_tones(tones) }
} }
/// Stop playing the tone or sequence.
///
/// If a tone or sequence is playing, it will stop. If nothing
/// is playing, this function will do nothing.
pub fn no_tone(&self) { pub fn no_tone(&self) {
unsafe { sound_no_tone() } unsafe { sound_no_tone() }
} }
/// Check if a tone or tone sequence is playing.
///
/// - return boolean `true` if playing (even if sound is muted).
pub fn playing(&self) -> bool { pub fn playing(&self) -> bool {
unsafe { sound_playing() } unsafe { sound_playing() }
} }
/// Play a tone sequence from frequency/duration pairs in an array in RAM.
///
/// - tones A pointer to an array of frequency/duration pairs.
///
/// The array must be located in RAM.
///
/// See the `tone()` function for details on the frequency and duration values.
/// A frequency of 0 for any tone means silence (a musical rest).
///
/// The last element of the array must be `TONES_END` or `TONES_REPEAT`.
///
/// Example:
///
/// ```
/// let sound2: [u16; 9] = [220, 1000, 0, 250, 440, 500, 880, 2000, TONES_END];
/// ```
/// Using `tones()`, with the data in PROGMEM, is normally a better
/// choice. The only reason to use tonesInRAM() would be if dynamically
/// altering the contents of the array is required.
pub fn tones_in_ram(&self, tones: *mut u32) { pub fn tones_in_ram(&self, tones: *mut u32) {
unsafe { sound_tones_in_ram(tones) } unsafe { sound_tones_in_ram(tones) }
} }
/// Set the volume to always normal, always high, or tone controlled.
///
/// One of the following values should be used:
///
/// - `VOLUME_IN_TONE` The volume of each tone will be specified in the tone
/// itself.
/// - `VOLUME_ALWAYS_NORMAL` All tones will play at the normal volume level.
/// - `VOLUME_ALWAYS_HIGH` All tones will play at the high volume level.
pub fn volume_mode(&self, mode: u8) { pub fn volume_mode(&self, mode: u8) {
unsafe { sound_volume_mode(mode) } unsafe { sound_volume_mode(mode) }
} }

View file

@ -1,6 +1,4 @@
//! A list of all tones available and used by the Sounds library Arduboy2Tones //! A list of all tones available and used by the Sounds library Arduboy2Tones
pub const NDUR: u16 = 100;
pub const TONES_END: u16 = 0x8000; pub const TONES_END: u16 = 0x8000;
pub const TONES_REPEAT: u16 = 0x8001; pub const TONES_REPEAT: u16 = 0x8001;
pub const TONE_HIGH_VOLUME: u16 = 0x8000; pub const TONE_HIGH_VOLUME: u16 = 0x8000;

View file

@ -1,71 +0,0 @@
use core::ffi::{c_int, c_uchar};
pub const EEPROM_STORAGE_SPACE_START: c_int = 16;
extern "C" {
#[link_name = "arduboy_eeprom_read"]
fn arduboy_eeprom_read_raw(idx: c_int) -> c_uchar;
#[link_name = "arduboy_eeprom_update"]
fn arduboy_eeprom_update_raw(idx: c_int, val: c_uchar);
#[link_name = "arduboy_eeprom_write"]
fn arduboy_eeprom_write_raw(idx: c_int, val: c_uchar);
#[link_name = "arduboy_eeprom_get"]
fn arduboy_eeprom_get_raw(idx: c_int) -> c_uchar;
#[link_name = "arduboy_eeprom_put"]
fn arduboy_eeprom_put_raw(idx: c_int, val: c_uchar);
}
///This is the struct to interact in a save way with the EEPROM C++ library.
pub struct EEPROM {
start_c1: i16,
start_c2: i16,
pub idx: i16,
}
impl EEPROM {
pub const fn new(mut idx: i16) -> EEPROM {
if idx > 950 {
idx = 0
}
EEPROM {
start_c1: EEPROM_STORAGE_SPACE_START + idx,
start_c2: EEPROM_STORAGE_SPACE_START + idx + 1,
idx: EEPROM_STORAGE_SPACE_START + idx + 2,
}
}
pub fn init(&self) {
let c1 = self.read_start_c1();
let c2 = self.read_start_c2();
if c1 != b'Z' || c2 != b'D' {
self.update_start_c1(b'Z');
self.update_start_c2(b'D');
self.update(0);
};
}
pub fn read(&self) -> u8 {
unsafe { arduboy_eeprom_read_raw(self.idx) }
}
pub fn read_start_c1(&self) -> u8 {
unsafe { arduboy_eeprom_read_raw(self.start_c1) }
}
pub fn read_start_c2(&self) -> u8 {
unsafe { arduboy_eeprom_read_raw(self.start_c2) }
}
pub fn update(&self, val: u8) {
unsafe { arduboy_eeprom_update_raw(self.idx, val) }
}
pub fn update_start_c1(&self, val: u8) {
unsafe { arduboy_eeprom_update_raw(self.start_c1, val) }
}
pub fn update_start_c2(&self, val: u8) {
unsafe { arduboy_eeprom_update_raw(self.start_c2, val) }
}
pub fn write(&self, val: u8) {
unsafe { arduboy_eeprom_write_raw(self.idx, val) }
}
pub fn get(&self, buffer: &mut u8) {
*buffer = unsafe { arduboy_eeprom_get_raw(self.idx) }
}
pub fn put(&self, val: u8) {
unsafe { arduboy_eeprom_put_raw(self.idx, val) }
}
}

View file

@ -1,4 +1,4 @@
pub mod arduboy; pub mod arduboy2;
pub mod arduboy_tone; pub mod arduboy_tone;
pub mod arduboy_tone_pitch; pub mod arduboy_tone_pitch;
pub mod arduino; pub mod arduino;

View file

@ -8,7 +8,7 @@
/// ); /// );
/// //for tone sequence /// //for tone sequence
/// progmem!( /// progmem!(
/// static tone: [u16; 43] = [ /// static tone: [u16; _] = [
/// NOTE_E4, 400, NOTE_D4, 200, NOTE_C4, 400, NOTE_D4, 200, NOTE_C4, 300, NOTE_REST, /// NOTE_E4, 400, NOTE_D4, 200, NOTE_C4, 400, NOTE_D4, 200, NOTE_C4, 300, NOTE_REST,
/// ]; /// ];
/// ); /// );

View file

@ -25,19 +25,17 @@ extern "C" {
/// ///
/// ### Parameters /// ### Parameters
/// ///
/// x,y The coordinates of the top left pixel location. /// - x,y The coordinates of the top left pixel location.
/// /// - bitmap A pointer to the array containing the image frames.
/// bitmap A pointer to the array containing the image frames. /// - frame The frame number of the image to draw.
///
/// frame The frame number of the image to draw.
/// ///
/// A sprite is drawn by overwriting the pixels in the buffer with the data from the specified frame in the array. No masking is done. A bit set to 1 in the frame will set the pixel to 1 in the buffer, and a 0 in the array will set a 0 in the buffer. /// A sprite is drawn by overwriting the pixels in the buffer with the data from the specified frame in the array. No masking is done. A bit set to 1 in the frame will set the pixel to 1 in the buffer, and a 0 in the array will set a 0 in the buffer.
///``` ///```text
/// image before after (# = 1, - = 0) /// image before after (# = 1, - = 0)
/// ///
/// ----- ----- ----- /// ----- ----- -----
/// --#-- ----- --#-- /// --#-- ----- --#--
/// ###-## ----- ##-## /// ##-## ----- ##-##
/// --#-- ----- --#-- /// --#-- ----- --#--
/// ----- ----- ----- /// ----- ----- -----
/// ///
@ -45,13 +43,44 @@ extern "C" {
/// ///
/// ----- ##### ----- /// ----- ##### -----
/// --#-- ##### --#-- /// --#-- ##### --#--
/// ###-## ##### ##-## /// ##-## ##### ##-##
/// --#-- ##### --#-- /// --#-- ##### --#--
/// ----- ##### ----- /// ----- ##### -----
/// ``` /// ```
pub fn draw_override(x: i16, y: i16, bitmap: *const u8, frame: u8) { pub fn draw_override(x: i16, y: i16, bitmap: *const u8, frame: u8) {
unsafe { arduino_draw_override_raw(x, y, bitmap, frame) } unsafe { arduino_draw_override_raw(x, y, bitmap, frame) }
} }
///Draw a sprite using a separate image and mask array.
///
///Parameters
///- x,y The coordinates of the top left pixel location.
///- bitmap A pointer to the array containing the image frames.
///- mask A pointer to the array containing the mask frames.
///- frame The frame number of the image to draw.
///- mask_frame The frame number for the mask to use (can be different from the image frame number).
///
///An array containing the image frames, and another array containing corresponding mask frames, are used to draw a sprite.
///
///For the mask array, the width and height are not included but must contain data of the same dimensions as the corresponding image array.
///
///Bits set to 1 in the mask indicate that the pixel will be set to the value of the corresponding image bit. Bits set to 0 in the mask will be left unchanged.
///```text
/// image mask before after (# = 1, - = 0)
///
/// ----- -###- ----- -----
/// --#-- ##### ----- --#--
/// ##-## ##-## ----- ##-##
/// --#-- ##### ----- --#--
/// ----- -###- ----- -----
///
/// image mask before after
///
/// ----- -###- ##### #---#
/// --#-- ##### ##### --#--
/// ##-## ##### ##### ##-##
/// --#-- ##### ##### --#--
/// ----- -###- ##### #---#
/// ```
pub fn draw_external_mask( pub fn draw_external_mask(
x: i16, x: i16,
y: i16, y: i16,
@ -62,12 +91,89 @@ pub fn draw_external_mask(
) { ) {
unsafe { arduino_draw_external_mask_raw(x, y, bitmap, mask, frame, mask_frame) } unsafe { arduino_draw_external_mask_raw(x, y, bitmap, mask, frame, mask_frame) }
} }
///Draw a sprite using an array containing both image and mask values.
///
///Parameters
/// - x,y The coordinates of the top left pixel location.
/// - bitmap A pointer to the array containing the image/mask frames.
/// - frame The frame number of the image to draw.
///
///An array containing combined image and mask data is used to draw a sprite. Bytes are given in pairs with the first byte representing the image pixels and the second byte specifying the corresponding mask. The width given in the array still specifies the image width, so each row of image and mask bytes will be twice the width value.
///
///Bits set to 1 in the mask indicate that the pixel will be set to the value of the corresponding image bit. Bits set to 0 in the mask will be left unchanged.
///
///image mask before after (# = 1, - = 0)
///```text
/// ----- -###- ----- -----
/// --#-- ##### ----- --#--
/// ##-## ##-## ----- ##-##
/// --#-- ##### ----- --#--
/// ----- -###- ----- -----
///
/// image mask before after
///
/// ----- -###- ##### #---#
/// --#-- ##### ##### --#--
/// ##-## ##### ##### ##-##
/// --#-- ##### ##### --#--
/// ----- -###- ##### #---#
/// ```
pub fn draw_plus_mask(x: i16, y: i16, bitmap: *const u8, frame: u8) { pub fn draw_plus_mask(x: i16, y: i16, bitmap: *const u8, frame: u8) {
unsafe { arduino_draw_plus_mask_raw(x, y, bitmap, frame) } unsafe { arduino_draw_plus_mask_raw(x, y, bitmap, frame) }
} }
///"Erase" a sprite.
///
///Parameters
/// - x,y The coordinates of the top left pixel location.
/// - bitmap A pointer to the array containing the image frames.
/// - frame The frame number of the image to erase.
///
///The data from the specified frame in the array is used to erase a sprite. To "erase" a sprite, bits set to 1 in the frame will set the corresponding pixel in the buffer to 0. Frame bits set to 0 will remain unchanged in the buffer.
///```text
/// image before after (# = 1, - = 0)
///
/// ----- ----- -----
/// --#-- ----- -----
/// ##-## ----- -----
/// --#-- ----- -----
/// ----- ----- -----
///
/// image before after
///
/// ----- ##### #####
/// --#-- ##### ##-##
/// ##-## ##### --#--
/// --#-- ##### ##-##
/// ----- ##### #####
/// ```
pub fn draw_erase(x: i16, y: i16, bitmap: *const u8, frame: u8) { pub fn draw_erase(x: i16, y: i16, bitmap: *const u8, frame: u8) {
unsafe { arduino_draw_erase_raw(x, y, bitmap, frame) } unsafe { arduino_draw_erase_raw(x, y, bitmap, frame) }
} }
///Draw a sprite using only the bits set to 1.
///
///Parameters
/// - x,y The coordinates of the top left pixel location.
/// - bitmap A pointer to the array containing the image frames.
/// - frame The frame number of the image to draw.
///
///Bits set to 1 in the frame will be used to draw the sprite by setting the corresponding pixel in the buffer to 1. Bits set to 0 in the frame will remain unchanged in the buffer.
///```text
/// image before after (# = 1, - = 0)
///
/// ----- ----- -----
/// --#-- ----- --#--
/// ##-## ----- ##-##
/// --#-- ----- --#--
/// ----- ----- -----
///
/// image before after
///
/// ----- ##### ##### (no change because all pixels were
/// --#-- ##### ##### already white)
/// ##-## ##### #####
/// --#-- ##### #####
/// ----- ##### #####
/// ```
pub fn draw_self_masked(x: i16, y: i16, bitmap: *const u8, frame: u8) { pub fn draw_self_masked(x: i16, y: i16, bitmap: *const u8, frame: u8) {
unsafe { arduino_draw_self_masked_raw(x, y, bitmap, frame) } unsafe { arduino_draw_self_masked_raw(x, y, bitmap, frame) }
} }

View file

@ -1,19 +1,7 @@
//! This is the important one to use this library effective in your project //! This is the important one to use this library effective in your project
pub use crate::library::arduboy::Arduboy;
pub use core::ffi::{
c_char, c_double, c_float, c_int, c_long, c_longlong, c_size_t, c_uchar, c_uint, c_ulong,
c_ulonglong,
};
#[doc(hidden)]
pub use core::ptr::addr_of;
///The main [Arduboy] struct ready to use in your project
#[allow(non_upper_case_globals)]
pub const arduboy: Arduboy = Arduboy {};
///The main [Sound] struct ready to use in your project
#[allow(non_upper_case_globals)]
pub const sound: Sound = Sound {};
pub use crate::hardware::buttons::*; pub use crate::hardware::buttons::*;
pub use crate::library::arduboy::{Color, Point, Rect, FONT_SIZE, HEIGHT, WIDTH}; pub use crate::hardware::led::{BLUE_LED, GREEN_LED, RED_LED, RGB_OFF, RGB_ON};
pub use crate::library::arduboy2::{Arduboy2, Color, Point, Rect, FONT_SIZE, HEIGHT, WIDTH};
pub use crate::library::arduboy_tone::*; pub use crate::library::arduboy_tone::*;
pub use crate::library::arduino::*; pub use crate::library::arduino::*;
pub use crate::library::c::*; pub use crate::library::c::*;
@ -23,6 +11,12 @@ pub use crate::library::sprites;
pub use crate::print::*; pub use crate::print::*;
pub use crate::{f, get_sprite_addr, get_string_addr, get_tones_addr, progmem}; pub use crate::{f, get_sprite_addr, get_string_addr, get_tones_addr, progmem};
use core::cmp; use core::cmp;
pub use core::ffi::{
c_char, c_double, c_float, c_int, c_long, c_longlong, c_size_t, c_uchar, c_uint, c_ulong,
c_ulonglong,
};
#[doc(hidden)]
pub use core::ptr::addr_of;
pub fn constrain<T: Ord>(x: T, a: T, b: T) -> T { pub fn constrain<T: Ord>(x: T, a: T, b: T) -> T {
cmp::max(cmp::min(x, b), a) cmp::max(cmp::min(x, b), a)

View file

@ -28,7 +28,7 @@ impl Printable for i16 {
fn print_2(self, params: Self::Parameters) { fn print_2(self, params: Self::Parameters) {
unsafe { unsafe {
crate::library::arduboy::print_int(self, params as c_int); crate::library::arduboy2::print_int(self, params as c_int);
} }
} }
@ -42,7 +42,7 @@ impl Printable for u16 {
fn print_2(self, params: Self::Parameters) { fn print_2(self, params: Self::Parameters) {
unsafe { unsafe {
crate::library::arduboy::print_unsigned_int(self, params as c_int); crate::library::arduboy2::print_unsigned_int(self, params as c_int);
} }
} }
@ -56,7 +56,7 @@ impl Printable for i32 {
fn print_2(self, params: Self::Parameters) { fn print_2(self, params: Self::Parameters) {
unsafe { unsafe {
crate::library::arduboy::print_long(self, params as c_int); crate::library::arduboy2::print_long(self, params as c_int);
} }
} }
@ -70,7 +70,7 @@ impl Printable for u32 {
fn print_2(self, params: Self::Parameters) { fn print_2(self, params: Self::Parameters) {
unsafe { unsafe {
crate::library::arduboy::print_unsigned_long(self, params as c_int); crate::library::arduboy2::print_unsigned_long(self, params as c_int);
} }
} }
@ -84,7 +84,7 @@ impl Printable for &[u8] {
fn print_2(self, _params: Self::Parameters) { fn print_2(self, _params: Self::Parameters) {
unsafe { unsafe {
crate::library::arduboy::print_chars(self as *const [u8] as *const i8); crate::library::arduboy2::print_chars(self as *const [u8] as *const i8);
} }
} }
@ -96,7 +96,7 @@ impl Printable for &str {
fn print_2(self, _params: Self::Parameters) { fn print_2(self, _params: Self::Parameters) {
unsafe { unsafe {
crate::library::arduboy::print_chars(self.as_bytes() as *const [u8] as *const i8); crate::library::arduboy2::print_chars(self.as_bytes() as *const [u8] as *const i8);
} }
} }
@ -108,7 +108,7 @@ impl Printable for Pstring {
fn print_2(self, _params: Self::Parameters) { fn print_2(self, _params: Self::Parameters) {
unsafe { unsafe {
crate::library::arduboy::print_chars_progmem(self.pointer); crate::library::arduboy2::print_chars_progmem(self.pointer);
} }
} }