Compare commits
1 commit
main
...
wip-belpom
Author | SHA1 | Date | |
---|---|---|---|
25e3f1439f |
7 changed files with 75 additions and 17 deletions
23
Cargo.lock
generated
23
Cargo.lock
generated
|
@ -340,6 +340,27 @@ dependencies = [
|
||||||
"void",
|
"void",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embedded-layout"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7adbc16ba694006a121bce08a8935186d16cb008a4c9e20c5e346517ad1e0ac8"
|
||||||
|
dependencies = [
|
||||||
|
"embedded-graphics",
|
||||||
|
"embedded-layout-macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embedded-layout-macros"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "352186cee85e4cf9104c42b4dfd0295a22901c5d2bf0c26efd47265adcf1c52d"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "embedded-sdmmc"
|
name = "embedded-sdmmc"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
@ -821,11 +842,13 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"embedded-graphics",
|
"embedded-graphics",
|
||||||
"embedded-graphics-simulator",
|
"embedded-graphics-simulator",
|
||||||
|
"embedded-layout",
|
||||||
"embedded-sdmmc",
|
"embedded-sdmmc",
|
||||||
"embedded-text",
|
"embedded-text",
|
||||||
"epd-waveshare",
|
"epd-waveshare",
|
||||||
"maduino_zero_4g",
|
"maduino_zero_4g",
|
||||||
"panic-halt",
|
"panic-halt",
|
||||||
|
"static_assertions",
|
||||||
"tz-rs",
|
"tz-rs",
|
||||||
"tzdb",
|
"tzdb",
|
||||||
]
|
]
|
||||||
|
|
|
@ -11,11 +11,13 @@ arrayvec = { version = "0.7.4", default_features = false }
|
||||||
atsamd-hal = { version = "0.15.1", default_features = false, features = ["samd21g", "samd21g-rt", "usb"] }
|
atsamd-hal = { version = "0.15.1", default_features = false, features = ["samd21g", "samd21g-rt", "usb"] }
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
embedded-graphics = "0.7.1"
|
embedded-graphics = "0.7.1"
|
||||||
|
embedded-layout = "0.2.0"
|
||||||
embedded-text = "0.5.0"
|
embedded-text = "0.5.0"
|
||||||
embedded-sdmmc = { version = "0.3.0", default_features = false }
|
embedded-sdmmc = { version = "0.3.0", default_features = false }
|
||||||
epd-waveshare = "0.5.0"
|
epd-waveshare = "0.5.0"
|
||||||
maduino_zero_4g = { git = "https://github.com/ZettaScript/atsamd", branch = "maduino-zero-4g", features = ["usb"] }
|
maduino_zero_4g = { git = "https://github.com/ZettaScript/atsamd", branch = "maduino-zero-4g", features = ["usb"] }
|
||||||
panic-halt = "0.2.0"
|
panic-halt = "0.2.0"
|
||||||
|
static_assertions = "1.1.0"
|
||||||
tz-rs = { version = "0.6.14", default_features = false, features = ["const"] }
|
tz-rs = { version = "0.6.14", default_features = false, features = ["const"] }
|
||||||
tzdb = { version = "0.5.7", optional = true }
|
tzdb = { version = "0.5.7", optional = true }
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,11 @@ GSM will be shutting down in France in a few years so if you have an old cellpho
|
||||||
## Install tools
|
## Install tools
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Choose one line depending on your distro
|
||||||
sudo pacman -S arm-none-eabi-gcc
|
sudo pacman -S arm-none-eabi-gcc
|
||||||
|
sudo apt install gcc-arm-none-eabi
|
||||||
|
|
||||||
|
# Install Rust target
|
||||||
rustup target add thumbv6m-none-eabi
|
rustup target add thumbv6m-none-eabi
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ impl App for Dial {
|
||||||
}
|
}
|
||||||
Key::OptionRight => {
|
Key::OptionRight => {
|
||||||
if mode_state.line.pop().is_some() {
|
if mode_state.line.pop().is_some() {
|
||||||
|
// TODO redraw background over the erased character
|
||||||
mode_state.line_changed = true;
|
mode_state.line_changed = true;
|
||||||
} else {
|
} else {
|
||||||
return Some(ModeState::Clock(Default::default()));
|
return Some(ModeState::Clock(Default::default()));
|
||||||
|
|
|
@ -69,8 +69,7 @@ impl Keypad {
|
||||||
|
|
||||||
#[cfg(feature = "simulator")]
|
#[cfg(feature = "simulator")]
|
||||||
fn get_keys(&self) -> [bool; NB_KEYS] {
|
fn get_keys(&self) -> [bool; NB_KEYS] {
|
||||||
use embedded_graphics_simulator::sdl2::Keycode;
|
use embedded_graphics_simulator::{sdl2::Keycode, SimulatorEvent};
|
||||||
use embedded_graphics_simulator::SimulatorEvent;
|
|
||||||
|
|
||||||
let mut keys = [false; NB_KEYS];
|
let mut keys = [false; NB_KEYS];
|
||||||
crate::display::window_mut()
|
crate::display::window_mut()
|
||||||
|
@ -88,7 +87,7 @@ impl Keypad {
|
||||||
Keycode::Num8 | Keycode::Kp8 => Some(Key::D8),
|
Keycode::Num8 | Keycode::Kp8 => Some(Key::D8),
|
||||||
Keycode::Num9 | Keycode::Kp9 => Some(Key::D9),
|
Keycode::Num9 | Keycode::Kp9 => Some(Key::D9),
|
||||||
Keycode::KpEnter | Keycode::Return => Some(Key::Enter),
|
Keycode::KpEnter | Keycode::Return => Some(Key::Enter),
|
||||||
Keycode::Asterisk => Some(Key::Asterisk),
|
Keycode::Asterisk | Keycode::KpMultiply => Some(Key::Asterisk),
|
||||||
Keycode::Hash | Keycode::KpHash => Some(Key::Hash),
|
Keycode::Hash | Keycode::KpHash => Some(Key::Hash),
|
||||||
// TODO more
|
// TODO more
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -148,19 +147,22 @@ impl KeyEvent {
|
||||||
pub fn get_char(&self, key_input_mode: KeyInputMode) -> Option<char> {
|
pub fn get_char(&self, key_input_mode: KeyInputMode) -> Option<char> {
|
||||||
use Key::*;
|
use Key::*;
|
||||||
match key_input_mode {
|
match key_input_mode {
|
||||||
KeyInputMode::Digit => match self.key {
|
KeyInputMode::Digit => match (self.key, self.repeats) {
|
||||||
D0 => Some('0'),
|
(D0, _) => Some('0'),
|
||||||
D1 => Some('1'),
|
(D1, _) => Some('1'),
|
||||||
D2 => Some('2'),
|
(D2, _) => Some('2'),
|
||||||
D3 => Some('3'),
|
(D3, _) => Some('3'),
|
||||||
D4 => Some('4'),
|
(D4, _) => Some('4'),
|
||||||
D5 => Some('5'),
|
(D5, _) => Some('5'),
|
||||||
D6 => Some('6'),
|
(D6, _) => Some('6'),
|
||||||
D7 => Some('7'),
|
(D7, _) => Some('7'),
|
||||||
D8 => Some('8'),
|
(D8, _) => Some('8'),
|
||||||
D9 => Some('9'),
|
(D9, _) => Some('9'),
|
||||||
Asterisk => Some('*'),
|
(Asterisk, 1) => Some('*'),
|
||||||
Hash => Some('#'),
|
(Asterisk, 2) => Some('+'),
|
||||||
|
(Asterisk, 3) => Some('p'),
|
||||||
|
(Asterisk, 4) => Some('W'),
|
||||||
|
(Hash, _) => Some('#'),
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
|
|
22
src/main.rs
22
src/main.rs
|
@ -10,6 +10,7 @@ mod gui;
|
||||||
mod keypad;
|
mod keypad;
|
||||||
mod state;
|
mod state;
|
||||||
mod strf;
|
mod strf;
|
||||||
|
mod text_input;
|
||||||
mod time;
|
mod time;
|
||||||
|
|
||||||
use apps::App;
|
use apps::App;
|
||||||
|
@ -21,7 +22,10 @@ use state::*;
|
||||||
use arrayvec::ArrayString;
|
use arrayvec::ArrayString;
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
use embedded_graphics::{
|
use embedded_graphics::{
|
||||||
mono_font::{ascii::FONT_10X20, ascii::FONT_6X10, ascii::FONT_9X15, MonoTextStyleBuilder},
|
mono_font::{
|
||||||
|
ascii::{FONT_10X20, FONT_6X10, FONT_9X15},
|
||||||
|
MonoTextStyleBuilder,
|
||||||
|
},
|
||||||
pixelcolor::BinaryColor,
|
pixelcolor::BinaryColor,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
primitives::{Line, PrimitiveStyle, PrimitiveStyleBuilder, Rectangle, StrokeAlignment},
|
primitives::{Line, PrimitiveStyle, PrimitiveStyleBuilder, Rectangle, StrokeAlignment},
|
||||||
|
@ -41,6 +45,22 @@ use maduino_zero_4g::{
|
||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
use tz::DateTime;
|
use tz::DateTime;
|
||||||
|
|
||||||
|
// Check that stack overflow is unlikely
|
||||||
|
#[cfg(not(feature = "simulator"))]
|
||||||
|
static_assertions::const_assert!(
|
||||||
|
core::mem::size_of::<(
|
||||||
|
State,
|
||||||
|
ModeState,
|
||||||
|
Peripherals,
|
||||||
|
maduino_zero_4g::Pins,
|
||||||
|
CorePeripherals,
|
||||||
|
keypad::Keypad,
|
||||||
|
Display,
|
||||||
|
Context,
|
||||||
|
fs::Fs,
|
||||||
|
)>() < 16 * 1024
|
||||||
|
);
|
||||||
|
|
||||||
#[cfg_attr(not(feature = "simulator"), bsp::entry)]
|
#[cfg_attr(not(feature = "simulator"), bsp::entry)]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
|
|
6
src/text_input.rs
Normal file
6
src/text_input.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
use arrayvec::ArrayString;
|
||||||
|
|
||||||
|
pub struct TextInput<const N: usize> {
|
||||||
|
cursor: usize,
|
||||||
|
value: ArrayString<N>,
|
||||||
|
}
|
Loading…
Reference in a new issue