diff --git a/src/platform/esp32.rs b/src/platform/esp32.rs index f1e3e7b..b2a551c 100644 --- a/src/platform/esp32.rs +++ b/src/platform/esp32.rs @@ -103,6 +103,14 @@ impl Board for Esp32Board { type Output = StrideOutput<[Rgb; 310], FastWs2812Esp32Rmt<'static>>; type Surfaces = BufferedSurfacePool; type Scheduler = FixedSizeScheduler<4>; + + fn chip_id() -> u64 { + let mut chip_id: [u8; 8] = [0; 8]; + unsafe { + esp_efuse_mac_get_default(&mut chip_id as *mut u8); + } + return u64::from_be_bytes(chip_id); + } fn take() -> Self { // It is necessary to call this function once. Otherwise some patches to the runtime @@ -120,7 +128,7 @@ impl Board for Esp32Board { esp_efuse_mac_get_default(&mut chip_id as *mut u8); } - log::info!("Setting up output for chip ID {:x?}", chip_id); + log::info!("Setting up output for chip ID {:x?}", Self::chip_id()); const POWER_VOLTS : u32 = 5; const POWER_MA : u32 = 500; @@ -135,7 +143,7 @@ impl Board for Esp32Board { // But the implementation spawns a thread based on the core the driver was created in, // so we create the driver in another thread briefly. // Fun stuff. - let output = match chip_id { // panel test board + let output = match Self::chip_id().to_be_bytes() { // panel test board [72, 202, 67, 89, 145, 204, 0, 0] => { StrideOutput::new( Pixbuf::new(), diff --git a/src/platform/mod.rs b/src/platform/mod.rs index f970bab..af2413b 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -20,4 +20,5 @@ pub trait Board { fn output(&mut self) -> Self::Output; fn surfaces(&mut self) -> Self::Surfaces; fn system_tasks(&mut self) -> Self::Scheduler; + fn chip_id() -> u64; } \ No newline at end of file