-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2398051
commit f353f61
Showing
19 changed files
with
414 additions
and
240 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "app-menu" | ||
name = "keyboard" | ||
version = "0.1.0" | ||
edition = "2024" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#![no_std] | ||
|
||
use core::fmt::Debug; | ||
|
||
use embedded_graphics::{ | ||
draw_target::DrawTarget, | ||
// mono_font::{MonoTextStyle, ascii::FONT_10X20}, | ||
pixelcolor::BinaryColor, | ||
prelude::*, | ||
primitives::PrimitiveStyle, | ||
// text::{Alignment, Text}, | ||
}; | ||
use shared::{Application, Key, KeyEvent}; | ||
|
||
pub struct Keyboard; | ||
|
||
impl Keyboard { | ||
pub fn new() -> Self { | ||
Self | ||
} | ||
} | ||
|
||
impl Default for Keyboard { | ||
fn default() -> Self { | ||
Self | ||
} | ||
} | ||
|
||
impl Application for Keyboard { | ||
async fn run<D: DrawTarget<Color = BinaryColor>>( | ||
&mut self, | ||
_vibration_motor: &mut impl shared::VibrationMotor, | ||
_buzzer: &mut impl shared::Buzzer, | ||
display: &mut D, | ||
keypad: &mut impl shared::Keypad, | ||
_rtc: &mut impl shared::Rtc, | ||
_backlight: &mut impl shared::Backlight, | ||
_system_response: Option<[u8; 64]>, | ||
) -> Option<shared::UsbTx> | ||
where | ||
<D as DrawTarget>::Error: Debug, | ||
{ | ||
let fill = PrimitiveStyle::with_fill(BinaryColor::Off); | ||
display | ||
.bounding_box() | ||
.into_styled(fill) | ||
.draw(display) | ||
.unwrap(); | ||
|
||
// let character_style = MonoTextStyle::new(&FONT_10X20, BinaryColor::Off); | ||
// let now = chrono::DateTime::<chrono::Utc>::from_timestamp(rtc.timestamp(), 0).unwrap(); | ||
// let mut text: heapless::String<8> = heapless::String::new(); | ||
// Text::with_alignment( | ||
// &text, | ||
// display.bounding_box().center() + Point::new(0, 6), | ||
// character_style, | ||
// Alignment::Center, | ||
// ) | ||
// .draw(display) | ||
// .unwrap(); | ||
|
||
match keypad.event().await { | ||
KeyEvent::Down(Key::Down) => Some(shared::UsbTx::HidChar('d')), | ||
KeyEvent::Down(Key::Up) => Some(shared::UsbTx::HidChar('u')), | ||
KeyEvent::Down(Key::One) => Some(shared::UsbTx::HidChar('1')), | ||
KeyEvent::Down(Key::Two) => Some(shared::UsbTx::HidChar('2')), | ||
KeyEvent::Down(Key::Four) => Some(shared::UsbTx::HidChar('4')), | ||
KeyEvent::Down(Key::Five) => Some(shared::UsbTx::HidChar('5')), | ||
KeyEvent::Down(Key::Six) => Some(shared::UsbTx::HidChar('6')), | ||
KeyEvent::Down(Key::Eight) => Some(shared::UsbTx::HidChar('8')), | ||
KeyEvent::Down(Key::Seven) => Some(shared::UsbTx::HidChar('7')), | ||
KeyEvent::Down(Key::Nine) => Some(shared::UsbTx::HidChar('9')), | ||
KeyEvent::Down(Key::Three) => Some(shared::UsbTx::HidChar('3')), | ||
KeyEvent::Down(Key::Select) => Some(shared::UsbTx::HidChar('s')), | ||
KeyEvent::Down(Key::Cancel) => Some(shared::UsbTx::HidChar('c')), | ||
KeyEvent::Down(Key::Asterisk) => Some(shared::UsbTx::HidChar('*')), | ||
KeyEvent::Down(Key::Zero) => Some(shared::UsbTx::HidChar('0')), | ||
KeyEvent::Down(Key::Hash) => Some(shared::UsbTx::HidChar('#')), | ||
KeyEvent::Up(_) => None, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.