move appdata out to new module

This commit is contained in:
sigil-03 2025-11-02 09:14:59 -07:00
parent 0836fc58df
commit 008bf334a4
2 changed files with 76 additions and 42 deletions

View file

@ -0,0 +1,66 @@
#[derive(Default)]
pub enum State {
// system is asleep, waiting for wake from coin insertion
DeepSleep,
// system is in low-power mode, dimmed lights, waiting for interaction
Idle,
// system is active. on entry: play coin sound. on button press: play different sound
#[default]
Active,
}
mod settings {
pub 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,
};
}
}
pub struct Settings {
pub brightness: Level,
pub volume: Level,
pub button_sound_index: usize,
}
impl Default for Settings {
fn default() -> Self {
Self {
brightness: Level::Medium,
volume: Level::Medium,
button_sound_index: 0,
}
}
}
}
pub use settings::Settings;
pub struct App {
state: State,
pub settings: Settings,
// TODO: make this the "sound module" or whatever.
// synthesizers: AppSynthesizers,
}
impl Default for App {
fn default() -> Self {
Self {
state: State::default(),
settings: Settings::default(),
}
}
}