Rust-for-Arduboy/Project/game/src/lib.rs

43 lines
1 KiB
Rust
Raw Normal View History

2023-08-06 18:14:49 +02:00
#![no_std]
#![allow(non_upper_case_globals)]
2023-08-06 18:14:49 +02:00
//Include the Arduboy Library
#[allow(unused_imports)]
use arduboy_rust::prelude::*;
2023-09-18 18:59:50 +02:00
#[allow(dead_code)]
const arduboy: Arduboy2 = Arduboy2::new();
2023-09-20 16:39:36 +02:00
extern "C" {
2023-08-06 18:14:49 +02:00
2023-09-20 16:39:36 +02:00
#[link_name = "arduino_serial_begin"]
fn serial_begin(serial: c_ulong);
// #[link_name = "arduino_serial_println_chars"]
// fn serial_println_chars(cstr: *const c_char);
}
// Progmem data
// dynamic ram variables
2023-08-06 18:14:49 +02:00
// 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:
2023-09-04 09:22:04 +02:00
arduboy.begin();
2023-09-12 18:52:18 +02:00
arduboy.set_frame_rate(30);
arduboy.clear();
2023-09-20 16:39:36 +02:00
serial_begin(9600)
2023-08-06 18:14:49 +02:00
}
2023-08-06 18:14:49 +02:00
// 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:
2023-09-04 09:22:04 +02:00
if !arduboy.next_frame() {
return;
}
2023-09-20 16:39:36 +02:00
serial::print("velo\0");
//serial_println_chars(b"hallo\0" as *const [u8] as *const i8);
2023-09-04 09:22:04 +02:00
arduboy.display();
2023-08-06 18:14:49 +02:00
}