5 Commits
Author SHA1 Message Date
lukas cf6c068394 Fixed color rendering for good 2026-08-22 00:29:10 +02:00
lukas 8fd3de2ab7 Moved Orange Portal mock into mock.rs file 2026-08-21 23:44:37 +02:00
lukas ec40a3e9fe Fixed color rendering issue 2026-08-21 23:40:41 +02:00
ede1998andlukas be7b65b2ac fix shifts in scanned card display 2026-08-21 23:40:40 +02:00
lukas fb4840773a Read NFC data is now displayed 2026-08-21 23:39:24 +02:00
12 changed files with 224 additions and 196 deletions
+6 -1
View File
@@ -49,7 +49,12 @@ num_enum = { version = "0.7.6", default-features = false }
[profile.dev]
# The default debug profile is too slow and too big for resource-constrained devices.
# Always build with some optimizations enabled.
opt-level = "s"
opt-level = 0
debug = 2
[profile.dev.package."*"]
opt-level = 3
debug = 0
[profile.release]
codegen-units = 1 # LLVM can perform better optimizations using a single thread
+6 -15
View File
@@ -8,20 +8,12 @@
#![deny(clippy::large_stack_frames)]
use alloc::boxed::Box;
use creaturedex::card::mock::{MOCK_PAYLOAD, MOCK_PAYLOAD2};
use creaturedex::display::primary_lcd::{PrimaryLcdDisplay, init_primary_lcd};
use creaturedex::drivers::nfc_pn532::NfcPn532Driver;
use creaturedex::navigation::inputs::Inputs;
use creaturedex::navigation::navigation;
use creaturedex::navigation::state::NavigationState;
use creaturedex::network::wifi::setup_wifi;
use embassy_executor::Spawner;
use embassy_time::Timer;
use embedded_graphics::draw_target::DrawTarget;
use embedded_graphics::pixelcolor::Rgb565;
use embedded_graphics::prelude::RgbColor;
use esp_hal::clock::CpuClock;
use esp_hal::delay::Delay;
use esp_hal::gpio::{Input, InputConfig, Pull};
use esp_hal::time::Duration;
use esp_hal::timer::timg::TimerGroup;
@@ -61,12 +53,12 @@ async fn main(spawner: Spawner) {
let display: &mut PrimaryLcdDisplay = Box::leak(Box::new(init_primary_lcd(
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.GPIO10, // shared reset
peripherals.GPIO12, // shared dc
)));
//setup_wifi(peripherals.WIFI, peripherals.FLASH, &spawner).await;
@@ -80,7 +72,6 @@ async fn main(spawner: Spawner) {
log::error!("NFC SAM configuration failed");
}
let mut nav_state = NavigationState::new();
let button_config = InputConfig::default().with_pull(Pull::Up);
let inputs = Inputs {
+60 -2
View File
@@ -1,4 +1,4 @@
/// Mock payload 2 acting as simulated NFC card read
/// GlaDos
pub const MOCK_PAYLOAD2: [u8; 858] = [
0xE9, 0x24, 0x03, 0xDA, 0x45, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0xAA, 0xA0, 0xF0, 0xAA, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
@@ -56,7 +56,7 @@ pub const MOCK_PAYLOAD2: [u8; 858] = [
0x95, 0x2D, 0x14, 0xBD, 0x43, 0xB2, 0x40, 0x76, 0x78, 0x00,
];
/// Mock payload 1 acting as simulated NFC card read
/// Blue Portal
pub const MOCK_PAYLOAD: [u8; 858] = [
0xE9, 0x24, 0x01, 0x47, 0xF2, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
@@ -113,3 +113,61 @@ pub const MOCK_PAYLOAD: [u8; 858] = [
0x03, 0x63, 0x8F, 0x4C, 0x2F, 0xBA, 0xCC, 0x17, 0x23, 0x51, 0x60, 0x27, 0x3B, 0x00, 0x1C, 0x6D,
0x1F, 0x8C, 0x6B, 0x3E, 0x32, 0xE2, 0x53, 0xD9, 0x8F,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xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xBB, 0xA1, 0xE1, 0x07,
0x40, 0x29, 0xEB, 0x6E, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD3, 0xD7, 0xA5,
0xA8, 0xB7, 0xB1, 0x33, 0x00, 0xA5, 0xAC, 0xBB, 0x99, 0xD1, 0xBB, 0xA1, 0xEE, 0x7B, 0x02, 0xCC,
0x88, 0x96, 0x9F, 0x07, 0x00, 0x86, 0x39, 0xA2, 0x61, 0x0B, 0x4C, 0x2F, 0x47, 0x7E, 0x9D, 0x0B,
0x00, 0x53, 0x70, 0x65, 0x65, 0x64, 0x79, 0x20, 0x74, 0x68, 0x69, 0x6E, 0x67, 0x20, 0x63, 0x6F,
0x6D, 0x65, 0x73, 0x20, 0x6F, 0x75, 0x74, 0x00, 0x00, 0x74, 0xEE, 0xAF, 0x55, 0x52, 0x98, 0x43,
0x71, 0xC1, 0x71, 0xDB, 0xBC, 0xAD, 0x32, 0x89, 0x8A, 0x60, 0x82, 0x68, 0x28, 0x48, 0xBD, 0x2B,
0x3F, 0x48, 0x49, 0x65, 0x78, 0x88, 0xA8, 0x10, 0x39, 0x5A, 0x77, 0x64, 0xBB, 0x4F, 0x7E, 0x6F,
0xC3, 0xBD, 0x28, 0x43, 0xC4, 0x24, 0xB0, 0xF3, 0x2D, 0x00,
];
+145 -145
View File
@@ -4,7 +4,7 @@ use alloc::{string::String, vec::Vec};
use num_enum::FromPrimitive;
use crate::card::decoder::{Events, decode_known_event, decode_packed_card_text, decode_secret};
use embedded_graphics::pixelcolor::Rgb565;
use embedded_graphics::pixelcolor::{Rgb565, Rgb888};
#[derive(Debug, Clone, Copy)]
pub struct NfcPayload<'a> {
@@ -22,14 +22,14 @@ pub struct NfcPayload<'a> {
#[repr(u8)]
pub enum CardType {
#[num_enum(default)]
Default = 0,
Blueprint = 1,
CYBER = 2,
Nature = 3,
Fossil = 4,
Ghost = 5,
Daemon = 6,
Fairy = 7,
Default = 1,
Blueprint = 2,
CYBER = 3,
Nature = 4,
Fossil = 5,
Ghost = 6,
Daemon = 7,
Fairy = 8,
}
impl Display for CardType {
@@ -51,14 +51,14 @@ pub type PrimaryColor = Rgb565;
impl Into<PrimaryColor> for CardType {
fn into(self) -> PrimaryColor {
match self {
CardType::Default => Rgb565::new(0xD8, 0x68, 0x30),
CardType::Blueprint => Rgb565::new(0x6D, 0x81, 0xFF),
CardType::CYBER => Rgb565::new(0xFF, 0xFF, 0x04),
CardType::Nature => Rgb565::new(0x55, 0xA0, 0x58),
CardType::Fossil => Rgb565::new(0xB9, 0x7A, 0x60),
CardType::Ghost => Rgb565::new(0xAB, 0xAB, 0xAB),
CardType::Daemon => Rgb565::new(0x60, 0x00, 0x88),
CardType::Fairy => Rgb565::new(0xB0, 0xA9, 0xE4),
CardType::Default => Rgb888::new(0xD8, 0x68, 0x30).into(),
CardType::Blueprint => Rgb888::new(0x6D, 0x81, 0xFF).into(),
CardType::CYBER => Rgb888::new(0xFF, 0xFF, 0x04).into(),
CardType::Nature => Rgb888::new(0x55, 0xA0, 0x58).into(),
CardType::Fossil => Rgb888::new(0xB9, 0x7A, 0x60).into(),
CardType::Ghost => Rgb888::new(0xAB, 0xAB, 0xAB).into(),
CardType::Daemon => Rgb888::new(0x60, 0x00, 0x88).into(),
CardType::Fairy => Rgb888::new(0xB0, 0xA9, 0xE4).into(),
}
}
}
@@ -68,148 +68,148 @@ impl Into<Palette> for CardType {
fn into(self) -> Palette {
match self {
CardType::Default => [
Rgb565::new(31, 23, 35),
Rgb565::new(60, 47, 82),
Rgb565::new(178, 39, 65),
Rgb565::new(70, 86, 165),
Rgb565::new(245, 70, 76),
Rgb565::new(216, 104, 48),
Rgb565::new(140, 127, 144),
Rgb565::new(73, 149, 243),
Rgb565::new(62, 197, 75),
Rgb565::new(240, 149, 72),
Rgb565::new(188, 176, 179),
Rgb565::new(247, 156, 136),
Rgb565::new(114, 222, 235),
Rgb565::new(180, 230, 86),
Rgb565::new(239, 208, 129),
Rgb565::new(255, 255, 255),
Rgb888::new(31, 23, 35).into(),
Rgb888::new(60, 47, 82).into(),
Rgb888::new(178, 39, 65).into(),
Rgb888::new(70, 86, 165).into(),
Rgb888::new(245, 70, 76).into(),
Rgb888::new(216, 104, 48).into(),
Rgb888::new(140, 127, 144).into(),
Rgb888::new(73, 149, 243).into(),
Rgb888::new(62, 197, 75).into(),
Rgb888::new(240, 149, 72).into(),
Rgb888::new(188, 176, 179).into(),
Rgb888::new(247, 156, 136).into(),
Rgb888::new(114, 222, 235).into(),
Rgb888::new(180, 230, 86).into(),
Rgb888::new(239, 208, 129).into(),
Rgb888::new(255, 255, 255).into(),
],
CardType::Blueprint => [
Rgb565::new(83, 67, 127),
Rgb565::new(44, 111, 153),
Rgb565::new(142, 88, 111),
Rgb565::new(0, 188, 170),
Rgb565::new(153, 104, 226),
Rgb565::new(109, 129, 255),
Rgb565::new(255, 84, 112),
Rgb565::new(196, 143, 158),
Rgb565::new(168, 159, 204),
Rgb565::new(190, 155, 255),
Rgb565::new(255, 155, 113),
Rgb565::new(127, 206, 255),
Rgb565::new(255, 155, 182),
Rgb565::new(255, 217, 174),
Rgb565::new(255, 217, 232),
Rgb565::new(255, 255, 255),
Rgb888::new(83, 67, 127).into(),
Rgb888::new(44, 111, 153).into(),
Rgb888::new(142, 88, 111).into(),
Rgb888::new(0, 188, 170).into(),
Rgb888::new(153, 104, 226).into(),
Rgb888::new(109, 129, 255).into(),
Rgb888::new(255, 84, 112).into(),
Rgb888::new(196, 143, 158).into(),
Rgb888::new(168, 159, 204).into(),
Rgb888::new(190, 155, 255).into(),
Rgb888::new(255, 155, 113).into(),
Rgb888::new(127, 206, 255).into(),
Rgb888::new(255, 155, 182).into(),
Rgb888::new(255, 217, 174).into(),
Rgb888::new(255, 217, 232).into(),
Rgb888::new(255, 255, 255).into(),
],
CardType::CYBER => [
Rgb565::new(0, 0, 0),
Rgb565::new(0, 0, 126),
Rgb565::new(0, 0, 255),
Rgb565::new(126, 0, 0),
Rgb565::new(126, 0, 126),
Rgb565::new(4, 126, 0),
Rgb565::new(254, 0, 0),
Rgb565::new(4, 126, 126),
Rgb565::new(254, 0, 255),
Rgb565::new(126, 126, 0),
Rgb565::new(126, 126, 126),
Rgb565::new(6, 255, 4),
Rgb565::new(6, 255, 255),
Rgb565::new(190, 190, 190),
Rgb565::new(255, 255, 4),
Rgb565::new(255, 255, 255),
Rgb888::new(0, 0, 0).into(),
Rgb888::new(0, 0, 126).into(),
Rgb888::new(0, 0, 255).into(),
Rgb888::new(126, 0, 0).into(),
Rgb888::new(126, 0, 126).into(),
Rgb888::new(4, 126, 0).into(),
Rgb888::new(254, 0, 0).into(),
Rgb888::new(4, 126, 126).into(),
Rgb888::new(254, 0, 255).into(),
Rgb888::new(126, 126, 0).into(),
Rgb888::new(126, 126, 126).into(),
Rgb888::new(6, 255, 4).into(),
Rgb888::new(6, 255, 255).into(),
Rgb888::new(190, 190, 190).into(),
Rgb888::new(255, 255, 4).into(),
Rgb888::new(255, 255, 255).into(),
],
CardType::Nature => [
Rgb565::new(35, 34, 40),
Rgb565::new(40, 66, 97),
Rgb565::new(30, 116, 83),
Rgb565::new(117, 77, 69),
Rgb565::new(95, 88, 84),
Rgb565::new(36, 133, 166),
Rgb565::new(198, 80, 70),
Rgb565::new(85, 160, 88),
Rgb565::new(135, 133, 115),
Rgb565::new(84, 186, 210),
Rgb565::new(161, 191, 65),
Rgb565::new(230, 146, 138),
Rgb565::new(184, 176, 149),
Rgb565::new(227, 192, 84),
Rgb565::new(195, 213, 199),
Rgb565::new(255, 255, 255),
Rgb888::new(35, 34, 40).into(),
Rgb888::new(40, 66, 97).into(),
Rgb888::new(30, 116, 83).into(),
Rgb888::new(117, 77, 69).into(),
Rgb888::new(95, 88, 84).into(),
Rgb888::new(36, 133, 166).into(),
Rgb888::new(198, 80, 70).into(),
Rgb888::new(85, 160, 88).into(),
Rgb888::new(135, 133, 115).into(),
Rgb888::new(84, 186, 210).into(),
Rgb888::new(161, 191, 65).into(),
Rgb888::new(230, 146, 138).into(),
Rgb888::new(184, 176, 149).into(),
Rgb888::new(227, 192, 84).into(),
Rgb888::new(195, 213, 199).into(),
Rgb888::new(255, 255, 255).into(),
],
CardType::Fossil => [
Rgb565::new(75, 61, 68),
Rgb565::new(119, 66, 81),
Rgb565::new(78, 84, 99),
Rgb565::new(100, 83, 85),
Rgb565::new(156, 82, 78),
Rgb565::new(132, 109, 89),
Rgb565::new(91, 125, 115),
Rgb565::new(125, 123, 98),
Rgb565::new(140, 124, 121),
Rgb565::new(185, 122, 96),
Rgb565::new(168, 138, 94),
Rgb565::new(142, 159, 125),
Rgb565::new(170, 162, 93),
Rgb565::new(169, 156, 141),
Rgb565::new(204, 168, 123),
Rgb565::new(255, 255, 255),
Rgb888::new(75, 61, 68).into(),
Rgb888::new(119, 66, 81).into(),
Rgb888::new(78, 84, 99).into(),
Rgb888::new(100, 83, 85).into(),
Rgb888::new(156, 82, 78).into(),
Rgb888::new(132, 109, 89).into(),
Rgb888::new(91, 125, 115).into(),
Rgb888::new(125, 123, 98).into(),
Rgb888::new(140, 124, 121).into(),
Rgb888::new(185, 122, 96).into(),
Rgb888::new(168, 138, 94).into(),
Rgb888::new(142, 159, 125).into(),
Rgb888::new(170, 162, 93).into(),
Rgb888::new(169, 156, 141).into(),
Rgb888::new(204, 168, 123).into(),
Rgb888::new(255, 255, 255).into(),
],
CardType::Ghost => [
Rgb565::new(0, 0, 0),
Rgb565::new(24, 24, 24),
Rgb565::new(40, 40, 40),
Rgb565::new(56, 56, 56),
Rgb565::new(71, 71, 71),
Rgb565::new(86, 86, 86),
Rgb565::new(100, 100, 100),
Rgb565::new(113, 113, 113),
Rgb565::new(126, 126, 126),
Rgb565::new(140, 140, 140),
Rgb565::new(155, 155, 155),
Rgb565::new(171, 171, 171),
Rgb565::new(189, 189, 189),
Rgb565::new(209, 209, 209),
Rgb565::new(231, 231, 231),
Rgb565::new(255, 255, 255),
Rgb888::new(0, 0, 0).into(),
Rgb888::new(24, 24, 24).into(),
Rgb888::new(40, 40, 40).into(),
Rgb888::new(56, 56, 56).into(),
Rgb888::new(71, 71, 71).into(),
Rgb888::new(86, 86, 86).into(),
Rgb888::new(100, 100, 100).into(),
Rgb888::new(113, 113, 113).into(),
Rgb888::new(126, 126, 126).into(),
Rgb888::new(140, 140, 140).into(),
Rgb888::new(155, 155, 155).into(),
Rgb888::new(171, 171, 171).into(),
Rgb888::new(189, 189, 189).into(),
Rgb888::new(209, 209, 209).into(),
Rgb888::new(231, 231, 231).into(),
Rgb888::new(255, 255, 255).into(),
],
CardType::Daemon => [
Rgb565::new(0, 3, 60),
Rgb565::new(96, 0, 136),
Rgb565::new(0, 56, 132),
Rgb565::new(42, 46, 121),
Rgb565::new(0, 82, 96),
Rgb565::new(177, 5, 133),
Rgb565::new(255, 0, 78),
Rgb565::new(172, 41, 206),
Rgb565::new(0, 157, 74),
Rgb565::new(0, 138, 197),
Rgb565::new(78, 110, 168),
Rgb565::new(255, 92, 255),
Rgb565::new(10, 255, 82),
Rgb565::new(0, 247, 255),
Rgb565::new(173, 212, 250),
Rgb565::new(255, 255, 255),
Rgb888::new(0, 3, 60).into(),
Rgb888::new(96, 0, 136).into(),
Rgb888::new(0, 56, 132).into(),
Rgb888::new(42, 46, 121).into(),
Rgb888::new(0, 82, 96).into(),
Rgb888::new(177, 5, 133).into(),
Rgb888::new(255, 0, 78).into(),
Rgb888::new(172, 41, 206).into(),
Rgb888::new(0, 157, 74).into(),
Rgb888::new(0, 138, 197).into(),
Rgb888::new(78, 110, 168).into(),
Rgb888::new(255, 92, 255).into(),
Rgb888::new(10, 255, 82).into(),
Rgb888::new(0, 247, 255).into(),
Rgb888::new(173, 212, 250).into(),
Rgb888::new(255, 255, 255).into(),
],
CardType::Fairy => [
Rgb565::new(40, 40, 46),
Rgb565::new(108, 86, 113),
Rgb565::new(135, 168, 137),
Rgb565::new(249, 130, 132),
Rgb565::new(176, 169, 228),
Rgb565::new(222, 163, 139),
Rgb565::new(172, 204, 228),
Rgb565::new(254, 170, 228),
Rgb565::new(217, 200, 191),
Rgb565::new(255, 195, 132),
Rgb565::new(176, 235, 147),
Rgb565::new(179, 227, 218),
Rgb565::new(233, 245, 157),
Rgb565::new(255, 230, 198),
Rgb565::new(255, 247, 160),
Rgb565::new(255, 255, 255),
Rgb888::new(40, 40, 46).into(),
Rgb888::new(108, 86, 113).into(),
Rgb888::new(135, 168, 137).into(),
Rgb888::new(249, 130, 132).into(),
Rgb888::new(176, 169, 228).into(),
Rgb888::new(222, 163, 139).into(),
Rgb888::new(172, 204, 228).into(),
Rgb888::new(254, 170, 228).into(),
Rgb888::new(217, 200, 191).into(),
Rgb888::new(255, 195, 132).into(),
Rgb888::new(176, 235, 147).into(),
Rgb888::new(179, 227, 218).into(),
Rgb888::new(233, 245, 157).into(),
Rgb888::new(255, 230, 198).into(),
Rgb888::new(255, 247, 160).into(),
Rgb888::new(255, 255, 255).into(),
],
}
}
-1
View File
@@ -1,4 +1,3 @@
pub mod palette;
pub mod primary_lcd;
pub mod secondary_oled;
pub mod sprite;
-17
View File
@@ -1,17 +0,0 @@
use embedded_graphics::pixelcolor::Rgb565;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Rgb(pub u8, pub u8, pub u8);
impl Rgb {
pub fn into_rgb565(self) -> Rgb565 {
Rgb565::new(self.0, self.1, self.2)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct TypeStyle {
pub name: &'static str,
pub primary: Rgb,
pub text: Rgb,
}
+1 -7
View File
@@ -1,5 +1,4 @@
use crate::card::model::Palette;
use crate::display::palette::Rgb;
use embedded_graphics::{
geometry::Size, pixelcolor::Rgb565, pixelcolor::RgbColor, prelude::Point, primitives::Rectangle,
};
@@ -14,11 +13,6 @@ where
return;
}
// OPTIMIZATION 1: Pre-compute the 16-color palette to Rgb565 once.
let mut palette565 = [Rgb565::new(0, 0, 0); 16];
for (i, c) in palette.iter().enumerate() {
palette565[i] = Rgb565::new(c.r() >> 3, c.g() >> 2, c.b() >> 3);
}
let mut src_width = 1usize;
while src_width * src_width < pixel_count {
@@ -44,7 +38,7 @@ where
pixel_byte & 0x0F
};
let color = palette565[color_index as usize];
let color = palette[color_index as usize];
let start_x = (x * scale) as i32;
let start_y = (y * scale) as i32;
+1 -2
View File
@@ -1,5 +1,4 @@
use esp_hal::gpio::{Input, InputConfig, Pull};
use esp_hal::peripherals::Peripherals;
use esp_hal::gpio::Input;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NavCommand {
+1 -1
View File
@@ -1,5 +1,5 @@
use crate::display::sprite::render_sprite_onto_ili9341;
use alloc::{format, string::String};
use alloc::format;
use embedded_graphics::mono_font::MonoTextStyle;
use embedded_graphics::mono_font::ascii::FONT_6X10;
use embedded_graphics::pixelcolor::Rgb565;
+2 -2
View File
@@ -2,7 +2,7 @@ use alloc::vec;
use core::future;
use crate::card::model::Card;
use crate::card::{decoder::split_nfc_hex, mock::MOCK_PAYLOAD, mock::MOCK_PAYLOAD2};
use crate::card::{decoder::split_nfc_hex, mock::*};
use crate::display::primary_lcd::PrimaryLcdDisplay;
use crate::views::card_view::CardView;
@@ -36,7 +36,7 @@ impl Navigable for MainMenu {
}
fn handle_input(&self, input: Action) -> impl core::future::Future<Output = View> + Send {
let card_mock1 = Card::try_from(split_nfc_hex(&MOCK_PAYLOAD).unwrap()).unwrap();
let card_mock1 = Card::try_from(split_nfc_hex(&MOCK_PAYLOAD3).unwrap()).unwrap();
let card_mock2 = Card::try_from(split_nfc_hex(&MOCK_PAYLOAD2).unwrap()).unwrap();
let new_menu = match input {
+1 -2
View File
@@ -4,8 +4,7 @@ use embedded_graphics::pixelcolor::Rgb565;
use embedded_graphics::prelude::Point;
use embedded_graphics::prelude::RgbColor;
use embedded_graphics::text::Text;
use embedded_graphics::{Drawable, geometry::Size, primitives::Rectangle};
use embedded_graphics_core::draw_target::DrawTarget;
use embedded_graphics::Drawable;
use crate::display::primary_lcd::PrimaryLcdDisplay;
+1 -1
View File
@@ -25,7 +25,7 @@ impl Navigable for SettingsMenu {
core::future::ready(())
}
fn handle_input(&self, input: Action) -> impl core::future::Future<Output = View> + Send {
fn handle_input(&self, _input: Action) -> impl core::future::Future<Output = View> + Send {
async move { View::Settings(SettingsMenu { selected: 0 }) }
}
}