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 /// A two-letter ASCII uppercase ISO 3166-1 alpha-2 country code.
23 pub country: [u8; 2],
24
25 /// The device name. Randomly generated when creating vFS.
26 pub name: String,
27
28 /// The full timezone name as in the IANA database.
29 pub timezone: String,
30
31 /// If true, rotate the image on the screen 180 degrees.
32 pub rotate_screen: bool,
33
34 /// Brightness of the screen backlight.
35 pub screen_brightness: u8,
36
37 /// Brightness of the LEDs.
38 pub leds_brightness: u8,
39
40 /// How loud the speakers should play sounds.
41 pub speakers_volume: u8,
42
43 /// How loud the headphones should play sounds.
44 pub headphones_volume: u8,
45
46 /// The preferred font size (text character height) in pixels.
47 pub font_size: u8,
48
49 /// Color scheme to use.
50 pub theme: u32,
51
52 /// Automatically lock the screen after N minutes.
53 ///
54 /// If zero, never locks automatically.
55 /// The screen is never locked when in multiplayer.
56 pub auto_lock: u8,
57
58 /// If enabled, apps are advised to skip flashy animations.
59 pub reduce_flashing: bool,
60
61 /// If enabled, collect and send anonymous telemetry.
62 pub telemetry: bool,
63
64 /// Emulate gamepad when connecting Firefly Zero to a PC via USB.
65 pub gamepad_mode: bool,
66
67 /// Increase contrast of colors in the default color palette.
68 pub contrast: bool,
69
70 /// Let the system apps show easter eggs, holiday effects, and weird jokes.
71 pub easter_eggs: bool,
72
73 /// Any feature new fields will be encoded in this field, for backward compatibility.
74 pub extra_flags: u32,
75}
76
77impl Encode<'_> for Settings {}
78
79impl Default for Settings {
80 fn default() -> Self {
81 /// * Primary: Black (0).
82 /// * Secondary: Light Gray (D).
83 /// * Accent: Green (6).
84 /// * Background: White (C).
85 /// * Index: default (00).
86 const DEFAULT_THEME: u32 = 0x_0D_6C_00;
87
88 Self {
89 xp: 0,
90 badges: 0,
91 lang: [b'e', b'n'],
92 country: [b'N', b'L'],
93 name: "firefly-zero".to_string(),
94 timezone: "Europe/Amsterdam".to_string(),
95 rotate_screen: false,
96 screen_brightness: 255,
97 leds_brightness: 255,
98 speakers_volume: 64,
99 headphones_volume: 64,
100 font_size: 9,
101 theme: DEFAULT_THEME,
102 auto_lock: 5,
103 reduce_flashing: false,
104 telemetry: false,
105 gamepad_mode: false,
106 contrast: false,
107 easter_eggs: false,
108 extra_flags: 0,
109 }
110 }
111}
112
113#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
114pub struct BatteryInfo {
115 pub min_voltage: u16,
116 pub max_voltage: u16,
117}
118
119impl Encode<'_> for BatteryInfo {}