Compare commits
3
Commits
8770490949
...
ce661a4bde
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce661a4bde
|
||
|
|
beb972e0d1
|
||
|
|
f59ee96cbc
|
+16
-20
@@ -7,13 +7,13 @@
|
|||||||
)]
|
)]
|
||||||
#![deny(clippy::large_stack_frames)]
|
#![deny(clippy::large_stack_frames)]
|
||||||
|
|
||||||
use alloc::boxed::Box;
|
|
||||||
use creaturedex::card::decoder::split_nfc_hex;
|
use creaturedex::card::decoder::split_nfc_hex;
|
||||||
use creaturedex::card::model::Card;
|
use creaturedex::card::model::Card;
|
||||||
use creaturedex::display::secondary_oled::DualSecondaryDisplay;
|
use creaturedex::drivers::i2c_bus::I2cBusPinConfiguration;
|
||||||
use creaturedex::display::shared_bus;
|
|
||||||
use creaturedex::display::tertiary_lcd::{TertiaryI2cLcd, init_tertiary_lcd, write_wrapped};
|
|
||||||
use creaturedex::drivers::nfc_pn532::NfcPn532Driver;
|
use creaturedex::drivers::nfc_pn532::NfcPn532Driver;
|
||||||
|
use creaturedex::drivers::secondary_oled::SecondaryDisplay;
|
||||||
|
use creaturedex::drivers::spi_bus;
|
||||||
|
use creaturedex::drivers::tertiary_lcd::{TertiaryDisplay, init_tertiary_lcd, write_wrapped};
|
||||||
use creaturedex::navigation::inputs::Inputs;
|
use creaturedex::navigation::inputs::Inputs;
|
||||||
use creaturedex::navigation::navigation::{self, CARD_DATA};
|
use creaturedex::navigation::navigation::{self, CARD_DATA};
|
||||||
use creaturedex::navigation::outputs::Outputs;
|
use creaturedex::navigation::outputs::Outputs;
|
||||||
@@ -27,11 +27,10 @@ use embedded_graphics::{
|
|||||||
text::Text,
|
text::Text,
|
||||||
};
|
};
|
||||||
use embedded_hal_bus::i2c::AtomicDevice;
|
use embedded_hal_bus::i2c::AtomicDevice;
|
||||||
use embedded_hal_bus::util::AtomicCell;
|
|
||||||
use esp_hal::Blocking;
|
use esp_hal::Blocking;
|
||||||
use esp_hal::clock::CpuClock;
|
use esp_hal::clock::CpuClock;
|
||||||
use esp_hal::gpio::{Input, InputConfig, Pull};
|
use esp_hal::gpio::{Input, InputConfig, Pull};
|
||||||
use esp_hal::i2c::master::{Config as I2cConfig, I2c};
|
use esp_hal::i2c::master::I2c;
|
||||||
use esp_hal::timer::timg::TimerGroup;
|
use esp_hal::timer::timg::TimerGroup;
|
||||||
use log::error;
|
use log::error;
|
||||||
|
|
||||||
@@ -67,7 +66,7 @@ async fn main(spawner: Spawner) {
|
|||||||
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||||
esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0);
|
esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0);
|
||||||
|
|
||||||
let (primary, mut secondaries) = shared_bus::DisplayPinConfiguration {
|
let (primary, mut secondaries) = spi_bus::DisplayPinConfiguration {
|
||||||
spi_peripheral: peripherals.SPI2,
|
spi_peripheral: peripherals.SPI2,
|
||||||
sck: peripherals.GPIO36,
|
sck: peripherals.GPIO36,
|
||||||
mosi: peripherals.GPIO35,
|
mosi: peripherals.GPIO35,
|
||||||
@@ -82,20 +81,17 @@ async fn main(spawner: Spawner) {
|
|||||||
}
|
}
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let config = I2cConfig::default().with_frequency(esp_hal::time::Rate::from_khz(400));
|
// Initialize the shared I2C bus using the refactored i2c_bus module.
|
||||||
let i2c = match I2c::new(peripherals.I2C0, config) {
|
let shared_i2c = {
|
||||||
Ok(bus) => bus
|
let config = I2cBusPinConfiguration {
|
||||||
.with_sda(peripherals.GPIO17)
|
i2c_peripheral: peripherals.I2C0,
|
||||||
.with_scl(peripherals.GPIO18),
|
scl: peripherals.GPIO18,
|
||||||
Err(e) => {
|
sda: peripherals.GPIO17,
|
||||||
log::error!("Shared I2C bus initialization failed for GPIO17/GPIO18: {e:?}");
|
};
|
||||||
panic!("Shared I2C bus initialization failed");
|
config.build()
|
||||||
}
|
|
||||||
};
|
};
|
||||||
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: TertiaryI2cLcd = init_tertiary_lcd(AtomicDevice::new(shared_i2c));
|
let mut lcd: TertiaryDisplay = init_tertiary_lcd(AtomicDevice::new(shared_i2c));
|
||||||
if let Err(e) = write_wrapped(&mut lcd, "Testing more than 16 chars what happens now?") {
|
if let Err(e) = write_wrapped(&mut lcd, "Testing more than 16 chars what happens now?") {
|
||||||
log::error!(
|
log::error!(
|
||||||
"Tertiary LCD startup text write failed over shared I2C bus; check the shared bus, wiring, and device responses: {e}"
|
"Tertiary LCD startup text write failed over shared I2C bus; check the shared bus, wiring, and device responses: {e}"
|
||||||
@@ -179,7 +175,7 @@ async fn nfc_driver_task(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_shit(oled: &mut DualSecondaryDisplay<'static>, text: &str) {
|
fn display_shit(oled: &mut SecondaryDisplay<'static>, text: &str) {
|
||||||
oled.clear().unwrap();
|
oled.clear().unwrap();
|
||||||
|
|
||||||
let text_style = MonoTextStyle::new(&FONT_6X10, BinaryColor::On);
|
let text_style = MonoTextStyle::new(&FONT_6X10, BinaryColor::On);
|
||||||
|
|||||||
@@ -1,5 +1 @@
|
|||||||
pub mod primary_lcd;
|
|
||||||
pub mod secondary_oled;
|
|
||||||
pub mod shared_bus;
|
|
||||||
pub mod sprite;
|
pub mod sprite;
|
||||||
pub mod tertiary_lcd;
|
|
||||||
|
|||||||
@@ -1 +1,6 @@
|
|||||||
|
pub mod i2c_bus;
|
||||||
pub mod nfc_pn532;
|
pub mod nfc_pn532;
|
||||||
|
pub mod primary_lcd;
|
||||||
|
pub mod secondary_oled;
|
||||||
|
pub mod spi_bus;
|
||||||
|
pub mod tertiary_lcd;
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
use alloc::boxed::Box;
|
||||||
|
use embedded_hal_bus::util::AtomicCell;
|
||||||
|
use esp_hal::gpio::interconnect::PeripheralInput;
|
||||||
|
use esp_hal::i2c::master::Config;
|
||||||
|
use esp_hal::{gpio::interconnect::PeripheralOutput, i2c::master::I2c};
|
||||||
|
|
||||||
|
type InnerI2cBus = esp_hal::i2c::master::I2c<'static, esp_hal::Blocking>;
|
||||||
|
pub type I2cBus = &'static AtomicCell<InnerI2cBus>;
|
||||||
|
|
||||||
|
pub struct I2cBusPinConfiguration<I2C, SCL, SDA> {
|
||||||
|
pub i2c_peripheral: I2C,
|
||||||
|
pub scl: SCL,
|
||||||
|
pub sda: SDA,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<I2C, SCL, SDA> I2cBusPinConfiguration<I2C, SCL, SDA>
|
||||||
|
where
|
||||||
|
I2C: esp_hal::i2c::master::Instance + 'static,
|
||||||
|
SCL: PeripheralOutput<'static> + PeripheralInput<'static>,
|
||||||
|
SDA: PeripheralOutput<'static> + PeripheralInput<'static>,
|
||||||
|
{
|
||||||
|
pub fn build(self) -> I2cBus {
|
||||||
|
let config = Config::default().with_frequency(esp_hal::time::Rate::from_khz(400));
|
||||||
|
let i2c = match I2c::new(self.i2c_peripheral, config) {
|
||||||
|
Ok(bus) => bus.with_sda(self.sda).with_scl(self.scl),
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("Shared I2C bus initialization failed for GPIO17/GPIO18: {e:?}");
|
||||||
|
panic!("Shared I2C bus initialization failed");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let shared_i2c = Box::leak(Box::new(AtomicCell::new(i2c)));
|
||||||
|
log::info!("Shared I2C bus ready on GPIO17 (SDA) and GPIO18 (SCL)");
|
||||||
|
|
||||||
|
shared_i2c
|
||||||
|
}
|
||||||
|
}
|
||||||
+63
-20
@@ -1,4 +1,5 @@
|
|||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
use core::error::Error;
|
||||||
use embedded_hal::i2c::I2c;
|
use embedded_hal::i2c::I2c;
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use pn532::i2c::I2CInterface;
|
use pn532::i2c::I2CInterface;
|
||||||
@@ -8,6 +9,7 @@ use pn532::{Pn532, Request};
|
|||||||
pub type Pn532Device<I2C> = Pn532<I2CInterface<I2C>, (), 34>;
|
pub type Pn532Device<I2C> = Pn532<I2CInterface<I2C>, (), 34>;
|
||||||
|
|
||||||
pub const PAGES_PER_READ: usize = 4;
|
pub const PAGES_PER_READ: usize = 4;
|
||||||
|
pub const BYTES_PER_READ: usize = PAGES_PER_READ * 4;
|
||||||
|
|
||||||
/// PN532 NFC reader driver.
|
/// PN532 NFC reader driver.
|
||||||
pub struct NfcPn532Driver<I2C>
|
pub struct NfcPn532Driver<I2C>
|
||||||
@@ -17,6 +19,35 @@ where
|
|||||||
pn532: Pn532Device<I2C>,
|
pn532: Pn532Device<I2C>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
struct PageParseError<const N: usize> {
|
||||||
|
iteration: u8,
|
||||||
|
bytes: [u8; N],
|
||||||
|
status_code: Option<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<const N: usize> Error for PageParseError<N> {}
|
||||||
|
|
||||||
|
impl<const N: usize> core::fmt::Display for PageParseError<N> {
|
||||||
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
let PageParseError {
|
||||||
|
iteration,
|
||||||
|
bytes,
|
||||||
|
status_code,
|
||||||
|
} = self;
|
||||||
|
match status_code {
|
||||||
|
Some(code) => write!(
|
||||||
|
f,
|
||||||
|
"NFC pages parse error in iteration {iteration} with error code 0x{code:02x}: {bytes:02x?}"
|
||||||
|
),
|
||||||
|
None => write!(
|
||||||
|
f,
|
||||||
|
"No data available for NFC page in iteration {iteration}: {bytes:02x?}"
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<I2C> NfcPn532Driver<I2C>
|
impl<I2C> NfcPn532Driver<I2C>
|
||||||
where
|
where
|
||||||
I2C: I2c,
|
I2C: I2c,
|
||||||
@@ -57,16 +88,21 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_nfc_page(iteration: u8, bytes: &[u8]) -> Result<[u8; PAGES_PER_READ * 4], ()> {
|
fn parse_nfc_page(
|
||||||
let success = bytes.first().is_some_and(|x| *x == 0);
|
iteration: u8,
|
||||||
if success {
|
bytes: &[u8],
|
||||||
let slice_len = bytes.len().min(PAGES_PER_READ * 4 + 1);
|
) -> Result<[u8; BYTES_PER_READ], PageParseError<BYTES_PER_READ>> {
|
||||||
let mut arr = [0; PAGES_PER_READ * 4];
|
let slice_len = bytes.len().min(BYTES_PER_READ + 1);
|
||||||
arr[..slice_len - 1].copy_from_slice(&bytes[1..slice_len]);
|
let mut arr = [0; BYTES_PER_READ];
|
||||||
Ok(arr)
|
arr[..slice_len - 1].copy_from_slice(&bytes[1..slice_len]);
|
||||||
} else {
|
|
||||||
info!("err {iteration}: {:02x?}", bytes);
|
match bytes.first() {
|
||||||
Err(())
|
Some(0x00) => Ok(arr),
|
||||||
|
error => Err(PageParseError {
|
||||||
|
iteration,
|
||||||
|
bytes: arr,
|
||||||
|
status_code: error.copied(),
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,18 +115,25 @@ where
|
|||||||
let mut data: Vec<u8> = Vec::with_capacity(858);
|
let mut data: Vec<u8> = Vec::with_capacity(858);
|
||||||
|
|
||||||
for i in (0x0B..=230).step_by(PAGES_PER_READ) {
|
for i in (0x0B..=230).step_by(PAGES_PER_READ) {
|
||||||
let mut parse_result = Err(());
|
let bytes = loop {
|
||||||
while parse_result.is_err() {
|
let read = self
|
||||||
let Ok(result) = self
|
|
||||||
.pn532
|
.pn532
|
||||||
.process_async(&Request::ntag_read(i), PAGES_PER_READ * 4 + 1)
|
.process_async(&Request::ntag_read(i), BYTES_PER_READ + 1)
|
||||||
.await
|
.await;
|
||||||
else {
|
|
||||||
continue;
|
let bytes = match read {
|
||||||
|
Ok(bytes) => bytes,
|
||||||
|
Err(e) => {
|
||||||
|
error!("Reading page {i} failed: {e:?}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
parse_result = Self::parse_nfc_page(i, result);
|
|
||||||
}
|
match Self::parse_nfc_page(i, bytes) {
|
||||||
let bytes = parse_result.unwrap();
|
Ok(data) => break data,
|
||||||
|
Err(e) => error!("Parsing page failed: {e}"),
|
||||||
|
}
|
||||||
|
};
|
||||||
let bytes = if i == 0x0B { &bytes[1..] } else { &bytes };
|
let bytes = if i == 0x0B { &bytes[1..] } else { &bytes };
|
||||||
data.extend(bytes);
|
data.extend(bytes);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ use esp_hal::delay::Delay;
|
|||||||
use esp_hal::gpio::Output;
|
use esp_hal::gpio::Output;
|
||||||
use ili9341::{DisplaySize240x320, Ili9341, Orientation};
|
use ili9341::{DisplaySize240x320, Ili9341, Orientation};
|
||||||
|
|
||||||
use crate::display::shared_bus::{DisplaySpiBus, SharedOutput};
|
use crate::drivers::spi_bus::{DisplaySpiBus, SharedOutput};
|
||||||
|
|
||||||
type GenericDualPrimaryDisplay<'a, BUS, DC, RES> =
|
type GenericPrimaryDisplay<'a, BUS, DC, RES> =
|
||||||
Ili9341<SPIInterface<AtomicDevice<'a, BUS, Output<'a>, Delay>, DC>, RES>;
|
Ili9341<SPIInterface<AtomicDevice<'a, BUS, Output<'a>, Delay>, DC>, RES>;
|
||||||
pub type DualPrimaryDisplay<'a> =
|
pub type PrimaryDisplay<'a> =
|
||||||
GenericDualPrimaryDisplay<'a, DisplaySpiBus, SharedOutput<'a>, Output<'a>>;
|
GenericPrimaryDisplay<'a, DisplaySpiBus, SharedOutput<'a>, Output<'a>>;
|
||||||
|
|
||||||
pub struct PrimaryDisplayPinConfiguration<'a> {
|
pub struct PrimaryDisplayPinConfiguration<'a> {
|
||||||
pub spi_bus: &'a AtomicCell<DisplaySpiBus>,
|
pub spi_bus: &'a AtomicCell<DisplaySpiBus>,
|
||||||
@@ -23,7 +23,7 @@ pub struct PrimaryDisplayPinConfiguration<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> PrimaryDisplayPinConfiguration<'a> {
|
impl<'a> PrimaryDisplayPinConfiguration<'a> {
|
||||||
pub fn build(self) -> DualPrimaryDisplay<'a> {
|
pub fn build(self) -> PrimaryDisplay<'a> {
|
||||||
let spi_dev = AtomicDevice::new(self.spi_bus, self.cs, Delay::new()).unwrap();
|
let spi_dev = AtomicDevice::new(self.spi_bus, self.cs, Delay::new()).unwrap();
|
||||||
let iface = SPIInterface::new(spi_dev, self.dc);
|
let iface = SPIInterface::new(spi_dev, self.dc);
|
||||||
|
|
||||||
@@ -6,12 +6,12 @@ use embedded_hal_bus::util::AtomicCell;
|
|||||||
use esp_hal::delay::Delay;
|
use esp_hal::delay::Delay;
|
||||||
use esp_hal::gpio::Output;
|
use esp_hal::gpio::Output;
|
||||||
|
|
||||||
use crate::display::shared_bus::{DisplaySpiBus, SharedOutput, SharedReset};
|
use crate::drivers::spi_bus::{DisplaySpiBus, SharedOutput, SharedReset};
|
||||||
|
|
||||||
pub type SecondaryOledDisplay<'a, BUS, RST, DC> =
|
pub type GenericSecondaryDisplay<'a, BUS, RST, DC> =
|
||||||
Ch1115<SPIInterface<AtomicDevice<'a, BUS, Output<'a>, Delay>, DC>, RST, Size128x64>;
|
Ch1115<SPIInterface<AtomicDevice<'a, BUS, Output<'a>, Delay>, DC>, RST, Size128x64>;
|
||||||
pub type DualSecondaryDisplay<'a> =
|
pub type SecondaryDisplay<'a> =
|
||||||
SecondaryOledDisplay<'a, DisplaySpiBus, SharedReset<'a>, SharedOutput<'a>>;
|
GenericSecondaryDisplay<'a, DisplaySpiBus, SharedReset<'a>, SharedOutput<'a>>;
|
||||||
|
|
||||||
pub struct SecondaryDisplayPinConfiguration<'a> {
|
pub struct SecondaryDisplayPinConfiguration<'a> {
|
||||||
pub spi_bus: &'a AtomicCell<DisplaySpiBus>,
|
pub spi_bus: &'a AtomicCell<DisplaySpiBus>,
|
||||||
@@ -21,7 +21,7 @@ pub struct SecondaryDisplayPinConfiguration<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> SecondaryDisplayPinConfiguration<'a> {
|
impl<'a> SecondaryDisplayPinConfiguration<'a> {
|
||||||
pub fn build(self) -> [DualSecondaryDisplay<'a>; 3] {
|
pub fn build(self) -> [SecondaryDisplay<'a>; 3] {
|
||||||
let mut displays = self.cs_pins.map(|cs| {
|
let mut displays = self.cs_pins.map(|cs| {
|
||||||
let spi_dev = AtomicDevice::new(self.spi_bus, cs, Delay::new()).unwrap();
|
let spi_dev = AtomicDevice::new(self.spi_bus, cs, Delay::new()).unwrap();
|
||||||
let interface = SPIInterface::new(spi_dev, self.dc.clone());
|
let interface = SPIInterface::new(spi_dev, self.dc.clone());
|
||||||
@@ -36,7 +36,7 @@ impl<'a> SecondaryDisplayPinConfiguration<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn init_single_reset<'a: 'b, 'b>(
|
fn init_single_reset<'a: 'b, 'b>(
|
||||||
displays: impl IntoIterator<Item = &'b mut DualSecondaryDisplay<'a>>,
|
displays: impl IntoIterator<Item = &'b mut SecondaryDisplay<'a>>,
|
||||||
shared_reset: SharedReset<'a>,
|
shared_reset: SharedReset<'a>,
|
||||||
) {
|
) {
|
||||||
let mut displays = displays.into_iter().peekable();
|
let mut displays = displays.into_iter().peekable();
|
||||||
@@ -9,10 +9,10 @@ use esp_hal::spi::Mode;
|
|||||||
use esp_hal::spi::master::{Config as SpiConfig, Spi};
|
use esp_hal::spi::master::{Config as SpiConfig, Spi};
|
||||||
use esp_hal::time::Rate;
|
use esp_hal::time::Rate;
|
||||||
|
|
||||||
use crate::display::primary_lcd::DualPrimaryDisplay;
|
use crate::drivers::primary_lcd::PrimaryDisplay;
|
||||||
use crate::display::primary_lcd::PrimaryDisplayPinConfiguration;
|
use crate::drivers::primary_lcd::PrimaryDisplayPinConfiguration;
|
||||||
use crate::display::secondary_oled::DualSecondaryDisplay;
|
use crate::drivers::secondary_oled::SecondaryDisplay;
|
||||||
use crate::display::secondary_oled::SecondaryDisplayPinConfiguration;
|
use crate::drivers::secondary_oled::SecondaryDisplayPinConfiguration;
|
||||||
|
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use embassy_sync::blocking_mutex::Mutex as BlockingMutex;
|
use embassy_sync::blocking_mutex::Mutex as BlockingMutex;
|
||||||
@@ -135,12 +135,7 @@ where
|
|||||||
RES2: OutputPin + 'static,
|
RES2: OutputPin + 'static,
|
||||||
DC: OutputPin + 'static,
|
DC: OutputPin + 'static,
|
||||||
{
|
{
|
||||||
pub fn build(
|
pub fn build(self) -> (PrimaryDisplay<'static>, [SecondaryDisplay<'static>; 3]) {
|
||||||
self,
|
|
||||||
) -> (
|
|
||||||
DualPrimaryDisplay<'static>,
|
|
||||||
[DualSecondaryDisplay<'static>; 3],
|
|
||||||
) {
|
|
||||||
let spi = Spi::new(
|
let spi = Spi::new(
|
||||||
self.spi_peripheral,
|
self.spi_peripheral,
|
||||||
SpiConfig::default()
|
SpiConfig::default()
|
||||||
@@ -4,10 +4,11 @@ use esp_hal::delay::Delay;
|
|||||||
use i2c_character_display::{CharacterDisplayPCF8574T, LcdDisplayType};
|
use i2c_character_display::{CharacterDisplayPCF8574T, LcdDisplayType};
|
||||||
use log::error;
|
use log::error;
|
||||||
|
|
||||||
pub type TertiaryLcd<I2C> = CharacterDisplayPCF8574T<I2C, Delay>;
|
type GenericTertiaryDisplay<I2C> = CharacterDisplayPCF8574T<I2C, Delay>;
|
||||||
pub type TertiaryI2cLcd<'a> = TertiaryLcd<AtomicDevice<'a, esp_hal::i2c::master::I2c<'a, esp_hal::Blocking>>>;
|
pub type TertiaryDisplay<'a> =
|
||||||
|
GenericTertiaryDisplay<AtomicDevice<'a, esp_hal::i2c::master::I2c<'a, esp_hal::Blocking>>>;
|
||||||
|
|
||||||
pub fn init_tertiary_lcd<I2C>(i2c: I2C) -> TertiaryLcd<I2C>
|
pub fn init_tertiary_lcd<I2C>(i2c: I2C) -> GenericTertiaryDisplay<I2C>
|
||||||
where
|
where
|
||||||
I2C: I2c,
|
I2C: I2c,
|
||||||
{
|
{
|
||||||
@@ -27,7 +28,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_line<I2C>(
|
pub fn write_line<I2C>(
|
||||||
lcd: &mut TertiaryLcd<I2C>,
|
lcd: &mut GenericTertiaryDisplay<I2C>,
|
||||||
line: u8,
|
line: u8,
|
||||||
text: &str,
|
text: &str,
|
||||||
) -> Result<(), i2c_character_display::CharacterDisplayError<I2C>>
|
) -> Result<(), i2c_character_display::CharacterDisplayError<I2C>>
|
||||||
@@ -49,7 +50,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_wrapped<I2C>(
|
pub fn write_wrapped<I2C>(
|
||||||
lcd: &mut TertiaryLcd<I2C>,
|
lcd: &mut GenericTertiaryDisplay<I2C>,
|
||||||
text: &str,
|
text: &str,
|
||||||
) -> Result<(), i2c_character_display::CharacterDisplayError<I2C>>
|
) -> Result<(), i2c_character_display::CharacterDisplayError<I2C>>
|
||||||
where
|
where
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
pub mod inputs;
|
pub mod inputs;
|
||||||
pub mod navigation;
|
pub mod navigation;
|
||||||
pub mod state;
|
|
||||||
pub mod outputs;
|
pub mod outputs;
|
||||||
|
pub mod state;
|
||||||
|
|||||||
@@ -3,17 +3,16 @@ use embedded_graphics::{
|
|||||||
pixelcolor::{Rgb565, RgbColor as _},
|
pixelcolor::{Rgb565, RgbColor as _},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::display::{
|
use crate::drivers::{
|
||||||
primary_lcd::DualPrimaryDisplay, secondary_oled::DualSecondaryDisplay,
|
primary_lcd::PrimaryDisplay, secondary_oled::SecondaryDisplay, tertiary_lcd::TertiaryDisplay,
|
||||||
tertiary_lcd::TertiaryI2cLcd,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Outputs {
|
pub struct Outputs {
|
||||||
pub primary_display: DualPrimaryDisplay<'static>,
|
pub primary_display: PrimaryDisplay<'static>,
|
||||||
pub secondary_display_1: DualSecondaryDisplay<'static>,
|
pub secondary_display_1: SecondaryDisplay<'static>,
|
||||||
pub secondary_display_2: DualSecondaryDisplay<'static>,
|
pub secondary_display_2: SecondaryDisplay<'static>,
|
||||||
pub secondary_display_3: DualSecondaryDisplay<'static>,
|
pub secondary_display_3: SecondaryDisplay<'static>,
|
||||||
pub tertiary_display: TertiaryI2cLcd<'static>,
|
pub tertiary_display: TertiaryDisplay<'static>,
|
||||||
pub _led_a: (),
|
pub _led_a: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,12 @@ use embedded_graphics::prelude::RgbColor;
|
|||||||
use embedded_graphics_core::draw_target::DrawTarget;
|
use embedded_graphics_core::draw_target::DrawTarget;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
card::model::Card, navigation::{navigation::{Action, Navigable, NewState}, outputs::Outputs}, views::view::View,
|
card::model::Card,
|
||||||
|
navigation::{
|
||||||
|
navigation::{Action, Navigable, NewState},
|
||||||
|
outputs::Outputs,
|
||||||
|
},
|
||||||
|
views::view::View,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ pub struct MainMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Navigable for MainMenu {
|
impl Navigable for MainMenu {
|
||||||
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send
|
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send {
|
||||||
{
|
|
||||||
let display = &mut outputs.primary_display;
|
let display = &mut outputs.primary_display;
|
||||||
display.clear(Rgb565::BLACK).unwrap();
|
display.clear(Rgb565::BLACK).unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ pub struct ScanMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Navigable for ScanMenu {
|
impl Navigable for ScanMenu {
|
||||||
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send
|
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send {
|
||||||
{
|
|
||||||
let display = &mut outputs.primary_display;
|
let display = &mut outputs.primary_display;
|
||||||
let style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
|
let style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
|
||||||
display.clear(Rgb565::BLACK).unwrap();
|
display.clear(Rgb565::BLACK).unwrap();
|
||||||
|
|||||||
+1
-3
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
use crate::navigation::outputs::Outputs;
|
use crate::navigation::outputs::Outputs;
|
||||||
use crate::views::card_view::CardView;
|
use crate::views::card_view::CardView;
|
||||||
use crate::views::{
|
use crate::views::{
|
||||||
@@ -18,8 +17,7 @@ pub enum View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Navigable for View {
|
impl Navigable for View {
|
||||||
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send
|
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send {
|
||||||
{
|
|
||||||
async move {
|
async move {
|
||||||
match self {
|
match self {
|
||||||
View::Main(main_menu) => main_menu.display(outputs).await,
|
View::Main(main_menu) => main_menu.display(outputs).await,
|
||||||
|
|||||||
Reference in New Issue
Block a user