Initial implementation of OLED driver with shared SPI bus

This commit is contained in:
2026-08-02 17:20:40 +02:00
parent 7ce3a60a08
commit 020ca5cd4b
7 changed files with 301 additions and 48 deletions
+29 -11
View File
@@ -8,7 +8,9 @@
#![deny(clippy::large_stack_frames)]
use creaturedex::card::mock::{MOCK_PAYLOAD, MOCK_PAYLOAD2};
use creaturedex::display::primary_lcd::init_primary_lcd;
use creaturedex::display::shared_bus::init_dual_displays;
use creaturedex::display::views::card_view::render_nfc_payload;
use creaturedex::drivers::nfc_pn532::NfcPn532Driver;
use creaturedex::navigation::input::init_navigation_button;
@@ -16,8 +18,13 @@ use creaturedex::navigation::state::NavigationState;
use creaturedex::network::wifi::setup_wifi;
use embassy_executor::Spawner;
use embassy_time::Timer;
use embedded_graphics::{
mono_font::{ascii::FONT_6X10, MonoTextStyle},
prelude::*,
text::Text,
};
use embedded_graphics::draw_target::DrawTarget;
use embedded_graphics::pixelcolor::Rgb565;
use embedded_graphics::pixelcolor::{BinaryColor, Rgb565};
use embedded_graphics::prelude::RgbColor;
use esp_hal::time::Duration;
use esp_hal::clock::CpuClock;
@@ -68,23 +75,32 @@ async fn main(spawner: Spawner) {
esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0);
let mut display = init_primary_lcd(
let (mut display, mut oled) = init_dual_displays(
peripherals.SPI2,
peripherals.GPIO36,
peripherals.GPIO35,
peripherals.GPIO37,
peripherals.GPIO11,
peripherals.GPIO10,
peripherals.GPIO12,
peripherals.GPIO36, // sck
peripherals.GPIO35, // mosi
peripherals.GPIO37, // miso
peripherals.GPIO11, // primary cs
peripherals.GPIO5, // oled cs
peripherals.GPIO10, // shared reset
peripherals.GPIO12, // shared dc
&mut delay,
);
setup_wifi(peripherals.WIFI, peripherals.FLASH, &spawner).await;
log::info!("Setup complete, entering main loop");
let mut nav_state = NavigationState::new();
oled.clear(BinaryColor::Off).unwrap();
let text_style = MonoTextStyle::new(&FONT_6X10, BinaryColor::On);
Text::new("Hello OLED", Point::new(10, 20), text_style)
.draw(&mut oled)
.unwrap();
oled.flush().unwrap();
let mut nfc_driver = NfcPn532Driver::new(peripherals.I2C0, peripherals.GPIO17, peripherals.GPIO18);
let timeout = Duration::from_millis(1000);
if nfc_driver.configure_sam(timeout).is_ok() {
@@ -93,6 +109,8 @@ async fn main(spawner: Spawner) {
log::error!("NFC SAM configuration failed");
}
log::info!("Setup complete, entering main loop");
loop {
if let Ok(card_data) = nfc_driver.read_card_data() {
log::info!("NFC Card Read: {:?}", card_data);