Triple oled #37
Generated
+1
-2
@@ -1702,8 +1702,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
[[package]]
|
||||
name = "i2c-character-display"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86a620ec16541e28c0e52ce21cd23d734a5d7efaae3d609b2a58694b0ef67739"
|
||||
source = "git+https://github.com/ede1998/i2c-character-display.git?rev=57aef1f49da183c120b8e995ef77549e3515d3c6#57aef1f49da183c120b8e995ef77549e3515d3c6"
|
||||
dependencies = [
|
||||
"bitfield 0.17.0",
|
||||
"embedded-hal 1.0.0",
|
||||
|
||||
@@ -52,6 +52,7 @@ ch1115 = { version = "0.1.2", features = ["graphics"] }
|
||||
|
||||
[patch.crates-io]
|
||||
ch1115 = { git = "https://github.com/ede1998/ch1115.git", rev = "2d3a3ba38050efe012e6a210afe3e125ec280c37" }
|
||||
i2c-character-display = { git = "https://github.com/ede1998/i2c-character-display.git", rev = "57aef1f49da183c120b8e995ef77549e3515d3c6" }
|
||||
|
||||
# For fine tuning these settings, please refer to https://doc.rust-lang.org/cargo/reference/profiles.html
|
||||
[profile.dev]
|
||||
|
||||
@@ -8,8 +8,6 @@ use crate::views::view::View;
|
||||
use embassy_futures::select::{Either, select};
|
||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
use embassy_time::{Duration, Timer};
|
||||
use embedded_graphics::draw_target::DrawTarget;
|
||||
use embedded_graphics::pixelcolor::Rgb565;
|
||||
|
||||
pub type Mutex<T> = embassy_sync::mutex::Mutex<CriticalSectionRawMutex, T>;
|
||||
pub type Signal<T> = embassy_sync::signal::Signal<CriticalSectionRawMutex, T>;
|
||||
@@ -29,11 +27,7 @@ pub struct NewState {
|
||||
}
|
||||
|
||||
pub trait Navigable {
|
||||
fn display<D>(&self, display: &mut D) -> impl core::future::Future<Output = ()> + Send
|
||||
where
|
||||
D: DrawTarget<Color = Rgb565> + Send,
|
||||
D::Error: core::fmt::Debug;
|
||||
// fn display<D>(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send;
|
||||
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send;
|
||||
fn handle_input(&self, input: Action) -> impl core::future::Future<Output = NewState> + Send;
|
||||
}
|
||||
|
||||
@@ -42,7 +36,7 @@ pub async fn run(mut inputs: Inputs, mut outputs: Outputs) {
|
||||
log::info!("starting navigation");
|
||||
|
||||
let mut state = NavigationState::new();
|
||||
state.screens.last().unwrap().display(&mut outputs.primary_display).await;
|
||||
state.screens.last().unwrap().display(&mut outputs).await;
|
||||
|
||||
loop {
|
||||
let selection = select(
|
||||
@@ -88,7 +82,7 @@ pub async fn run(mut inputs: Inputs, mut outputs: Outputs) {
|
||||
state.screens.push(new_state.view);
|
||||
|
||||
if action != Action::Timer || new_state.redraw {
|
||||
state.screens.last().unwrap().display(&mut outputs.primary_display).await;
|
||||
state.screens.last().unwrap().display(&mut outputs).await;
|
||||
}
|
||||
|
||||
Timer::after(Duration::from_millis(DEBOUNCE_DURATION_MILLIS)).await;
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
use crate::display::{shared_bus::{DualPrimaryDisplay, DualSecondaryDisplay}, tertiary_lcd::TertiaryI2cLcd};
|
||||
|
||||
use embedded_graphics::{
|
||||
draw_target::DrawTarget as _,
|
||||
pixelcolor::{Rgb565, RgbColor as _},
|
||||
};
|
||||
|
||||
use crate::display::{
|
||||
shared_bus::{DualPrimaryDisplay, DualSecondaryDisplay},
|
||||
tertiary_lcd::TertiaryI2cLcd,
|
||||
};
|
||||
|
||||
pub struct Outputs {
|
||||
pub primary_display: DualPrimaryDisplay<'static>,
|
||||
@@ -10,3 +16,13 @@ pub struct Outputs {
|
||||
pub tertiary_display: TertiaryI2cLcd<'static>,
|
||||
pub _led_a: (),
|
||||
}
|
||||
|
||||
impl Outputs {
|
||||
pub fn clear_screens(&mut self) {
|
||||
self.primary_display.clear(Rgb565::BLACK).unwrap();
|
||||
self.secondary_display_1.clear().unwrap();
|
||||
// self.secondary_display_2.clear().unwrap();
|
||||
// self.secondary_display_3.clear().unwrap();
|
||||
self.tertiary_display.clear().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
+68
-70
@@ -1,5 +1,6 @@
|
||||
use crate::display::sprite::render_sprite_onto_ili9341;
|
||||
use crate::navigation::navigation::NewState;
|
||||
use crate::navigation::outputs::Outputs;
|
||||
use alloc::format;
|
||||
use embedded_graphics::mono_font::MonoTextStyle;
|
||||
use embedded_graphics::mono_font::ascii::FONT_6X10;
|
||||
@@ -24,80 +25,77 @@ pub struct CardView {
|
||||
}
|
||||
|
||||
impl Navigable for CardView {
|
||||
fn display<D>(&self, display: &mut D) -> impl core::future::Future<Output = ()> + Send
|
||||
where
|
||||
D: DrawTarget<Color = Rgb565>,
|
||||
D::Error: core::fmt::Debug,
|
||||
{
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send {
|
||||
async move {
|
||||
let display = &mut outputs.primary_display;
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
|
||||
let background = Rectangle::new(Point::new(0, 0), Size::new(240, 320));
|
||||
let bg_color = self.card.cardtype.clone().into();
|
||||
let background = Rectangle::new(Point::new(0, 0), Size::new(240, 320));
|
||||
let bg_color = self.card.cardtype.clone().into();
|
||||
|
||||
let _ = display.fill_solid(&background, bg_color);
|
||||
let _ = display.fill_solid(&background, bg_color);
|
||||
|
||||
let style = MonoTextStyle::new(&FONT_6X10, Rgb565::WHITE);
|
||||
Text::new(
|
||||
&format!("Name: {}", self.card.name),
|
||||
Point::new(20, 240),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("Type: {}", self.card.cardtype),
|
||||
Point::new(20, 250),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("Event: {}", self.card.event),
|
||||
Point::new(20, 260),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("UUID: {}", self.card.uuid),
|
||||
Point::new(20, 270),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("Trait1: {}", self.card.trait1),
|
||||
Point::new(20, 280),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("Trait2: {}", self.card.trait2),
|
||||
Point::new(20, 290),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("Trait3: {}", self.card.trait3),
|
||||
Point::new(20, 300),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("Secret: {}", self.card.secret),
|
||||
Point::new(20, 310),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
let style = MonoTextStyle::new(&FONT_6X10, Rgb565::WHITE);
|
||||
Text::new(
|
||||
&format!("Name: {}", self.card.name),
|
||||
Point::new(20, 240),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("Type: {}", self.card.cardtype),
|
||||
Point::new(20, 250),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("Event: {}", self.card.event),
|
||||
Point::new(20, 260),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("UUID: {}", self.card.uuid),
|
||||
Point::new(20, 270),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("Trait1: {}", self.card.trait1),
|
||||
Point::new(20, 280),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("Trait2: {}", self.card.trait2),
|
||||
Point::new(20, 290),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("Trait3: {}", self.card.trait3),
|
||||
Point::new(20, 300),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
Text::new(
|
||||
&format!("Secret: {}", self.card.secret),
|
||||
Point::new(20, 310),
|
||||
style,
|
||||
)
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
|
||||
let palette: Palette = self.card.cardtype.clone().into();
|
||||
render_sprite_onto_ili9341(display, self.card.sprite.data.as_slice(), &palette);
|
||||
|
||||
core::future::ready(())
|
||||
let palette: Palette = self.card.cardtype.clone().into();
|
||||
render_sprite_onto_ili9341(display, self.card.sprite.data.as_slice(), &palette);
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_input(&self, input: Action) -> impl core::future::Future<Output = NewState> + Send {
|
||||
|
||||
@@ -7,9 +7,7 @@ use embedded_graphics::prelude::RgbColor;
|
||||
use embedded_graphics_core::draw_target::DrawTarget;
|
||||
|
||||
use crate::{
|
||||
card::model::Card,
|
||||
navigation::navigation::{Action, Navigable, NewState},
|
||||
views::view::View,
|
||||
card::model::Card, navigation::{navigation::{Action, Navigable, NewState}, outputs::Outputs}, views::view::View,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -19,14 +17,10 @@ pub struct JournalView {
|
||||
}
|
||||
|
||||
impl Navigable for JournalView {
|
||||
fn display<D>(&self, display: &mut D) -> impl core::future::Future<Output = ()> + Send
|
||||
where
|
||||
D: DrawTarget<Color = Rgb565>,
|
||||
D::Error: core::fmt::Debug,
|
||||
{
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
|
||||
core::future::ready(())
|
||||
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send {
|
||||
async move {
|
||||
outputs.primary_display.clear(Rgb565::BLACK).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_input(&self, input: Action) -> impl core::future::Future<Output = NewState> + Send {
|
||||
|
||||
@@ -4,6 +4,7 @@ use crate::card::model::Card;
|
||||
use crate::card::{decoder::split_nfc_hex, mock::*};
|
||||
|
||||
use crate::navigation::inputs::ButtonAction;
|
||||
use crate::navigation::outputs::Outputs;
|
||||
use crate::views::card_view::CardView;
|
||||
use crate::views::journal_view::JournalView;
|
||||
use crate::views::{menu_item, settings_menu::SettingsMenu, view::View};
|
||||
@@ -21,11 +22,9 @@ pub struct MainMenu {
|
||||
}
|
||||
|
||||
impl Navigable for MainMenu {
|
||||
fn display<D>(&self, display: &mut D) -> impl core::future::Future<Output = ()> + Send
|
||||
where
|
||||
D: DrawTarget<Color = Rgb565>,
|
||||
D::Error: core::fmt::Debug,
|
||||
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send
|
||||
{
|
||||
let display = &mut outputs.primary_display;
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
|
||||
menu_item::show(display, "Scan card", 0, self.selected);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
use crate::navigation::inputs::ButtonAction;
|
||||
use crate::navigation::navigation::CARD_DATA;
|
||||
use crate::navigation::navigation::NewState;
|
||||
use crate::navigation::outputs::Outputs;
|
||||
|
||||
use alloc::format;
|
||||
use embedded_graphics::Drawable;
|
||||
use embedded_graphics::geometry::AngleUnit as _;
|
||||
use embedded_graphics::geometry::Dimensions as _;
|
||||
use embedded_graphics::geometry::Size;
|
||||
use embedded_graphics::mono_font::MonoTextStyle;
|
||||
use embedded_graphics::mono_font::ascii::FONT_10X20;
|
||||
@@ -31,11 +33,9 @@ pub struct ScanMenu {
|
||||
}
|
||||
|
||||
impl Navigable for ScanMenu {
|
||||
fn display<D>(&self, display: &mut D) -> impl core::future::Future<Output = ()> + Send
|
||||
where
|
||||
D: DrawTarget<Color = Rgb565>,
|
||||
D::Error: core::fmt::Debug,
|
||||
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send
|
||||
{
|
||||
let display = &mut outputs.primary_display;
|
||||
let style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::navigation::navigation::{Action, Navigable, NewState};
|
||||
use crate::navigation::outputs::Outputs;
|
||||
use crate::views::{menu_item, view::View};
|
||||
|
||||
use embedded_graphics::pixelcolor::Rgb565;
|
||||
@@ -12,11 +13,8 @@ pub struct SettingsMenu {
|
||||
}
|
||||
|
||||
impl Navigable for SettingsMenu {
|
||||
fn display<D>(&self, display: &mut D) -> impl core::future::Future<Output = ()> + Send
|
||||
where
|
||||
D: DrawTarget<Color = Rgb565>,
|
||||
D::Error: core::fmt::Debug,
|
||||
{
|
||||
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send {
|
||||
let display = &mut outputs.primary_display;
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
menu_item::show(display, "System Inforation", 0, self.selected);
|
||||
menu_item::show(display, "Wifi Information", 1, self.selected);
|
||||
|
||||
+7
-11
@@ -1,6 +1,5 @@
|
||||
use embedded_graphics::draw_target::DrawTarget;
|
||||
use embedded_graphics::pixelcolor::Rgb565;
|
||||
|
||||
use crate::navigation::outputs::Outputs;
|
||||
use crate::views::card_view::CardView;
|
||||
use crate::views::{
|
||||
journal_view::JournalView, main_menu::MainMenu, scan_menu::ScanMenu,
|
||||
@@ -19,18 +18,15 @@ pub enum View {
|
||||
}
|
||||
|
||||
impl Navigable for View {
|
||||
fn display<D>(&self, display: &mut D) -> impl core::future::Future<Output = ()> + Send
|
||||
where
|
||||
D: DrawTarget<Color = Rgb565> + Send,
|
||||
D::Error: core::fmt::Debug,
|
||||
fn display(&self, outputs: &mut Outputs) -> impl core::future::Future<Output = ()> + Send
|
||||
{
|
||||
async move {
|
||||
match self {
|
||||
View::Main(main_menu) => main_menu.display(display).await,
|
||||
View::Scan(scan_menu) => scan_menu.display(display).await,
|
||||
View::Settings(settings_menu) => settings_menu.display(display).await,
|
||||
View::Journal(journal_view) => journal_view.display(display).await,
|
||||
View::Card(card_view) => card_view.display(display).await,
|
||||
View::Main(main_menu) => main_menu.display(outputs).await,
|
||||
View::Scan(scan_menu) => scan_menu.display(outputs).await,
|
||||
View::Settings(settings_menu) => settings_menu.display(outputs).await,
|
||||
View::Journal(journal_view) => journal_view.display(outputs).await,
|
||||
View::Card(card_view) => card_view.display(outputs).await,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user