more docs and added the import_config.h file to controlle which c++ libraries are added

This commit is contained in:
ZennDev1337 2023-08-16 09:58:14 +02:00
parent c4f43a0f9d
commit fd48cc36c5
7 changed files with 73 additions and 21 deletions

View file

@ -7,4 +7,5 @@ edition = "2021"
crate-type = ["staticlib"] crate-type = ["staticlib"]
[dependencies] [dependencies]
arduboy-rust = { path = "../../arduboy-rust" } arduboy-rust = { path = "../../arduboy-rust" }

View file

@ -1,6 +1,9 @@
#![no_std] #![no_std]
#![allow(non_upper_case_globals)] #![allow(non_upper_case_globals)]
#[no_mangle]
pub static ArduboyTones_Library: u8 = 1;
//Include the Arduboy Library //Include the Arduboy Library
#[allow(unused_imports)] #[allow(unused_imports)]
use arduboy_rust::prelude::*; use arduboy_rust::prelude::*;

View file

@ -1,16 +1,6 @@
#pragma once #pragma once
// Comment out the librarys you dont need. #include "../../import_config.h"
// 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 ;
#if defined(Arduboy2_Library) #if defined(Arduboy2_Library)
#include <Arduboy2.h> #include <Arduboy2.h>

View file

@ -8,11 +8,20 @@
//! ``` //! ```
//! use arduboy_rust::prelude::*; //! use arduboy_rust::prelude::*;
//! ``` //! ```
//! Inside the Wrapper-Project folder is a folder named src. //! ### Disable C++ libraries
//! You can disable C++ libraries in the main.h file. //! 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. //! 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) //! [Here is the link to the GitHub Repo](https://github.com/zenndev1337/rust-for-arduboy)

File diff suppressed because one or more lines are too long

View file

@ -25,6 +25,15 @@
<a href="#25" id="25">25</a> <a href="#25" id="25">25</a>
<a href="#26" id="26">26</a> <a href="#26" id="26">26</a>
<a href="#27" id="27">27</a> <a href="#27" id="27">27</a>
<a href="#28" id="28">28</a>
<a href="#29" id="29">29</a>
<a href="#30" id="30">30</a>
<a href="#31" id="31">31</a>
<a href="#32" id="32">32</a>
<a href="#33" id="33">33</a>
<a href="#34" id="34">34</a>
<a href="#35" id="35">35</a>
<a href="#36" id="36">36</a>
</pre></div><pre class="rust"><code><span class="attr">#![cfg(target_arch = <span class="string">&quot;avr&quot;</span>)] </pre></div><pre class="rust"><code><span class="attr">#![cfg(target_arch = <span class="string">&quot;avr&quot;</span>)]
#![no_std] #![no_std]
#![feature(c_size_t)] #![feature(c_size_t)]
@ -35,11 +44,20 @@
//! ``` //! ```
//! use arduboy_rust::prelude::*; //! use arduboy_rust::prelude::*;
//! ``` //! ```
//! Inside the Wrapper-Project folder is a folder named src. //! ### Disable C++ libraries
//! You can disable C++ libraries in the main.h file. //! 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. //! 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&#39;
//! ```
//! - 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) //! [Here is the link to the GitHub Repo](https://github.com/zenndev1337/rust-for-arduboy)

21
import_config.h Normal file
View file

@ -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 ;