Author SHA1 Message Date
lukas 8206d7460d Fixed color rendering issue 2026-08-21 23:29:43 +02:00
ede1998 5a534b1f0b fix shifts in scanned card display 2026-08-14 22:05:26 +02:00
lukasandede1998 1d0bae4e6c Read NFC data is now displayed 2026-08-02 19:03:27 +02:00
3 changed files with 63 additions and 12 deletions
+59 -8
View File
@@ -19,9 +19,9 @@ use embassy_time::Timer;
use embedded_graphics::draw_target::DrawTarget; use embedded_graphics::draw_target::DrawTarget;
use embedded_graphics::pixelcolor::Rgb565; use embedded_graphics::pixelcolor::Rgb565;
use embedded_graphics::prelude::RgbColor; use embedded_graphics::prelude::RgbColor;
use esp_hal::time::Duration;
use esp_hal::clock::CpuClock; use esp_hal::clock::CpuClock;
use esp_hal::delay::Delay; use esp_hal::delay::Delay;
use esp_hal::time::Duration;
use esp_hal::timer::timg::TimerGroup; use esp_hal::timer::timg::TimerGroup;
use log::error; use log::error;
@@ -31,6 +31,54 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! {
loop {} loop {}
} }
const SCANNED_PAYLOAD: &[u8] = &[
3, 255, 3, 115, 196, 19, 0, 0, 3, 90, 109, 121, 115, 116, 101, 114, 121, 104, 97, 99, 107, 46,
99, 111, 109, 58, 99, 99, 49, 233, 36, 1, 10, 75, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 85, 85, 85, 85, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 245,
85, 85, 85, 85, 95, 95, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 245, 85, 85,
255, 255, 85, 85, 245, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 245, 95, 255,
255, 255, 245, 85, 95, 95, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 245, 80, 0, 255,
255, 245, 85, 85, 245, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 85, 0, 0, 15, 255,
255, 245, 85, 245, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 85, 0, 0, 15, 255, 255,
255, 85, 85, 255, 255, 255, 255, 255, 255, 255, 255, 255, 245, 85, 80, 0, 255, 255, 255, 255,
245, 85, 255, 255, 255, 255, 255, 255, 255, 255, 255, 245, 85, 245, 255, 255, 255, 255, 255,
245, 85, 255, 255, 255, 255, 255, 255, 255, 255, 255, 245, 85, 245, 255, 255, 255, 15, 255,
245, 85, 95, 255, 255, 255, 255, 255, 255, 255, 255, 245, 85, 245, 255, 255, 0, 15, 255, 245,
85, 95, 255, 255, 255, 255, 255, 255, 255, 255, 245, 85, 255, 80, 0, 0, 15, 255, 255, 245, 95,
255, 255, 255, 255, 255, 255, 255, 255, 245, 85, 255, 0, 0, 0, 15, 255, 255, 245, 95, 255, 255,
255, 255, 255, 255, 255, 255, 255, 85, 255, 0, 0, 0, 15, 255, 255, 245, 85, 255, 255, 255, 255,
255, 255, 255, 255, 255, 85, 240, 0, 0, 0, 15, 255, 255, 245, 85, 255, 255, 255, 255, 255, 255,
255, 255, 255, 85, 240, 15, 0, 0, 15, 255, 255, 255, 85, 255, 255, 255, 255, 255, 255, 255,
255, 255, 80, 0, 255, 255, 0, 15, 255, 255, 255, 85, 255, 255, 255, 255, 255, 255, 255, 255,
240, 0, 0, 255, 255, 0, 15, 255, 255, 255, 85, 95, 255, 255, 255, 255, 255, 255, 255, 240, 0,
0, 255, 255, 240, 15, 255, 255, 255, 85, 95, 255, 255, 255, 255, 255, 255, 255, 0, 5, 255, 255,
255, 240, 15, 255, 255, 255, 85, 95, 255, 255, 255, 255, 255, 255, 255, 0, 85, 255, 255, 255,
240, 15, 255, 255, 255, 85, 95, 255, 255, 255, 255, 255, 255, 255, 255, 245, 85, 255, 255, 240,
15, 255, 255, 255, 85, 95, 255, 255, 255, 255, 255, 255, 255, 255, 245, 85, 255, 255, 240, 15,
255, 255, 255, 85, 95, 255, 255, 255, 255, 255, 255, 255, 255, 245, 85, 255, 255, 240, 15, 255,
255, 255, 85, 95, 255, 255, 255, 255, 255, 255, 255, 255, 245, 85, 95, 255, 0, 15, 255, 255,
255, 85, 95, 255, 255, 255, 255, 255, 255, 255, 255, 255, 245, 80, 0, 0, 255, 255, 255, 255,
85, 95, 255, 255, 255, 255, 255, 255, 255, 255, 255, 245, 0, 15, 255, 255, 255, 255, 255, 85,
95, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 85, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 245, 255, 85, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 245, 255, 85, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 240, 5, 95, 255, 245, 95, 85, 85, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 240, 0, 85, 85, 85, 245, 85, 95, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 85, 95, 255, 85, 85, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 0, 5, 85, 85, 85, 95, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 0, 5, 85, 85, 85, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 15, 187,
161, 225, 7, 64, 41, 235, 110, 38, 0, 0, 0, 0, 0, 0, 0, 0, 211, 215, 165, 168, 183, 177, 51, 0,
165, 172, 187, 153, 209, 187, 161, 238, 123, 2, 204, 136, 150, 159, 7, 0, 134, 57, 162, 97, 11,
76, 47, 71, 126, 157, 11, 0, 83, 112, 101, 101, 100, 121, 32, 116, 104, 105, 110, 103, 32, 99,
111, 109, 101, 115, 32, 111, 117, 116, 0, 0, 116, 238, 175, 85, 82, 152, 67, 113, 193, 113,
219, 188, 173, 50, 137, 138, 96, 130, 104, 40, 72, 189, 43, 63, 72, 73, 101, 120, 136, 168, 16,
57, 90, 119, 100, 187, 79, 126, 111, 195, 189, 40, 67, 196, 36, 176, 243, 45, 0, 254, 0, 0, 0,
189, 4, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
];
extern crate alloc; extern crate alloc;
// This creates a default app-descriptor required by the esp-idf bootloader. // This creates a default app-descriptor required by the esp-idf bootloader.
@@ -70,12 +118,12 @@ async fn main(spawner: Spawner) {
let mut display = init_primary_lcd( let mut display = init_primary_lcd(
peripherals.SPI2, peripherals.SPI2,
peripherals.GPIO36, peripherals.GPIO36, // sck
peripherals.GPIO35, peripherals.GPIO35, // mosi
peripherals.GPIO37, peripherals.GPIO37, // miso
peripherals.GPIO11, peripherals.GPIO11, // primary cs
peripherals.GPIO10, peripherals.GPIO10, // shared reset
peripherals.GPIO12, peripherals.GPIO12, // shared dc
&mut delay, &mut delay,
); );
@@ -85,7 +133,8 @@ async fn main(spawner: Spawner) {
let mut nav_state = NavigationState::new(); let mut nav_state = NavigationState::new();
let mut nfc_driver = NfcPn532Driver::new(peripherals.I2C0, peripherals.GPIO17, peripherals.GPIO18); let mut nfc_driver =
NfcPn532Driver::new(peripherals.I2C0, peripherals.GPIO17, peripherals.GPIO18);
let timeout = Duration::from_millis(1000); let timeout = Duration::from_millis(1000);
if nfc_driver.configure_sam(timeout).is_ok() { if nfc_driver.configure_sam(timeout).is_ok() {
log::info!("NFC SAM configuration successful"); log::info!("NFC SAM configuration successful");
@@ -96,6 +145,8 @@ async fn main(spawner: Spawner) {
loop { loop {
if let Ok(card_data) = nfc_driver.read_card_data() { if let Ok(card_data) = nfc_driver.read_card_data() {
log::info!("NFC Card Read: {:?}", card_data); log::info!("NFC Card Read: {:?}", card_data);
render_nfc_payload(&mut display, &card_data[29..888]);
} }
if button1.is_low() { if button1.is_low() {
+3 -3
View File
@@ -1,11 +1,11 @@
use embedded_graphics::pixelcolor::Rgb565; use embedded_graphics::pixelcolor::Rgb565;
use embedded_graphics::pixelcolor::Rgb888;
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Rgb(pub u8, pub u8, pub u8); pub struct Rgb(pub u8, pub u8, pub u8);
impl Rgb { impl Rgb {
pub fn into_rgb565(self) -> Rgb565 { pub fn into_rgb565(self) -> Rgb565 {
Rgb565::new(self.0, self.1, self.2) Rgb888::new(self.0, self.1, self.2).into()
} }
} }
+1 -1
View File
@@ -12,7 +12,7 @@ use crate::card::model::NfcPayload;
use crate::display::palette::{PALETTES, TYPE_STYLES}; use crate::display::palette::{PALETTES, TYPE_STYLES};
use crate::display::sprite::render_sprite_onto_ili9341; use crate::display::sprite::render_sprite_onto_ili9341;
pub fn render_nfc_payload<D>(display: &mut D, payload: &[u8; 858]) pub fn render_nfc_payload<D>(display: &mut D, payload: &[u8])
where where
D: DrawTarget<Color = Rgb565>, D: DrawTarget<Color = Rgb565>,
D::Error: core::fmt::Debug, D::Error: core::fmt::Debug,