diff --git a/Project/game/Cargo.toml b/Project/game/Cargo.toml index b916457..cd122f6 100644 --- a/Project/game/Cargo.toml +++ b/Project/game/Cargo.toml @@ -7,4 +7,5 @@ edition = "2021" crate-type = ["staticlib"] [dependencies] + arduboy-rust = { path = "../../arduboy-rust" } diff --git a/Project/game/src/lib.rs b/Project/game/src/lib.rs index ff15aa6..fb6c97c 100644 --- a/Project/game/src/lib.rs +++ b/Project/game/src/lib.rs @@ -1,6 +1,9 @@ #![no_std] #![allow(non_upper_case_globals)] +#[no_mangle] +pub static ArduboyTones_Library: u8 = 1; + //Include the Arduboy Library #[allow(unused_imports)] use arduboy_rust::prelude::*; diff --git a/Wrapper-Project/src/main.h b/Wrapper-Project/src/main.h index 3d20f74..617c358 100644 --- a/Wrapper-Project/src/main.h +++ b/Wrapper-Project/src/main.h @@ -1,16 +1,6 @@ #pragma once -// Comment out the librarys you dont need. -// This saves memory but be carful if the librarys are not defined -// it will not export the given functions for the rust project. -// -// to save a good amount you can comment out -// the ArduboyTones library if you don't need it. - -#define Arduboy2_Library ; -#define ArduboyTones_Library ; -#define EEPROM_Library ; -#define Arduino_Library ; +#include "../../import_config.h" #if defined(Arduboy2_Library) #include diff --git a/arduboy-rust/src/lib.rs b/arduboy-rust/src/lib.rs index 5e3e9fd..29fbd93 100644 --- a/arduboy-rust/src/lib.rs +++ b/arduboy-rust/src/lib.rs @@ -8,11 +8,20 @@ //! ``` //! use arduboy_rust::prelude::*; //! ``` -//! Inside the Wrapper-Project folder is a folder named src. -//! You can disable C++ libraries in the main.h file. +//! ### Disable C++ libraries +//! Inside the root directory is a file named `import_config.h` +//! +//! You can disable C++ libraries in the `import_config.h` file. //! Just comment the unused library definition out. //! -//! To get an idea, the ArduboyTones Library needs 2-3% of the flash memory. +//! Be careful with disabling libraries because: +//! - The only error you get is something like this if you try to use a function that relies on the library you disabled. +//! ```text +//! game.90c69b91e57f285-cgu.0:(.text.loop+0x290): undefined reference to `sound_tone' +//! ``` +//! - the benefit of disabling will be important in the feature when I add support for the ArduboyG library etc. +//! +//! To get an idea, the ArduboyTones Library needs additional 2-3% of the flash memory. //! //! [Here is the link to the GitHub Repo](https://github.com/zenndev1337/rust-for-arduboy) diff --git a/docs/doc/arduboy_rust/index.html b/docs/doc/arduboy_rust/index.html index 5df0e72..06647ac 100644 --- a/docs/doc/arduboy_rust/index.html +++ b/docs/doc/arduboy_rust/index.html @@ -1,11 +1,21 @@ -arduboy_rust - Rust

Crate arduboy_rust

source ·
Expand description

This is the arduboy_rust crate +arduboy_rust - Rust

Crate arduboy_rust

source ·
Expand description

This is the arduboy_rust crate To get started import the prelude to your project.

Import the module:

use arduboy_rust::prelude::*;
-

Inside the Wrapper-Project folder is a folder named src. -You can disable C++ libraries in the main.h file. +

Disable C++ libraries

+

Inside the root directory is a file named import_config.h

+

You can disable C++ libraries in the import_config.h file. Just comment the unused library definition out.

-

To get an idea, the ArduboyTones Library needs 2-3% of the flash memory.

+

Be careful with disabling libraries because:

+
    +
  • The only error you get is something like this if you try to use a function that relies on the library you disabled.
  • +
+
game.90c69b91e57f285-cgu.0:(.text.loop+0x290): undefined reference to `sound_tone'
+
+
    +
  • the benefit of disabling will be important in the feature when I add support for the ArduboyG library etc.
  • +
+

To get an idea, the ArduboyTones Library needs additional 2-3% of the flash memory.

Here is the link to the GitHub Repo

Modules

  • 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 ArduboyTones C++ library.
  • This is the Module to interact in a save way with the Arduino C++ library.
  • Clib functions you can use on the Arduboy
  • This is the Module to interact in a save way with the Arduboy hardware.
  • This is the important one to use this library effective in your project
  • This is the module to interact in a save way with the Sprites C++ library.

Macros

  • This is the way to go if you want print some random text
  • Create a const raw pointer to a sprite as u8, without creating an intermediate reference.
  • Create a const raw pointer to a [u8;_] that saves text, without creating an intermediate reference.
  • Create a const raw pointer to a sprite as u16, without creating an intermediate reference.
  • Create a space for Progmem variable

Structs

  • 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 ArduboyTones C++ library.
  • This is the struct to store and read structs objects to/from eeprom memory.
  • Use this struct to store and read single bytes to/from eeprom memory.

Enums

  • This item is to chose between Black or White

Constants

  • 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/src/arduboy_rust/lib.rs.html b/docs/doc/src/arduboy_rust/lib.rs.html index 2641be8..19224b0 100644 --- a/docs/doc/src/arduboy_rust/lib.rs.html +++ b/docs/doc/src/arduboy_rust/lib.rs.html @@ -25,6 +25,15 @@ 25 26 27 +28 +29 +30 +31 +32 +33 +34 +35 +36
#![cfg(target_arch = "avr")]
 #![no_std]
 #![feature(c_size_t)]
@@ -35,11 +44,20 @@
 //! ```
 //! use arduboy_rust::prelude::*;
 //! ```
-//! Inside the Wrapper-Project folder is a folder named src.
-//! You can disable C++ libraries in the main.h file.
+//! ### Disable C++ libraries
+//! Inside the root directory is a file named `import_config.h`
+//!
+//! You can disable C++ libraries in the `import_config.h` file.
 //! Just comment the unused library definition out.
 //!
-//! To get an idea, the ArduboyTones Library needs 2-3% of the flash memory.
+//! Be careful with disabling libraries because:
+//! - The only error you get is something like this if you try to use a function that relies on the library you disabled.
+//! ```text
+//! game.90c69b91e57f285-cgu.0:(.text.loop+0x290): undefined reference to `sound_tone'
+//! ```
+//! - the benefit of disabling will be important in the feature when I add support for the ArduboyG library etc.
+//!
+//! To get an idea, the ArduboyTones Library needs additional 2-3% of the flash memory.
 //!
 //! [Here is the link to the GitHub Repo](https://github.com/zenndev1337/rust-for-arduboy)
 
diff --git a/import_config.h b/import_config.h
new file mode 100644
index 0000000..f762514
--- /dev/null
+++ b/import_config.h
@@ -0,0 +1,21 @@
+#pragma once
+
+// #################
+// #    WARNING    #
+// #################
+//
+// ## Read the docs before change here things!! ##
+//
+// https://zenndev1337.github.io/Rust-for-Arduboy/
+//
+// Comment out the librarys you dont need.
+// This saves memory but be carful if the librarys are not defined
+// it will not export the given functions for the rust project.
+//
+// to save a good amount you can comment out
+// the ArduboyTones library if you don't need it.
+
+#define Arduboy2_Library ;
+#define ArduboyTones_Library ;
+#define EEPROM_Library ;
+#define Arduino_Library ;
\ No newline at end of file