Compare commits

..

3 Commits

Author SHA1 Message Date
JP Stringham
e06f84df2f merge 2026-02-10 14:10:07 -05:00
JP Stringham
85a8c6b164 Merge branch 'main' of ssh://simcoesibtea.supersaturn.space:3002/jp/pico-radio 2026-02-10 14:09:52 -05:00
JP Stringham
7a41405a71 oops 2026-02-10 14:08:21 -05:00
2 changed files with 15 additions and 10 deletions

View File

@@ -28,11 +28,11 @@ rustflags = [
# This runner will make a UF2 file and then copy it to a mounted RP2040 in USB # This runner will make a UF2 file and then copy it to a mounted RP2040 in USB
# Bootloader mode: # Bootloader mode:
runner = "elf2uf2-rs -d" # runner = "elf2uf2-rs -d"
# This runner will find a supported SWD debug probe and flash your RP2040 over # This runner will find a supported SWD debug probe and flash your RP2040 over
# SWD: # SWD:
# runner = "probe-rs run --chip RP2040 --protocol swd" runner = "probe-rs run --chip RP2040 --protocol swd"
[env] [env]
DEFMT_RTT_BUFFER_SIZE = { value = "4096", force = true } DEFMT_RTT_BUFFER_SIZE = { value = "4096", force = true }

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 => gfx_buf.draw_string(20, 48, "Offline"), false => gfx_buf.draw_string(20, 48, "Offline"),
} }
@@ -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);