fix shifts in scanned card display

This commit is contained in:
2026-08-14 22:05:26 +02:00
parent 1d0bae4e6c
commit 5a534b1f0b
+52 -3
View File
@@ -19,9 +19,9 @@ 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::time::Duration;
use esp_hal::timer::timg::TimerGroup;
use log::error;
@@ -31,6 +31,54 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! {
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;
// This creates a default app-descriptor required by the esp-idf bootloader.
@@ -85,7 +133,8 @@ async fn main(spawner: Spawner) {
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);
if nfc_driver.configure_sam(timeout).is_ok() {
log::info!("NFC SAM configuration successful");
@@ -97,7 +146,7 @@ async fn main(spawner: Spawner) {
if let Ok(card_data) = nfc_driver.read_card_data() {
log::info!("NFC Card Read: {:?}", card_data);
render_nfc_payload(&mut display, &card_data);
render_nfc_payload(&mut display, &card_data[29..888]);
}
if button1.is_low() {