OLED driver with shared SPI bus integrated
This commit was merged in pull request #35.
This commit is contained in:
@@ -14,7 +14,6 @@ use core::future;
|
||||
|
||||
use crate::{
|
||||
card::model::{Card, Palette},
|
||||
display::primary_lcd::PrimaryLcdDisplay,
|
||||
navigation::navigation::{Action, Navigable},
|
||||
views::view::View,
|
||||
};
|
||||
@@ -25,10 +24,11 @@ pub struct CardView {
|
||||
}
|
||||
|
||||
impl Navigable for CardView {
|
||||
fn display(
|
||||
&self,
|
||||
display: &mut PrimaryLcdDisplay<'static>,
|
||||
) -> impl core::future::Future<Output = ()> + Send {
|
||||
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();
|
||||
|
||||
let background = Rectangle::new(Point::new(0, 0), Size::new(240, 320));
|
||||
|
||||
@@ -7,7 +7,9 @@ use embedded_graphics::prelude::RgbColor;
|
||||
use embedded_graphics_core::draw_target::DrawTarget;
|
||||
|
||||
use crate::{
|
||||
card::model::Card, display::primary_lcd::PrimaryLcdDisplay, navigation::navigation::{Action, Navigable, NewState}, views::view::View,
|
||||
card::model::Card,
|
||||
navigation::navigation::{Action, Navigable, NewState},
|
||||
views::view::View,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -17,10 +19,11 @@ pub struct JournalView {
|
||||
}
|
||||
|
||||
impl Navigable for JournalView {
|
||||
fn display(
|
||||
&self,
|
||||
display: &mut PrimaryLcdDisplay<'static>,
|
||||
) -> impl core::future::Future<Output = ()> + Send {
|
||||
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(())
|
||||
|
||||
@@ -2,7 +2,6 @@ use alloc::vec;
|
||||
|
||||
use crate::card::model::Card;
|
||||
use crate::card::{decoder::split_nfc_hex, mock::*};
|
||||
use crate::display::primary_lcd::PrimaryLcdDisplay;
|
||||
|
||||
use crate::navigation::inputs::ButtonAction;
|
||||
use crate::views::card_view::CardView;
|
||||
@@ -22,10 +21,11 @@ pub struct MainMenu {
|
||||
}
|
||||
|
||||
impl Navigable for MainMenu {
|
||||
fn display(
|
||||
&self,
|
||||
display: &mut PrimaryLcdDisplay<'static>,
|
||||
) -> impl core::future::Future<Output = ()> + Send {
|
||||
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();
|
||||
|
||||
menu_item::show(display, "Scan card", 0, self.selected);
|
||||
|
||||
+7
-10
@@ -1,19 +1,17 @@
|
||||
use embedded_graphics::Drawable;
|
||||
use embedded_graphics::draw_target::DrawTarget;
|
||||
use embedded_graphics::mono_font::MonoTextStyle;
|
||||
use embedded_graphics::mono_font::ascii::FONT_10X20;
|
||||
use embedded_graphics::pixelcolor::Rgb565;
|
||||
use embedded_graphics::prelude::Point;
|
||||
use embedded_graphics::prelude::RgbColor;
|
||||
use embedded_graphics::text::Text;
|
||||
use embedded_graphics::Drawable;
|
||||
|
||||
use crate::display::primary_lcd::PrimaryLcdDisplay;
|
||||
|
||||
pub fn show<'a>(
|
||||
display: &mut PrimaryLcdDisplay<'static>,
|
||||
name: &str,
|
||||
position: i32,
|
||||
selected: i32,
|
||||
) {
|
||||
pub fn show<'a, D>(display: &mut D, name: &str, position: i32, selected: i32)
|
||||
where
|
||||
D: DrawTarget<Color = Rgb565>,
|
||||
D::Error: core::fmt::Debug,
|
||||
{
|
||||
let style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
|
||||
let selected_style = MonoTextStyle::new(&FONT_10X20, Rgb565::BLUE);
|
||||
|
||||
@@ -29,4 +27,3 @@ pub fn show<'a>(
|
||||
.draw(display)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use crate::display::primary_lcd::PrimaryLcdDisplay;
|
||||
use crate::navigation::inputs::ButtonAction;
|
||||
use crate::navigation::navigation::CARD_DATA;
|
||||
use crate::navigation::navigation::NewState;
|
||||
@@ -6,7 +5,6 @@ use crate::navigation::navigation::NewState;
|
||||
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;
|
||||
@@ -33,10 +31,11 @@ pub struct ScanMenu {
|
||||
}
|
||||
|
||||
impl Navigable for ScanMenu {
|
||||
fn display(
|
||||
&self,
|
||||
display: &mut PrimaryLcdDisplay<'static>,
|
||||
) -> impl core::future::Future<Output = ()> + Send {
|
||||
fn display<D>(&self, display: &mut D) -> impl core::future::Future<Output = ()> + Send
|
||||
where
|
||||
D: DrawTarget<Color = Rgb565>,
|
||||
D::Error: core::fmt::Debug,
|
||||
{
|
||||
let style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
|
||||
display.clear(Rgb565::BLACK).unwrap();
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use crate::display::primary_lcd::PrimaryLcdDisplay;
|
||||
|
||||
use crate::navigation::navigation::{Action, Navigable, NewState};
|
||||
use crate::views::{menu_item, view::View};
|
||||
|
||||
@@ -14,10 +12,11 @@ pub struct SettingsMenu {
|
||||
}
|
||||
|
||||
impl Navigable for SettingsMenu {
|
||||
fn display(
|
||||
&self,
|
||||
display: &mut PrimaryLcdDisplay<'static>,
|
||||
) -> impl core::future::Future<Output = ()> + Send {
|
||||
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();
|
||||
menu_item::show(display, "System Inforation", 0, self.selected);
|
||||
menu_item::show(display, "Wifi Information", 1, self.selected);
|
||||
|
||||
+8
-4
@@ -1,3 +1,6 @@
|
||||
use embedded_graphics::draw_target::DrawTarget;
|
||||
use embedded_graphics::pixelcolor::Rgb565;
|
||||
|
||||
use crate::views::card_view::CardView;
|
||||
use crate::views::{
|
||||
journal_view::JournalView, main_menu::MainMenu, scan_menu::ScanMenu,
|
||||
@@ -16,10 +19,11 @@ pub enum View {
|
||||
}
|
||||
|
||||
impl Navigable for View {
|
||||
fn display(
|
||||
&self,
|
||||
display: &mut crate::display::primary_lcd::PrimaryLcdDisplay<'static>,
|
||||
) -> impl core::future::Future<Output = ()> + Send {
|
||||
fn display<D>(&self, display: &mut D) -> impl core::future::Future<Output = ()> + Send
|
||||
where
|
||||
D: DrawTarget<Color = Rgb565> + Send,
|
||||
D::Error: core::fmt::Debug,
|
||||
{
|
||||
async move {
|
||||
match self {
|
||||
View::Main(main_menu) => main_menu.display(display).await,
|
||||
|
||||
Reference in New Issue
Block a user