A personal rust firmware for the Badger 2040 W

good enough for now

Changed files
+10 -4
src
badge_display
+10 -4
src/badge_display/mod.rs
··· 23 use gpio::Output; 24 use heapless::String; 25 use tinybmp::Bmp; 26 - use uc8151::asynch::Uc8151; 27 use uc8151::LUT; 28 use uc8151::WIDTH; 29 use {defmt_rtt as _, panic_probe as _}; 30 31 use crate::Spi0Bus; ··· 86 let mut cycles_since_last_clear = 0; 87 88 loop { 89 if cycles_since_last_clear >= cycles_to_skip || first_run { 90 let count = WIFI_COUNT.load(core::sync::atomic::Ordering::Relaxed); 91 let _ = core::fmt::write(&mut text, format_args!("Count: {}", count)); ··· 117 } 118 text.clear(); 119 // let _ = display.clear(Rgb565::WHITE.into()); 120 - let _ = display.update().await; 121 WIFI_COUNT.store(count + 1, core::sync::atomic::Ordering::Relaxed); 122 cycles_since_last_clear = 0; 123 } ··· 127 let tga: Bmp<BinaryColor> = Bmp::from_slice(&current_image.image()).unwrap(); 128 let image = Image::new(&tga, current_image.image_location()); 129 //clear image location by writing a white rectangle over previous image location 130 - let clear_bounds = Rectangle::new( 131 current_image.previous().image_location(), 132 Size::new(157, 101), 133 ); 134 - clear_bounds 135 .into_styled(PrimitiveStyle::with_fill(BinaryColor::On)) 136 .draw(&mut display) 137 .unwrap(); 138 139 let _ = image.draw(&mut display); 140 let _ = display.update().await; 141 CHANGE_IMAGE.store(false, core::sync::atomic::Ordering::Relaxed); 142 }
··· 23 use gpio::Output; 24 use heapless::String; 25 use tinybmp::Bmp; 26 use uc8151::LUT; 27 use uc8151::WIDTH; 28 + use uc8151::{asynch::Uc8151, UpdateRegion}; 29 use {defmt_rtt as _, panic_probe as _}; 30 31 use crate::Spi0Bus; ··· 86 let mut cycles_since_last_clear = 0; 87 88 loop { 89 + //TODO do the clock here need to 90 + //1. Find the right time for counting 91 if cycles_since_last_clear >= cycles_to_skip || first_run { 92 let count = WIFI_COUNT.load(core::sync::atomic::Ordering::Relaxed); 93 let _ = core::fmt::write(&mut text, format_args!("Count: {}", count)); ··· 119 } 120 text.clear(); 121 // let _ = display.clear(Rgb565::WHITE.into()); 122 + // let _ = display.update().await; 123 WIFI_COUNT.store(count + 1, core::sync::atomic::Ordering::Relaxed); 124 cycles_since_last_clear = 0; 125 } ··· 129 let tga: Bmp<BinaryColor> = Bmp::from_slice(&current_image.image()).unwrap(); 130 let image = Image::new(&tga, current_image.image_location()); 131 //clear image location by writing a white rectangle over previous image location 132 + let image_bounds = Size::new(160, 140); 133 + let clear_rectangle = Rectangle::new( 134 current_image.previous().image_location(), 135 Size::new(157, 101), 136 ); 137 + clear_rectangle 138 .into_styled(PrimitiveStyle::with_fill(BinaryColor::On)) 139 .draw(&mut display) 140 .unwrap(); 141 142 let _ = image.draw(&mut display); 143 + //TODO need to look up the reginal area display 144 + // let update_region = UpdateRegion::new(192, 32, 160, 144).unwrap(); 145 + // let result = display.partial_update(update_region).await; 146 let _ = display.update().await; 147 CHANGE_IMAGE.store(false, core::sync::atomic::Ordering::Relaxed); 148 }