added support for printing out of progmem
This commit is contained in:
parent
25e7d3272c
commit
5fdfcf88c4
10 changed files with 157 additions and 4 deletions
|
@ -6,7 +6,7 @@ mod hardware;
|
|||
mod library;
|
||||
pub mod prelude;
|
||||
mod print;
|
||||
pub use crate::library::arduboy::{Arduboy, Color, FONT_SIZE, HEIGHT, WIDTH};
|
||||
pub use crate::library::arduboy::{Arduboy, Color, Pstring, FONT_SIZE, HEIGHT, WIDTH};
|
||||
pub use crate::library::arduboy_tone::Sound;
|
||||
pub use crate::library::eeprom::EEPROM;
|
||||
pub use crate::library::{arduboy_tone_pitch, c, sprites};
|
||||
|
|
|
@ -20,6 +20,11 @@ pub const WIDTH: u8 = 128;
|
|||
///
|
||||
/// this is to calculate with it.
|
||||
pub const HEIGHT: u8 = 64;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Pstring {
|
||||
pub pointer: *const i8,
|
||||
}
|
||||
/// This item is to chose between Black or White
|
||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
|
||||
#[repr(u8)]
|
||||
|
@ -411,6 +416,9 @@ extern "C" {
|
|||
#[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;
|
||||
|
||||
|
|
|
@ -12,14 +12,14 @@ pub const arduboy: Arduboy = Arduboy {};
|
|||
#[allow(non_upper_case_globals)]
|
||||
pub const sound: Sound = Sound {};
|
||||
pub use crate::hardware::buttons::*;
|
||||
pub use crate::library::arduboy::{Color, Point, Rect, FONT_SIZE, HEIGHT, WIDTH};
|
||||
pub use crate::library::arduboy::{Color, Point, Pstring, Rect, FONT_SIZE, HEIGHT, WIDTH};
|
||||
pub use crate::library::arduboy_tone::*;
|
||||
pub use crate::library::arduino::*;
|
||||
pub use crate::library::c::*;
|
||||
pub use crate::library::eeprom::EEPROM;
|
||||
pub use crate::library::sprites;
|
||||
pub use crate::print::*;
|
||||
pub use crate::{get_sprite_addr, get_tones_addr};
|
||||
pub use crate::{get_sprite_addr, get_string_addr, get_tones_addr};
|
||||
use core::cmp;
|
||||
|
||||
pub fn constrain<T: Ord>(x: T, a: T, b: T) -> T {
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
use core::ffi::c_int;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! get_string_addr {
|
||||
( $s:expr ) => {
|
||||
Pstring {
|
||||
pointer: addr_of!($s) as *const i8,
|
||||
}
|
||||
};
|
||||
}
|
||||
#[allow(unused_imports)]
|
||||
pub(super) use get_string_addr;
|
||||
|
||||
use crate::Pstring;
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
|
||||
pub enum Base {
|
||||
Bin = 2,
|
||||
|
@ -101,3 +114,15 @@ impl Printable for &str {
|
|||
|
||||
fn default_parameters() -> Self::Parameters {}
|
||||
}
|
||||
|
||||
impl Printable for Pstring {
|
||||
type Parameters = ();
|
||||
|
||||
fn print_2(self, _params: Self::Parameters) {
|
||||
unsafe {
|
||||
crate::library::arduboy::print_chars_progmem(self.pointer);
|
||||
}
|
||||
}
|
||||
|
||||
fn default_parameters() -> Self::Parameters {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue