firefly_types/settings.rs
1use crate::encode::Encode;
2use alloc::string::{String, ToString};
3use serde::{Deserialize, Serialize};
4
5/// System settings. Stored in `sys/config`.
6///
7/// Since we don't have a realiable vesioning for the system config,
8/// some of the settings are added "just in case" and might be not used yet
9/// or maybe even won't be ever used.
10#[allow(clippy::struct_excessive_bools)]
11#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
12pub struct Settings {
13 /// How much XP the player earned over all games.
14 pub xp: u32,
15
16 /// How many badges the player earned over all games.
17 pub badges: u32,
18
19 /// A two-letter ASCII ISO 639 Set 1 language code.
20 pub lang: [u8; 2],
21
22 /// The device name. Randomly generated when creating vFS.
23 pub name: String,
24
25 /// The full timezone name as in the IANA database.
26 pub timezone: String,
27
28 /// If true, rotate the image on the screen 180 degrees.
29 pub rotate_screen: bool,
30
31 /// Brightness of the screen backlight.
32 pub screen_brightness: u8,
33
34 /// Brightness of the LEDs.
35 pub leds_brightness: u8,
36
37 /// How loud the speakers should play sounds.
38 pub speakers_volume: u8,
39
40 /// How loud the headphones should play sounds.
41 pub headphones_volume: u8,
42
43 /// Color scheme to use.
44 pub theme: u8,
45
46 /// Automatically lock the screen after N minutes.
47 ///
48 /// If zero, never locks automatically.
49 /// The screen is never locked when in multiplayer.
50 pub auto_lock: u8,
51
52 /// If enabled, apps are advised to skip flashy animations.
53 pub reduce_flashing: bool,
54
55 /// If enabled, collect and send anonymous telemetry.
56 pub telemetry: bool,
57
58 /// Emulate gamepad when connecting Firefly Zero to a PC via USB.
59 pub gamepad_mode: bool,
60
61 /// Increase contrast of colors in the default color palette.
62 pub contrast: bool,
63
64 /// Let the system apps show easter eggs, holiday effects, and weird jokes.
65 pub easter_eggs: bool,
66}
67
68impl Encode<'_> for Settings {}
69
70impl Default for Settings {
71 fn default() -> Self {
72 Self {
73 xp: 0,
74 badges: 0,
75 lang: [b'e', b'n'],
76 name: "firefly-zero".to_string(),
77 timezone: "Europe/Amsterdam".to_string(),
78 rotate_screen: false,
79 screen_brightness: 255,
80 leds_brightness: 255,
81 speakers_volume: 64,
82 headphones_volume: 64,
83 theme: 0,
84 auto_lock: 5,
85 reduce_flashing: false,
86 telemetry: false,
87 gamepad_mode: false,
88 contrast: false,
89 easter_eggs: false,
90 }
91 }
92}
93
94#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
95pub struct BatteryInfo {
96 pub min_voltage: u16,
97 pub max_voltage: u16,
98}
99
100impl Encode<'_> for BatteryInfo {}