Skip to content

Commit

Permalink
debugging stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
gferraro committed Dec 11, 2024
1 parent e2b8a5d commit fa2764b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/device_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl DeviceConfigInner {
}

pub struct DeviceConfig {
config_inner: DeviceConfigInner,
pub config_inner: DeviceConfigInner,
pub motion_detection_mask: DetectionMask,
pub cursor_position: usize,
}
Expand Down
64 changes: 61 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,70 @@ impl FrameBuffer {
[segment_offset + packet_offset..segment_offset + packet_offset + FRAME_WIDTH]
}
}
use crate::byte_slice_cursor::Cursor;
use crate::rp2040_flash::read_device_config_from_rp2040_flash;
use embedded_io::Read;

#[entry]
fn main() -> ! {
info!("Startup tc2-firmware {}", FIRMWARE_VERSION);
// TODO: Check wake_en and sleep_en registers to make sure we're not enabling any clocks we don't need.
let mut peripherals: Peripherals = Peripherals::take().unwrap();
let config = DeviceConfig::load_existing_inner_config_from_flash();

//this uses 5Kib
let config = DeviceConfig::load_existing_config_from_flash();
let config = config.unwrap();
loop {
info!(
"Extra used is config is {} mask {}",
config.config(),
config.motion_detection_mask
);
nop();
}

//this also use 5kib
let slice = read_device_config_from_rp2040_flash();
let inner = DeviceConfig::inner_from_bytes(slice);

// if inner.is_none() {
// // Device config is uninitialised in flash
// return None;
// }
let (inner, mut cursor_pos) = inner.unwrap();
// let mask_length = cursor.read_i32();
let mut cursor = Cursor::new(slice);
cursor.set_position(cursor_pos);
let mut motion_detection_mask;
motion_detection_mask = DetectionMask::new(Some([0u8; 2400]));

//thius line is what uses extra 2.46Kib
let len = cursor.read(&mut motion_detection_mask.inner).unwrap();

if len != motion_detection_mask.inner.len() {
// This payload came without the mask attached (i.e. from the rPi)
motion_detection_mask.set_empty();
} else {
cursor_pos = cursor.position();
}

let config = Some(DeviceConfig {
config_inner: inner,
motion_detection_mask,
cursor_position: cursor_pos,
});
let config = config.unwrap();
loop {
info!(
"Extra used is config is {} mask {}",
config.config(),
config.motion_detection_mask
);
nop();
}

//this uses 2.48KIB
let config: Option<(device_config::DeviceConfigInner, usize)> =
DeviceConfig::load_existing_inner_config_from_flash();
let mask = DetectionMask::new(Some([0u8; 2400]));

if config.is_none() {
Expand All @@ -139,6 +196,7 @@ fn main() -> ! {
);
nop();
}

let mut is_audio = false;
// let mut is_audio: bool = config.is_some() && config.as_mut().unwrap().0.is_audio_device();
let (clocks, rosc) = clock_utils::setup_rosc_as_system_clock(
Expand Down Expand Up @@ -461,7 +519,7 @@ pub fn thermal_code(
lepton_firmware_version,
alarm_woke_us,
timer,
config,
// config,
)
},
);
Expand Down

0 comments on commit fa2764b

Please sign in to comment.