add settings struct
This commit is contained in:
parent
3eb410c796
commit
73e4b482a6
1 changed files with 36 additions and 0 deletions
|
|
@ -24,6 +24,42 @@ use hal::println;
|
||||||
|
|
||||||
use qingke::riscv;
|
use qingke::riscv;
|
||||||
|
|
||||||
|
enum Level {
|
||||||
|
Off,
|
||||||
|
Low,
|
||||||
|
Medium,
|
||||||
|
High,
|
||||||
|
Maximum,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Level {
|
||||||
|
pub fn next(&mut self) {
|
||||||
|
*self = match self {
|
||||||
|
Self::Off => Self::Low,
|
||||||
|
Self::Low => Self::Medium,
|
||||||
|
Self::Medium => Self::High,
|
||||||
|
Self::High => Self::Maximum,
|
||||||
|
Self::Maximum => Self::Off,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Settings {
|
||||||
|
brightness: Level,
|
||||||
|
volume: Level,
|
||||||
|
button_sound_index: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Settings {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
brightness: Level::Medium,
|
||||||
|
volume: Level::Medium,
|
||||||
|
button_sound_index: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct DebouncedGPIO<'a> {
|
struct DebouncedGPIO<'a> {
|
||||||
input: Input<'a>,
|
input: Input<'a>,
|
||||||
// value of the GPIO
|
// value of the GPIO
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue