Triple oled #37
+4
-4
@@ -10,9 +10,9 @@
|
||||
use alloc::boxed::Box;
|
||||
use creaturedex::card::decoder::split_nfc_hex;
|
||||
use creaturedex::card::model::Card;
|
||||
use creaturedex::display::secondary_oled::DualSecondaryDisplay;
|
||||
use creaturedex::display::secondary_oled::SecondaryDisplay;
|
||||
use creaturedex::display::shared_bus;
|
||||
use creaturedex::display::tertiary_lcd::{TertiaryI2cLcd, init_tertiary_lcd, write_wrapped};
|
||||
use creaturedex::display::tertiary_lcd::{TertiaryDisplay, init_tertiary_lcd, write_wrapped};
|
||||
use creaturedex::drivers::nfc_pn532::NfcPn532Driver;
|
||||
use creaturedex::navigation::inputs::Inputs;
|
||||
use creaturedex::navigation::navigation::{self, CARD_DATA};
|
||||
@@ -95,7 +95,7 @@ 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: 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?") {
|
||||
log::error!(
|
||||
"Tertiary LCD startup text write failed over shared I2C bus; check the shared bus, wiring, and device responses: {e}"
|
||||
@@ -179,7 +179,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();
|
||||
|
||||
let text_style = MonoTextStyle::new(&FONT_6X10, BinaryColor::On);
|
||||
|
||||
@@ -10,10 +10,10 @@ use ili9341::{DisplaySize240x320, Ili9341, Orientation};
|
||||
|
||||
use crate::display::shared_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>;
|
||||
pub type DualPrimaryDisplay<'a> =
|
||||
GenericDualPrimaryDisplay<'a, DisplaySpiBus, SharedOutput<'a>, Output<'a>>;
|
||||
pub type PrimaryDisplay<'a> =
|
||||
GenericPrimaryDisplay<'a, DisplaySpiBus, SharedOutput<'a>, Output<'a>>;
|
||||
|
||||
pub struct PrimaryDisplayPinConfiguration<'a> {
|
||||
pub spi_bus: &'a AtomicCell<DisplaySpiBus>,
|
||||
@@ -23,7 +23,7 @@ pub struct 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 iface = SPIInterface::new(spi_dev, self.dc);
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ use esp_hal::gpio::Output;
|
||||
|
||||
use crate::display::shared_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>;
|
||||
pub type DualSecondaryDisplay<'a> =
|
||||
SecondaryOledDisplay<'a, DisplaySpiBus, SharedReset<'a>, SharedOutput<'a>>;
|
||||
pub type SecondaryDisplay<'a> =
|
||||
GenericSecondaryDisplay<'a, DisplaySpiBus, SharedReset<'a>, SharedOutput<'a>>;
|
||||
|
||||
pub struct SecondaryDisplayPinConfiguration<'a> {
|
||||
pub spi_bus: &'a AtomicCell<DisplaySpiBus>,
|
||||
@@ -21,7 +21,7 @@ pub struct 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 spi_dev = AtomicDevice::new(self.spi_bus, cs, Delay::new()).unwrap();
|
||||
let interface = SPIInterface::new(spi_dev, self.dc.clone());
|
||||
@@ -36,7 +36,7 @@ impl<'a> SecondaryDisplayPinConfiguration<'a> {
|
||||
}
|
||||
|
||||
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>,
|
||||
) {
|
||||
let mut displays = displays.into_iter().peekable();
|
||||
|
||||
@@ -9,9 +9,9 @@ use esp_hal::spi::Mode;
|
||||
use esp_hal::spi::master::{Config as SpiConfig, Spi};
|
||||
use esp_hal::time::Rate;
|
||||
|
||||
use crate::display::primary_lcd::DualPrimaryDisplay;
|
||||
use crate::display::primary_lcd::PrimaryDisplay;
|
||||
use crate::display::primary_lcd::PrimaryDisplayPinConfiguration;
|
||||
use crate::display::secondary_oled::DualSecondaryDisplay;
|
||||
use crate::display::secondary_oled::SecondaryDisplay;
|
||||
use crate::display::secondary_oled::SecondaryDisplayPinConfiguration;
|
||||
|
||||
use core::cell::RefCell;
|
||||
@@ -135,12 +135,7 @@ where
|
||||
RES2: OutputPin + 'static,
|
||||
DC: OutputPin + 'static,
|
||||
{
|
||||
pub fn build(
|
||||
self,
|
||||
) -> (
|
||||
DualPrimaryDisplay<'static>,
|
||||
[DualSecondaryDisplay<'static>; 3],
|
||||
) {
|
||||
pub fn build(self) -> (PrimaryDisplay<'static>, [SecondaryDisplay<'static>; 3]) {
|
||||
let spi = Spi::new(
|
||||
self.spi_peripheral,
|
||||
SpiConfig::default()
|
||||
|
||||
@@ -4,10 +4,11 @@ use esp_hal::delay::Delay;
|
||||
use i2c_character_display::{CharacterDisplayPCF8574T, LcdDisplayType};
|
||||
use log::error;
|
||||
|
||||
pub type TertiaryLcd<I2C> = CharacterDisplayPCF8574T<I2C, Delay>;
|
||||
pub type TertiaryI2cLcd<'a> = TertiaryLcd<AtomicDevice<'a, esp_hal::i2c::master::I2c<'a, esp_hal::Blocking>>>;
|
||||
type GenericTertiaryDisplay<I2C> = CharacterDisplayPCF8574T<I2C, Delay>;
|
||||
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
|
||||
I2C: I2c,
|
||||
{
|
||||
@@ -27,7 +28,7 @@ where
|
||||
}
|
||||
|
||||
pub fn write_line<I2C>(
|
||||
lcd: &mut TertiaryLcd<I2C>,
|
||||
lcd: &mut GenericTertiaryDisplay<I2C>,
|
||||
line: u8,
|
||||
text: &str,
|
||||
) -> Result<(), i2c_character_display::CharacterDisplayError<I2C>>
|
||||
@@ -49,7 +50,7 @@ where
|
||||
}
|
||||
|
||||
pub fn write_wrapped<I2C>(
|
||||
lcd: &mut TertiaryLcd<I2C>,
|
||||
lcd: &mut GenericTertiaryDisplay<I2C>,
|
||||
text: &str,
|
||||
) -> Result<(), i2c_character_display::CharacterDisplayError<I2C>>
|
||||
where
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
pub mod inputs;
|
||||
pub mod navigation;
|
||||
pub mod state;
|
||||
pub mod outputs;
|
||||
pub mod state;
|
||||
|
||||
@@ -4,16 +4,15 @@ use embedded_graphics::{
|
||||
};
|
||||
|
||||
use crate::display::{
|
||||
primary_lcd::DualPrimaryDisplay, secondary_oled::DualSecondaryDisplay,
|
||||
tertiary_lcd::TertiaryI2cLcd,
|
||||
primary_lcd::PrimaryDisplay, secondary_oled::SecondaryDisplay, tertiary_lcd::TertiaryDisplay,
|
||||
};
|
||||
|
||||
pub struct Outputs {
|
||||
pub primary_display: DualPrimaryDisplay<'static>,
|
||||
pub secondary_display_1: DualSecondaryDisplay<'static>,
|
||||
pub secondary_display_2: DualSecondaryDisplay<'static>,
|
||||
pub secondary_display_3: DualSecondaryDisplay<'static>,
|
||||
pub tertiary_display: TertiaryI2cLcd<'static>,
|
||||
pub primary_display: PrimaryDisplay<'static>,
|
||||
pub secondary_display_1: SecondaryDisplay<'static>,
|
||||
pub secondary_display_2: SecondaryDisplay<'static>,
|
||||
pub secondary_display_3: SecondaryDisplay<'static>,
|
||||
pub tertiary_display: TertiaryDisplay<'static>,
|
||||
pub _led_a: (),
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,12 @@ use embedded_graphics::prelude::RgbColor;
|
||||
use embedded_graphics_core::draw_target::DrawTarget;
|
||||
|
||||
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)]
|
||||
|
||||
@@ -22,8 +22,7 @@ pub struct 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;
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
|
||||
|
||||
@@ -33,8 +33,7 @@ pub struct 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 style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
|
||||
+1
-3
@@ -1,4 +1,3 @@
|
||||
|
||||
use crate::navigation::outputs::Outputs;
|
||||
use crate::views::card_view::CardView;
|
||||
use crate::views::{
|
||||
@@ -18,8 +17,7 @@ pub enum 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 {
|
||||
match self {
|
||||
View::Main(main_menu) => main_menu.display(outputs).await,
|
||||
|
||||
Reference in New Issue
Block a user