This commit is contained in:
JP Stringham
2026-02-10 14:08:21 -05:00
parent cef00d1afd
commit 7a41405a71

View File

@@ -99,7 +99,7 @@ fn main() -> ! {
let mut broadcast_on = false; let mut broadcast_on = false;
let mut current_tune = 108; let mut current_tune = 12;
const MAX_TUNE: u16 = 350u16; const MAX_TUNE: u16 = 350u16;
const MIN_TUNE: u16 = 4u16; const MIN_TUNE: u16 = 4u16;
@@ -130,17 +130,22 @@ fn main() -> ! {
if tick.wrapping_sub(last_gfx_update) > 1_000_000 { if tick.wrapping_sub(last_gfx_update) > 1_000_000 {
gfx_buf.clear(); gfx_buf.clear();
gfx_buf.draw_string(20, 20, "Hello Radio!"); gfx_buf.draw_string(20, 14, "Hello Radio!");
let tuned_freq = 125_000u32 / (current_tune * 2) as u32; let tuned_freq = 125_000u32 / (current_tune * 2) as u32;
let mut tune_str_buf = [0u8; 4]; let mut tune_str_buf = [0u8; 5];
u16_into_str(tuned_freq as u16, &mut tune_str_buf); u16_into_str(tuned_freq as u16, &mut tune_str_buf);
let tune_str = str::from_utf8(&tune_str_buf).unwrap(); let tune_str = str::from_utf8(&tune_str_buf).unwrap();
info!("{}, {}", tune_str, tune_str.len()); info!("{}, {}", tune_str, tune_str.len());
gfx_buf.draw_string(20, 34, tune_str); gfx_buf.draw_string(20, 28, tune_str);
u16_into_str(current_tune, &mut tune_str_buf);
let tune_str = str::from_utf8(&tune_str_buf).unwrap();
gfx_buf.draw_string(64, 28, tune_str);
match broadcast_on { match broadcast_on {
true => gfx_buf.draw_string(20, 48, "ON THE AIR"), true => gfx_buf.draw_string(20, 42, "ON THE AIR"),
false => (), false => (),
} }
@@ -181,9 +186,9 @@ fn main() -> ! {
} }
} }
fn u16_into_str(mut value: u16, str_buf: &mut [u8; 4]) { fn u16_into_str(mut value: u16, str_buf: &mut [u8; 5]) {
for i in 0..4 { for i in 0..5 {
str_buf[3 - i] = b'0' + (value % 10) as u8; str_buf[4 - i] = b'0' + (value % 10) as u8;
value /= 10; value /= 10;
} }
info!("utf8 buf {}", str_buf); info!("utf8 buf {}", str_buf);