Added NFC implementation into refactored structure

This commit is contained in:
2026-08-02 16:26:13 +02:00
parent 5f76802f92
commit 78765ce595
4 changed files with 145 additions and 1 deletions
+14
View File
@@ -10,6 +10,7 @@
use creaturedex::card::mock::{MOCK_PAYLOAD, MOCK_PAYLOAD2};
use creaturedex::display::primary_lcd::init_primary_lcd;
use creaturedex::display::views::card_view::render_nfc_payload;
use creaturedex::drivers::nfc_pn532::NfcPn532Driver;
use creaturedex::navigation::input::init_navigation_button;
use creaturedex::navigation::state::NavigationState;
use creaturedex::network::wifi::setup_wifi;
@@ -18,6 +19,7 @@ use embassy_time::Timer;
use embedded_graphics::draw_target::DrawTarget;
use embedded_graphics::pixelcolor::Rgb565;
use embedded_graphics::prelude::RgbColor;
use esp_hal::time::Duration;
use esp_hal::clock::CpuClock;
use esp_hal::delay::Delay;
use esp_hal::timer::timg::TimerGroup;
@@ -83,7 +85,19 @@ async fn main(spawner: Spawner) {
let mut nav_state = NavigationState::new();
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() {
log::info!("NFC SAM configuration successful");
} else {
log::error!("NFC SAM configuration failed");
}
loop {
if let Some(card_data) = nfc_driver.read_card(timeout) {
log::info!("NFC Card Read: {:?}", card_data);
}
if button1.is_low() {
log::info!("Button pressed!");
display.clear(Rgb565::BLACK).unwrap();