first commit

This commit is contained in:
Zenn 2023-08-06 18:14:49 +02:00
commit c591b2c272
50 changed files with 2650 additions and 0 deletions

View file

@ -0,0 +1,12 @@
[package]
name = "eeprom-demo"
version = "0.1.0"
authors = ["ZennDev <zenndev@protonmail.com>"]
license = "MIT OR Apache-2.0"
edition = "2021"
[lib]
crate-type = ["staticlib"]
[dependencies]
arduboy-rust = "1.0.0"

View file

@ -0,0 +1,59 @@
#![no_std]
#![allow(non_upper_case_globals)]
//Include the Arduboy Library
//Initialize the arduboy object
#[allow(unused_imports)]
use arduboy_rust::prelude::*;
// #[link_section = ".progmem.data"]
// Setup eeprom memory
static mut eeprom: EEPROM = EEPROM::new(10);
static mut count: u8 = 0;
static mut MEM: u8 = 0;
// The setup() function runs once when you turn your Arduboy on
#[no_mangle]
pub unsafe extern "C" fn setup() {
// put your setup code here, to run once:
arduboy.begin();
eeprom.init();
arduboy.clear();
arduboy.set_frame_rate(30);
}
// The loop() function repeats forever after setup() is done
#[no_mangle]
#[export_name = "loop"]
pub unsafe extern "C" fn loop_() {
// put your main code here, to run repeatedly:
if !arduboy.next_frame() {
return;
}
arduboy.clear();
arduboy.poll_buttons();
if arduboy.just_pressed(UP) {
count += 1;
}
if arduboy.just_pressed(DOWN) {
count -= 1;
}
if arduboy.just_pressed(A) {
unsafe { eeprom.put(count) }
}
if arduboy.just_pressed(B) {
eeprom.get(&mut MEM)
}
arduboy.set_cursor(0, 0);
arduboy.print(count as u16);
arduboy.set_cursor(0, 30);
arduboy.print("Memory:\0");
arduboy.print(MEM as u16);
arduboy.set_cursor(0, 40);
arduboy.print("eeprom:\0");
arduboy.print(eeprom.read() as u16);
arduboy.display();
}