Big refactor and new run script
This commit is contained in:
parent
5796b78695
commit
a54fa90edc
68 changed files with 769 additions and 336 deletions
|
@ -47,18 +47,18 @@ pub struct ButtonSet {
|
|||
|
||||
impl ButtonSet {
|
||||
pub unsafe fn pressed(&self) -> bool {
|
||||
crate::library::arduboy2::pressed(self.flag_set)
|
||||
crate::libraries::arduboy2_library::binding::pressed(self.flag_set)
|
||||
}
|
||||
|
||||
pub unsafe fn just_pressed(&self) -> bool {
|
||||
crate::library::arduboy2::just_pressed(self.flag_set)
|
||||
crate::libraries::arduboy2_library::binding::just_pressed(self.flag_set)
|
||||
}
|
||||
|
||||
pub unsafe fn just_released(&self) -> bool {
|
||||
crate::library::arduboy2::just_released(self.flag_set)
|
||||
crate::libraries::arduboy2_library::binding::just_released(self.flag_set)
|
||||
}
|
||||
pub unsafe fn not_pressed(&self) -> bool {
|
||||
crate::library::arduboy2::not_pressed(self.flag_set)
|
||||
crate::libraries::arduboy2_library::binding::not_pressed(self.flag_set)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,15 +27,11 @@
|
|||
|
||||
extern crate panic_halt;
|
||||
pub mod hardware;
|
||||
mod library;
|
||||
mod libraries;
|
||||
pub mod prelude;
|
||||
mod print;
|
||||
|
||||
#[doc(inline)]
|
||||
pub extern crate heapless;
|
||||
pub use crate::library::arduboy2::{self, Arduboy2, Color, FONT_SIZE, HEIGHT, WIDTH};
|
||||
pub use crate::library::arduboy_tones::{self, ArduboyTones};
|
||||
pub use crate::library::ardvoice::{self, ArdVoice};
|
||||
pub use crate::library::eeprom::{EEPROM, EEPROMBYTE};
|
||||
pub use crate::library::{arduino, c, sprites};
|
||||
pub use crate::library::arduboyfx::{self};
|
||||
pub mod serial_print;
|
||||
pub use crate::libraries::{
|
||||
arduboy2_library, arduboy_tones_library, arduboyfx_library, arduino_system, ardvoice_library,
|
||||
};
|
||||
|
|
|
@ -3,16 +3,17 @@
|
|||
//! All of the functions are safe wrapped inside the [Arduboy2] struct.
|
||||
#![allow(dead_code)]
|
||||
|
||||
use super::binding::*;
|
||||
use super::print::Printable;
|
||||
use crate::hardware::buttons::ButtonSet;
|
||||
use crate::print::Printable;
|
||||
use core::ffi::{c_char, c_int, c_long, c_size_t, c_uchar, c_uint, c_ulong};
|
||||
use core::mem;
|
||||
use core::ops::Not;
|
||||
|
||||
/// The standard font size of the arduboy
|
||||
///
|
||||
/// this is to calculate with it.
|
||||
pub const FONT_SIZE: u8 = 6;
|
||||
pub const FONT_WIDTH: i16 = 6;
|
||||
pub const FONT_HEIGHT: i16 = 8;
|
||||
/// The standard width of the arduboy
|
||||
///
|
||||
/// this is to calculate with it.
|
||||
|
@ -650,7 +651,7 @@ impl Arduboy2 {
|
|||
///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
|
||||
/// LEFT_BUTTON, RIGHT_BUTTON, UP_BUTTON, DOWN_BUTTON, A_BUTTON, B_BUTTON
|
||||
pub fn buttons_state(&self) -> u8 {
|
||||
unsafe { arduboy_buttons_state() }
|
||||
}
|
||||
|
@ -658,175 +659,9 @@ impl Arduboy2 {
|
|||
///
|
||||
///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".
|
||||
///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.
|
||||
pub fn exit_to_bootloader(&self) {
|
||||
unsafe { arduboy_exit_to_bootloader() }
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
#[link_name = "arduboy_begin"]
|
||||
fn begin();
|
||||
|
||||
#[link_name = "arduboy_clear"]
|
||||
fn clear();
|
||||
|
||||
#[link_name = "arduboy_display"]
|
||||
fn display();
|
||||
|
||||
#[link_name = "arduboy_display_and_clear_buffer"]
|
||||
fn display_and_clear_buffer();
|
||||
|
||||
#[link_name = "arduboy_draw_fast_hline"]
|
||||
fn draw_fast_hline_raw(x: i16, y: i16, w: u8, color: u8);
|
||||
|
||||
#[link_name = "arduboy_draw_fast_vline"]
|
||||
fn draw_fast_vline_raw(x: i16, y: i16, h: u8, color: u8);
|
||||
|
||||
#[link_name = "arduboy_draw_pixel"]
|
||||
fn draw_pixel_raw(x: i16, y: i16, color: u8);
|
||||
|
||||
#[link_name = "arduboy_draw_circle"]
|
||||
fn draw_circle_raw(x: i16, y: i16, r: u8, color: u8);
|
||||
|
||||
#[link_name = "arduboy_draw_rect"]
|
||||
fn draw_rect_raw(x: i16, y: i16, w: u8, h: u8, color: u8);
|
||||
|
||||
#[link_name = "arduboy_fill_circle"]
|
||||
fn fill_circle_raw(x: i16, y: i16, r: u8, color: u8);
|
||||
|
||||
#[link_name = "arduboy_fill_rect"]
|
||||
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"]
|
||||
fn get_pixel_raw(x: u8, y: u8) -> u8;
|
||||
#[doc(hidden)]
|
||||
#[link_name = "arduboy_init_random_seed"]
|
||||
fn init_random_seed();
|
||||
#[doc(hidden)]
|
||||
#[link_name = "arduboy_just_pressed"]
|
||||
pub fn just_pressed(button: u8) -> bool;
|
||||
#[doc(hidden)]
|
||||
#[link_name = "arduboy_just_released"]
|
||||
pub fn just_released(button: u8) -> bool;
|
||||
#[doc(hidden)]
|
||||
#[link_name = "arduboy_not_pressed"]
|
||||
pub fn not_pressed(button: u8) -> bool;
|
||||
|
||||
#[link_name = "arduboy_next_frame"]
|
||||
fn next_frame() -> bool;
|
||||
|
||||
#[link_name = "arduboy_poll_buttons"]
|
||||
fn poll_buttons();
|
||||
#[doc(hidden)]
|
||||
#[link_name = "arduboy_pressed"]
|
||||
pub fn pressed(buttons: u8) -> bool;
|
||||
#[doc(hidden)]
|
||||
#[link_name = "arduboy_print_chars"]
|
||||
pub fn print_chars(cstr: *const c_char);
|
||||
#[doc(hidden)]
|
||||
#[link_name = "arduboy_print_chars_progmem"]
|
||||
pub fn print_chars_progmem(pstring: *const c_char);
|
||||
|
||||
// #[link_name = "arduboy_print_char"]
|
||||
// fn print_char(c: c_char) -> c_size_t;
|
||||
#[doc(hidden)]
|
||||
#[link_name = "arduboy_print_int"]
|
||||
pub fn print_int(n: c_int, base: c_int) -> c_size_t;
|
||||
#[doc(hidden)]
|
||||
#[link_name = "arduboy_print_long"]
|
||||
pub fn print_long(n: c_long, base: c_int) -> c_size_t;
|
||||
#[doc(hidden)]
|
||||
#[link_name = "arduboy_print_unsigned_char"]
|
||||
pub fn print_unsigned_char(n: c_uchar, base: c_int) -> c_size_t;
|
||||
#[doc(hidden)]
|
||||
#[link_name = "arduboy_print_unsigned_int"]
|
||||
pub fn print_unsigned_int(n: c_uint, base: c_int) -> c_size_t;
|
||||
#[doc(hidden)]
|
||||
#[link_name = "arduboy_print_unsigned_long"]
|
||||
pub fn print_unsigned_long(n: c_ulong, base: c_int) -> c_size_t;
|
||||
|
||||
#[link_name = "arduboy_set_cursor"]
|
||||
fn set_cursor(x: i16, y: i16);
|
||||
|
||||
#[link_name = "arduboy_set_frame_rate"]
|
||||
fn set_frame_rate(rate: u8);
|
||||
|
||||
#[link_name = "arduboy_set_text_size"]
|
||||
fn set_text_size(size: u8);
|
||||
|
||||
#[link_name = "arduboy_audio_on"]
|
||||
fn arduboy_audio_on();
|
||||
|
||||
#[link_name = "arduboy_audio_off"]
|
||||
fn arduboy_audio_off();
|
||||
|
||||
#[link_name = "arduboy_audio_save_on_off"]
|
||||
fn arduboy_audio_save_on_off();
|
||||
|
||||
#[link_name = "arduboy_audio_toggle"]
|
||||
fn arduboy_audio_toggle();
|
||||
|
||||
#[link_name = "arduboy_audio_enabled"]
|
||||
fn arduboy_audio_enabled() -> bool;
|
||||
|
||||
#[link_name = "arduboy_invert"]
|
||||
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);
|
||||
|
||||
#[link_name = "arduboy_set_rgb_led_single"]
|
||||
fn set_rgb_led_single(color: c_uchar, val: c_uchar);
|
||||
|
||||
#[link_name = "arduboy_set_rgb_led"]
|
||||
fn set_rgb_led(red: c_uchar, green: c_uchar, blue: c_uchar);
|
||||
|
||||
#[link_name = "arduboy_buttons_state"]
|
||||
fn arduboy_buttons_state() -> u8;
|
||||
|
||||
#[link_name = "arduboy_exit_to_bootloader"]
|
||||
fn arduboy_exit_to_bootloader();
|
||||
}
|
168
arduboy-rust/src/libraries/arduboy2_library/binding.rs
Normal file
168
arduboy-rust/src/libraries/arduboy2_library/binding.rs
Normal file
|
@ -0,0 +1,168 @@
|
|||
use core::ffi::{c_char, c_int, c_long, c_size_t, c_uchar, c_uint, c_ulong};
|
||||
|
||||
extern "C" {
|
||||
#[link_name = "arduboy_begin"]
|
||||
pub fn begin();
|
||||
|
||||
#[link_name = "arduboy_clear"]
|
||||
pub fn clear();
|
||||
|
||||
#[link_name = "arduboy_display"]
|
||||
pub fn display();
|
||||
|
||||
#[link_name = "arduboy_display_and_clear_buffer"]
|
||||
pub fn display_and_clear_buffer();
|
||||
|
||||
#[link_name = "arduboy_draw_fast_hline"]
|
||||
pub fn draw_fast_hline_raw(x: i16, y: i16, w: u8, color: u8);
|
||||
|
||||
#[link_name = "arduboy_draw_fast_vline"]
|
||||
pub fn draw_fast_vline_raw(x: i16, y: i16, h: u8, color: u8);
|
||||
|
||||
#[link_name = "arduboy_draw_pixel"]
|
||||
pub fn draw_pixel_raw(x: i16, y: i16, color: u8);
|
||||
|
||||
#[link_name = "arduboy_draw_circle"]
|
||||
pub fn draw_circle_raw(x: i16, y: i16, r: u8, color: u8);
|
||||
|
||||
#[link_name = "arduboy_draw_rect"]
|
||||
pub fn draw_rect_raw(x: i16, y: i16, w: u8, h: u8, color: u8);
|
||||
|
||||
#[link_name = "arduboy_fill_circle"]
|
||||
pub fn fill_circle_raw(x: i16, y: i16, r: u8, color: u8);
|
||||
|
||||
#[link_name = "arduboy_fill_rect"]
|
||||
pub fn fill_rect_raw(x: i16, y: i16, w: u8, h: u8, color: u8);
|
||||
|
||||
#[link_name = "arduboy_fill_round_rect"]
|
||||
pub fn fill_round_rect(x: i16, y: i16, w: u8, h: u8, r: u8, color: u8);
|
||||
|
||||
#[link_name = "arduboy_draw_round_rect"]
|
||||
pub fn draw_round_rect(x: i16, y: i16, w: u8, h: u8, r: u8, color: u8);
|
||||
|
||||
#[link_name = "arduboy_fill_triangle"]
|
||||
pub fn fill_triangle(x0: i16, y0: i16, x1: i16, y1: i16, x2: i16, y2: i16, color: u8);
|
||||
|
||||
#[link_name = "arduboy_draw_triangle"]
|
||||
pub fn draw_triangle(x0: i16, y0: i16, x1: i16, y1: i16, x2: i16, y2: i16, color: u8);
|
||||
|
||||
#[link_name = "arduboy_get_pixel"]
|
||||
pub fn get_pixel_raw(x: u8, y: u8) -> u8;
|
||||
|
||||
#[link_name = "arduboy_init_random_seed"]
|
||||
pub fn init_random_seed();
|
||||
|
||||
#[link_name = "arduboy_just_pressed"]
|
||||
pub fn just_pressed(button: u8) -> bool;
|
||||
|
||||
#[link_name = "arduboy_just_released"]
|
||||
pub fn just_released(button: u8) -> bool;
|
||||
|
||||
#[link_name = "arduboy_not_pressed"]
|
||||
pub fn not_pressed(button: u8) -> bool;
|
||||
|
||||
#[link_name = "arduboy_next_frame"]
|
||||
pub fn next_frame() -> bool;
|
||||
|
||||
#[link_name = "arduboy_poll_buttons"]
|
||||
pub fn poll_buttons();
|
||||
|
||||
#[link_name = "arduboy_pressed"]
|
||||
pub fn pressed(buttons: u8) -> bool;
|
||||
|
||||
#[link_name = "arduboy_print_chars"]
|
||||
pub fn print_chars(cstr: *const c_char);
|
||||
|
||||
#[link_name = "arduboy_print_chars_progmem"]
|
||||
pub fn print_chars_progmem(pstring: *const c_char);
|
||||
|
||||
// #[link_name = "arduboy_print_char"]
|
||||
// fn print_char(c: c_char) -> c_size_t;
|
||||
|
||||
#[link_name = "arduboy_print_int"]
|
||||
pub fn print_int(n: c_int, base: c_int) -> c_size_t;
|
||||
|
||||
#[link_name = "arduboy_print_long"]
|
||||
pub fn print_long(n: c_long, base: c_int) -> c_size_t;
|
||||
|
||||
#[link_name = "arduboy_print_unsigned_char"]
|
||||
pub fn print_unsigned_char(n: c_uchar, base: c_int) -> c_size_t;
|
||||
|
||||
#[link_name = "arduboy_print_unsigned_int"]
|
||||
pub fn print_unsigned_int(n: c_uint, base: c_int) -> c_size_t;
|
||||
|
||||
#[link_name = "arduboy_print_unsigned_long"]
|
||||
pub fn print_unsigned_long(n: c_ulong, base: c_int) -> c_size_t;
|
||||
|
||||
#[link_name = "arduboy_set_cursor"]
|
||||
pub fn set_cursor(x: i16, y: i16);
|
||||
|
||||
#[link_name = "arduboy_set_frame_rate"]
|
||||
pub fn set_frame_rate(rate: u8);
|
||||
|
||||
#[link_name = "arduboy_set_text_size"]
|
||||
pub fn set_text_size(size: u8);
|
||||
|
||||
#[link_name = "arduboy_audio_on"]
|
||||
pub fn arduboy_audio_on();
|
||||
|
||||
#[link_name = "arduboy_audio_off"]
|
||||
pub fn arduboy_audio_off();
|
||||
|
||||
#[link_name = "arduboy_audio_save_on_off"]
|
||||
pub fn arduboy_audio_save_on_off();
|
||||
|
||||
#[link_name = "arduboy_audio_toggle"]
|
||||
pub fn arduboy_audio_toggle();
|
||||
|
||||
#[link_name = "arduboy_audio_enabled"]
|
||||
pub fn arduboy_audio_enabled() -> bool;
|
||||
|
||||
#[link_name = "arduboy_invert"]
|
||||
pub fn arduboy_invert(inverse: bool);
|
||||
|
||||
#[link_name = "arduboy_every_x_frames"]
|
||||
pub fn every_x_frames(frames: u8) -> bool;
|
||||
|
||||
#[link_name = "arduboy_flip_horizontal"]
|
||||
pub fn flip_horizontal(flipped: bool);
|
||||
|
||||
#[link_name = "arduboy_flip_vertical"]
|
||||
pub fn flip_vertical(flipped: bool);
|
||||
|
||||
#[link_name = "arduboy_set_text_color"]
|
||||
pub fn set_text_color(color: u8);
|
||||
|
||||
#[link_name = "arduboy_set_text_background_color"]
|
||||
pub fn set_text_background_color(color: u8);
|
||||
|
||||
#[link_name = "arduboy_set_cursor_x"]
|
||||
pub fn set_cursor_x(x: i16);
|
||||
|
||||
#[link_name = "arduboy_set_cursor_y"]
|
||||
pub fn set_cursor_y(y: i16);
|
||||
|
||||
#[link_name = "arduboy_set_text_wrap"]
|
||||
pub fn set_text_wrap(w: bool);
|
||||
|
||||
#[link_name = "arduboy_idle"]
|
||||
pub fn idle();
|
||||
|
||||
#[link_name = "arduboy_digital_write_rgb_single"]
|
||||
pub fn digital_write_rgb_single(color: c_uchar, val: c_uchar);
|
||||
|
||||
#[link_name = "arduboy_digital_write_rgb"]
|
||||
pub fn digital_write_rgb(red: c_uchar, green: c_uchar, blue: c_uchar);
|
||||
|
||||
#[link_name = "arduboy_set_rgb_led_single"]
|
||||
pub fn set_rgb_led_single(color: c_uchar, val: c_uchar);
|
||||
|
||||
#[link_name = "arduboy_set_rgb_led"]
|
||||
pub fn set_rgb_led(red: c_uchar, green: c_uchar, blue: c_uchar);
|
||||
|
||||
#[link_name = "arduboy_buttons_state"]
|
||||
pub fn arduboy_buttons_state() -> u8;
|
||||
|
||||
#[link_name = "arduboy_exit_to_bootloader"]
|
||||
pub fn arduboy_exit_to_bootloader();
|
||||
}
|
12
arduboy-rust/src/libraries/arduboy2_library/mod.rs
Normal file
12
arduboy-rust/src/libraries/arduboy2_library/mod.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
//! 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.
|
||||
#[doc(hidden)]
|
||||
pub mod arduboy2;
|
||||
#[doc(hidden)]
|
||||
pub mod binding;
|
||||
#[doc(hidden)]
|
||||
pub mod print;
|
||||
|
||||
pub mod sprites;
|
||||
pub use arduboy2::{Arduboy2, Color, Point, Rect, FONT_HEIGHT, FONT_WIDTH, HEIGHT, WIDTH};
|
|
@ -1,4 +1,4 @@
|
|||
use crate::prelude::Pstring;
|
||||
use crate::arduino_system::progmem::Pstring;
|
||||
use core::ffi::c_int;
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
|
||||
|
@ -28,7 +28,7 @@ impl Printable for i16 {
|
|||
|
||||
fn print_2(self, params: Self::Parameters) {
|
||||
unsafe {
|
||||
crate::library::arduboy2::print_int(self, params as c_int);
|
||||
super::binding::print_int(self, params as c_int);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ impl Printable for u16 {
|
|||
|
||||
fn print_2(self, params: Self::Parameters) {
|
||||
unsafe {
|
||||
crate::library::arduboy2::print_unsigned_int(self, params as c_int);
|
||||
super::binding::print_unsigned_int(self, params as c_int);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ impl Printable for i32 {
|
|||
|
||||
fn print_2(self, params: Self::Parameters) {
|
||||
unsafe {
|
||||
crate::library::arduboy2::print_long(self, params as c_int);
|
||||
super::binding::print_long(self, params as c_int);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ impl Printable for u32 {
|
|||
|
||||
fn print_2(self, params: Self::Parameters) {
|
||||
unsafe {
|
||||
crate::library::arduboy2::print_unsigned_long(self, params as c_int);
|
||||
super::binding::print_unsigned_long(self, params as c_int);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ impl Printable for &[u8] {
|
|||
|
||||
fn print_2(self, _params: Self::Parameters) {
|
||||
unsafe {
|
||||
crate::library::arduboy2::print_chars(self as *const [u8] as *const i8);
|
||||
super::binding::print_chars(self as *const [u8] as *const i8);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ impl Printable for &str {
|
|||
|
||||
fn print_2(self, _params: Self::Parameters) {
|
||||
unsafe {
|
||||
crate::library::arduboy2::print_chars(self.as_bytes() as *const [u8] as *const i8);
|
||||
super::binding::print_chars(self.as_bytes() as *const [u8] as *const i8);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ impl<const N: usize> Printable for crate::heapless::String<N> {
|
|||
|
||||
fn print_2(self, _params: Self::Parameters) {
|
||||
unsafe {
|
||||
crate::library::arduboy2::print_chars(self.as_bytes() as *const [u8] as *const i8);
|
||||
super::binding::print_chars(self.as_bytes() as *const [u8] as *const i8);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ impl Printable for Pstring {
|
|||
|
||||
fn print_2(self, _params: Self::Parameters) {
|
||||
unsafe {
|
||||
crate::library::arduboy2::print_chars_progmem(self.pointer);
|
||||
super::binding::print_chars_progmem(self.pointer);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,9 @@
|
|||
//!This is the Module to interact in a save way with the ArduboyTones C++ library.
|
||||
//!
|
||||
//! You will need to uncomment the ArduboyTones_Library in the import_config.h file.
|
||||
pub mod tones_pitch;
|
||||
|
||||
use core::ffi::{c_uchar, c_uint, c_ulong};
|
||||
|
||||
///This is the struct to interact in a save way with the ArduboyTones C++ library.
|
||||
///
|
||||
/// You will need to uncomment the ArduboyTones_Library in the import_config.h file.
|
||||
|
||||
pub struct ArduboyTones {}
|
||||
impl ArduboyTones {
|
||||
///Get a new instance of [ArduboyTones]
|
||||
|
@ -71,9 +67,9 @@ impl ArduboyTones {
|
|||
/// Example:
|
||||
/// ```
|
||||
/// use arduboy_rust::prelude::*;
|
||||
/// const sound:ArduboyTones=ArduboyTones::new();
|
||||
/// const sound: ArduboyTones = ArduboyTones::new();
|
||||
/// progmem!(
|
||||
/// static sound1:[u8;_]=[220,1000, 0,250, 440,500, 880,2000,TONES_END];
|
||||
/// static sound1: [u8; _] = [220, 1000, 0, 250, 440, 500, 880, 2000, TONES_END];
|
||||
/// );
|
||||
///
|
||||
/// sound.tones(get_tones_addr!(sound1));
|
8
arduboy-rust/src/libraries/arduboy_tones_library/mod.rs
Normal file
8
arduboy-rust/src/libraries/arduboy_tones_library/mod.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
//!This is the Module to interact in a save way with the ArduboyTones C++ library.
|
||||
//!
|
||||
//! You will need to uncomment the ArduboyTones_Library in the import_config.h file.
|
||||
#[doc(hidden)]
|
||||
mod arduboy_tones;
|
||||
pub mod tones_pitch;
|
||||
|
||||
pub use arduboy_tones::ArduboyTones;
|
|
@ -1,5 +1,5 @@
|
|||
use crate::libraries::arduino_system::progmem::Pstring;
|
||||
use core::ffi::{c_char, c_uchar, c_ulong};
|
||||
use crate::library::progmem::Pstring;
|
||||
|
||||
pub trait DrawableString
|
||||
where
|
|
@ -1,9 +1,11 @@
|
|||
//! This is the Module to interact in a save way with the ArduboyFX C++ library.
|
||||
//!
|
||||
//! You will need to uncomment the ArduboyFX_Library in the import_config.h file.
|
||||
pub mod fx_consts;
|
||||
mod drawable_number;
|
||||
pub mod fx_consts;
|
||||
#[doc(hidden)]
|
||||
pub use drawable_number::DrawableNumber;
|
||||
mod drawable_string;
|
||||
#[doc(hidden)]
|
||||
pub use drawable_string::DrawableString;
|
||||
pub mod fx;
|
|
@ -1,3 +1,4 @@
|
|||
//!This is the module to interact with the eeprom memory
|
||||
use core::ffi::{c_int, c_uchar};
|
||||
|
||||
pub const EEPROM_STORAGE_SPACE_START: i16 = 16;
|
7
arduboy-rust/src/libraries/arduino_system/mod.rs
Normal file
7
arduboy-rust/src/libraries/arduino_system/mod.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
//!This module contains all the Arduino system functions to interact with the hardware.
|
||||
|
||||
pub mod arduino;
|
||||
pub mod c;
|
||||
pub mod eeprom;
|
||||
pub mod progmem;
|
||||
pub mod serial_print;
|
|
@ -1,3 +1,4 @@
|
|||
//!This is the module to interact with the progmem memory
|
||||
#![allow(unused_imports)]
|
||||
/// Create a space for Progmem variable
|
||||
/// ## Example
|
|
@ -1,10 +1,10 @@
|
|||
//! This is the Module to interact in a save way with the Arduino Serial C++ library.
|
||||
//!
|
||||
//! You will need to uncomment the Arduino_Serial_Library in the import_config.h file.
|
||||
use crate::prelude::Pstring;
|
||||
use crate::arduino_system::progmem::Pstring;
|
||||
use core::ffi::{c_char, c_int, c_long, c_size_t, c_uchar, c_uint, c_ulong};
|
||||
|
||||
use crate::print::Base;
|
||||
use crate::libraries::arduboy2_library::print::Base;
|
||||
extern "C" {
|
||||
#[link_name = "arduino_serial_begin"]
|
||||
fn serial_begin(serial: c_ulong);
|
5
arduboy-rust/src/libraries/ardvoice_library/mod.rs
Normal file
5
arduboy-rust/src/libraries/ardvoice_library/mod.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
//! This is the Module to interact in a save way with the ArdVoice C++ library.
|
||||
//!
|
||||
//! You will need to uncomment the ArdVoice_Library in the import_config.h file.
|
||||
mod ardvoice;
|
||||
pub use ardvoice::ArdVoice;
|
5
arduboy-rust/src/libraries/mod.rs
Normal file
5
arduboy-rust/src/libraries/mod.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
pub mod arduboy2_library;
|
||||
pub mod arduboy_tones_library;
|
||||
pub mod arduino_system;
|
||||
pub mod arduboyfx_library;
|
||||
pub mod ardvoice_library;
|
|
@ -1,9 +0,0 @@
|
|||
pub mod arduboy2;
|
||||
pub mod arduboy_tones;
|
||||
pub mod arduino;
|
||||
pub mod ardvoice;
|
||||
pub mod c;
|
||||
pub mod eeprom;
|
||||
pub mod progmem;
|
||||
pub mod sprites;
|
||||
pub mod arduboyfx;
|
|
@ -5,23 +5,19 @@
|
|||
//! use arduboy_rust::prelude::*;
|
||||
//! ```
|
||||
#[doc(inline)]
|
||||
pub use crate::hardware::buttons::{self, *};
|
||||
pub use crate::hardware::buttons::*;
|
||||
#[doc(inline)]
|
||||
pub use crate::hardware::led::{self, *};
|
||||
pub use crate::hardware::led::*;
|
||||
pub use crate::heapless::{LinearMap, String, Vec};
|
||||
pub use crate::library::arduboy2::{self, *};
|
||||
pub use crate::library::arduboy_tones::{self, ArduboyTones};
|
||||
pub use crate::library::arduboyfx::{self, fx};
|
||||
pub use crate::library::arduino::*;
|
||||
pub use crate::library::ardvoice::{self, ArdVoice};
|
||||
pub use crate::library::c::*;
|
||||
pub use crate::library::eeprom::{EEPROM, EEPROMBYTE, EEPROMBYTECHECKLESS};
|
||||
#[doc(hidden)]
|
||||
pub use crate::library::progmem::Pstring;
|
||||
pub use crate::library::sprites;
|
||||
pub use crate::print::*;
|
||||
#[doc(inline)]
|
||||
pub use crate::serial_print as serial;
|
||||
pub use crate::libraries::arduboy2_library::*;
|
||||
pub use crate::libraries::arduboy_tones_library::*;
|
||||
pub use crate::libraries::arduboyfx_library::*;
|
||||
pub use crate::libraries::arduino_system::arduino::*;
|
||||
pub use crate::libraries::arduino_system::c::*;
|
||||
pub use crate::libraries::arduino_system::eeprom::*;
|
||||
pub use crate::libraries::arduino_system::progmem::*;
|
||||
pub use crate::libraries::arduino_system::serial_print as serial;
|
||||
pub use crate::libraries::ardvoice_library::ArdVoice;
|
||||
pub use crate::{
|
||||
f, get_ardvoice_tone_addr, get_sprite_addr, get_string_addr, get_tones_addr, progmem,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue