added ArduboyFx begin drawBitmap and display to the crate also added a fxdata-converter.html file to the docs

This commit is contained in:
ZennDev1337 2023-10-03 08:50:48 +02:00
parent 9248c9f2ac
commit ddf419f702
10 changed files with 3218 additions and 2682 deletions

View file

@ -2,6 +2,7 @@
#![allow(non_upper_case_globals)]
//Include the Arduboy Library
use arduboy_rust::arduboyfx::*;
#[allow(unused_imports)]
use arduboy_rust::prelude::*;
@ -11,14 +12,23 @@ const arduboy: Arduboy2 = Arduboy2::new();
// Progmem data
// dynamic ram variables
const FX_DATA_PAGE: u16 = 0xffff;
const FX_DATA_BYTES: u32 = 234;
const FXlogo: u32 = 0x000000;
const FXlogoWith: i16 = 115;
const FXlogoHeight: i16 = 16;
static mut x: i16 = (WIDTH - FXlogoWith) / 2;
static mut y: i16 = 25;
static mut xDir: i8 = 1;
static mut yDir: i8 = 1;
// 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();
arduboy.set_frame_rate(30);
arduboy.clear();
arduboyfx_begin_data(FX_DATA_PAGE);
}
// The loop() function repeats forever after setup() is done
#[no_mangle]
@ -28,5 +38,14 @@ pub unsafe extern "C" fn loop_() {
if !arduboy.next_frame() {
return;
}
arduboy.display();
arduboyfx_draw_bitmap(x, y, FXlogo, 0, 0);
x += xDir as i16;
y += yDir as i16;
if x == 0 || x == WIDTH - FXlogoWith {
xDir = -xDir;
}
if y == 0 || y == HEIGHT - FXlogoHeight {
yDir = -yDir;
}
arduboyfx_display_clear();
}