From 73e4b482a63997aac1922f861cf64232f9bb5307 Mon Sep 17 00:00:00 2001 From: sigil-03 Date: Sun, 26 Oct 2025 13:31:18 -0600 Subject: [PATCH] add settings struct --- ch32v-insert-coin/src/main.rs | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/ch32v-insert-coin/src/main.rs b/ch32v-insert-coin/src/main.rs index 19c3869..c1b4631 100644 --- a/ch32v-insert-coin/src/main.rs +++ b/ch32v-insert-coin/src/main.rs @@ -24,6 +24,42 @@ use hal::println; 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> { input: Input<'a>, // value of the GPIO