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