prepare Outputs type

This commit is contained in:
2026-08-23 10:54:21 +02:00
parent 38e1617bdd
commit 889da2e62c
8 changed files with 56 additions and 32 deletions
+26 -18
View File
@@ -11,10 +11,11 @@ use alloc::boxed::Box;
use creaturedex::card::decoder::split_nfc_hex;
use creaturedex::card::model::Card;
use creaturedex::display::shared_bus::{DualSecondaryDisplay, init_dual_displays};
use creaturedex::display::tertiary_lcd::{init_tertiary_lcd, write_wrapped};
use creaturedex::display::tertiary_lcd::{TertiaryI2cLcd, init_tertiary_lcd, write_wrapped};
use creaturedex::drivers::nfc_pn532::NfcPn532Driver;
use creaturedex::navigation::inputs::Inputs;
use creaturedex::navigation::navigation::{self, CARD_DATA};
use creaturedex::navigation::outputs::Outputs;
use creaturedex::network::wifi::setup_wifi;
use embassy_executor::Spawner;
use embassy_time::Instant;
@@ -65,7 +66,7 @@ async fn main(spawner: Spawner) {
let timg0 = TimerGroup::new(peripherals.TIMG0);
esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0);
let (display, oled) = Box::leak(Box::new(init_dual_displays(
let (display, mut oled) = init_dual_displays(
peripherals.SPI2,
peripherals.GPIO36, // sck
peripherals.GPIO35, // mosi
@@ -75,18 +76,12 @@ async fn main(spawner: Spawner) {
peripherals.GPIO10, // primary reset
peripherals.GPIO47, // secondary reset
peripherals.GPIO12, // shared dc
)));
);
let _secondary_oled_cs_2 = Output::new(
peripherals.GPIO14,
Level::High,
OutputConfig::default(),
);
let _secondary_oled_cs_3 = Output::new(
peripherals.GPIO21,
Level::High,
OutputConfig::default(),
);
let _secondary_oled_cs_2 =
Output::new(peripherals.GPIO14, Level::High, OutputConfig::default());
let _secondary_oled_cs_3 =
Output::new(peripherals.GPIO21, Level::High, OutputConfig::default());
let config = I2cConfig::default().with_frequency(esp_hal::time::Rate::from_khz(400));
let i2c = match I2c::new(peripherals.I2C0, config) {
@@ -101,10 +96,10 @@ async fn main(spawner: Spawner) {
let shared_i2c = Box::leak(Box::new(AtomicCell::new(i2c)));
log::info!("Shared I2C bus ready on GPIO17 (SDA) and GPIO18 (SCL)");
let mut lcd = init_tertiary_lcd(AtomicDevice::new(shared_i2c));
if let Err(_) = write_wrapped(&mut lcd, "Testing more than 16 chars what happens now?") {
let mut lcd: TertiaryI2cLcd = init_tertiary_lcd(AtomicDevice::new(shared_i2c));
if let Err(e) = write_wrapped(&mut lcd, "Testing more than 16 chars what happens now?") {
log::error!(
"Tertiary LCD startup text write failed over shared I2C bus; check the shared bus, wiring, and device responses"
"Tertiary LCD startup text write failed over shared I2C bus; check the shared bus, wiring, and device responses: {e}"
);
}
@@ -127,14 +122,27 @@ async fn main(spawner: Spawner) {
ok: Input::new(peripherals.GPIO0, button_config),
};
display_shit(oled);
display_shit(&mut oled);
let outputs = Outputs {
primary_display: display,
secondary_display_1: oled,
// secondary_display_2: todo!(),
// secondary_display_3: todo!(),
tertiary_display: lcd,
_led_a: (),
};
log::info!("Setup complete, entering main loop");
spawner.spawn(navigation::run(inputs, display).expect("run task failed"));
spawner.spawn(navigation::run(inputs, outputs).expect("run task failed"));
spawner.spawn(nfc_driver_task(nfc_driver).expect("nfc driver task failed"));
}
#[embassy_executor::task]
#[allow(
clippy::large_stack_frames,
reason = "ignoring this for now because it still works"
)]
async fn nfc_driver_task(
mut nfc_driver: NfcPn532Driver<AtomicDevice<'static, I2c<'static, Blocking>>>,
) {