use core::borrow::{Borrow, BorrowMut}; use hd44780_driver::display_size::DisplaySize; use miniconf::{Error, Packed, Tree, TreeKey}; use serde::{Deserialize, Serialize}; use heapless::String; #[derive(Tree, Default)] pub struct Msg(pub String<80>); impl Borrow for Msg { fn borrow(&self) -> &str { &self.0 } } impl BorrowMut for Msg { fn borrow_mut(&mut self) -> &mut str { &mut self.0 } } #[derive(Tree, Default)] pub struct Settings { lcd_size: [u8; 2], #[tree(depth=3)] msgs: [Option; 12] } const fn const_packed(u: usize) -> Packed { match Packed::new(u) { Some(p) => p, None => panic!("non-zero key required") } } pub const SIZE: Packed = const_packed(0b1_0); pub const MSG_0: Packed = const_packed(0b1_0000_1); pub const MSG_1: Packed = const_packed(0b1_1000_1);