From 22878699456eda0a0cc981224010ac3de5a72383 Mon Sep 17 00:00:00 2001 From: ZennCode Date: Tue, 8 Aug 2023 08:36:49 +0200 Subject: [PATCH] update of the docs and readme --- README.md | 6 +++++- arduboy-rust/src/library/arduboy.rs | 26 +++++++++++++++----------- arduboy-rust/src/library/progmem.rs | 9 +++++++++ arduboy-rust/src/prelude.rs | 6 ++++-- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b27f108..fce3024 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,11 @@ Your game is located in the Project/game folder. This is also the folder you are Inside the game folder you will find a lib.rs file which contains the setup and loop function as you know it from a normal Arduboy C project. -You can use the following command to open the Rust doc of the arduboy_rust crate +You can find the Docs here: + +- [arduboy-rust Crate Docs](https://zenndev1337.github.io/Rust-for-Arduboy-Docs/arduboy_rust/index.html) + +or you can use the following command to open the arduboy-rust Crate docs locally ```bash cargo doc -p arduboy-rust --open diff --git a/arduboy-rust/src/library/arduboy.rs b/arduboy-rust/src/library/arduboy.rs index 9189743..209e1cc 100644 --- a/arduboy-rust/src/library/arduboy.rs +++ b/arduboy-rust/src/library/arduboy.rs @@ -20,11 +20,7 @@ pub const WIDTH: u8 = 128; /// /// this is to calculate with it. pub const HEIGHT: u8 = 64; -#[doc(hidden)] -#[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)] @@ -44,15 +40,23 @@ impl Not for Color { } } } +/// This struct is used by a few Arduboy functions. pub struct Rect { - x: i16, - y: i16, - width: u8, - height: u8, + /// Position X + pub x: i16, + /// Position Y + pub y: i16, + /// Rect width + pub width: u8, + /// Rect height + pub height: u8, } +/// This struct is used by a few Arduboy functions. pub struct Point { - x: i16, - y: i16, + /// Position X + pub x: i16, + /// Position Y + pub y: i16, } /// This is the struct to interact in a save way with the Arduboy2 C++ library. diff --git a/arduboy-rust/src/library/progmem.rs b/arduboy-rust/src/library/progmem.rs index fffa54b..800294c 100644 --- a/arduboy-rust/src/library/progmem.rs +++ b/arduboy-rust/src/library/progmem.rs @@ -82,3 +82,12 @@ macro_rules! f { }}; } pub(super) use f; + +/// This struct is important for the Progmem functionality. +/// +/// Typically you will never use this by your self. +/// It will be used by the get_string_addr macro in combination with a print command. +#[derive(Copy, Clone)] +pub struct Pstring { + pub pointer: *const i8, +} diff --git a/arduboy-rust/src/prelude.rs b/arduboy-rust/src/prelude.rs index a39b12a..086ecb9 100644 --- a/arduboy-rust/src/prelude.rs +++ b/arduboy-rust/src/prelude.rs @@ -1,9 +1,10 @@ -//! This is the imported 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)] @@ -12,11 +13,12 @@ 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, Pstring, Rect, FONT_SIZE, HEIGHT, WIDTH}; +pub use crate::library::arduboy::{Color, Point, 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::progmem::Pstring; pub use crate::library::sprites; pub use crate::print::*; pub use crate::{f, get_sprite_addr, get_string_addr, get_tones_addr, progmem};