Skip to content

Commit e0b3d8a

Browse files
authored
feat(melpo): Makes scaling an option (#236)
This PR makes UI scaling a config file option
1 parent 97a825a commit e0b3d8a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

platforms/melpomene/melpo-config/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,25 @@ pub struct DisplayConfig {
9090
/// The maximum number of frames per second. Must be >= 1
9191
#[serde(default = "DisplayConfig::default_frames_per_second")]
9292
pub frames_per_second: usize,
93+
/// The scaling of the display
94+
#[serde(default = "DisplayConfig::default_scaling")]
95+
pub scaling: u32,
9396
}
9497

9598
impl DisplayConfig {
9699
pub const DEFAULT_KCHANNEL_DEPTH: usize = 2;
97100
pub const DEFAULT_FRAMES_PER_SECOND: usize = 20;
101+
pub const DEFAULT_SCALING: u32 = 2;
98102

99103
const fn default_kchannel_depth() -> usize {
100104
Self::DEFAULT_KCHANNEL_DEPTH
101105
}
102106
const fn default_frames_per_second() -> usize {
103107
Self::DEFAULT_FRAMES_PER_SECOND
104108
}
109+
const fn default_scaling() -> u32 {
110+
Self::DEFAULT_SCALING
111+
}
105112
}
106113

107114
#[derive(Debug, Serialize, Deserialize)]

platforms/melpomene/melpo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ enabled = true
4242
enabled = true
4343
# kchannel_depth = 2
4444
# frames_per_second = 20
45+
# scaling = 2
4546

4647
[platform.tcp_uart]
4748
enabled = true

platforms/melpomene/src/sim_drivers/emb_display.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ impl SimDisplay {
7575
height,
7676
};
7777

78-
kernel
79-
.spawn(commander.run(width, height, settings.frames_per_second))
80-
.await;
78+
kernel.spawn(commander.run(width, height, settings)).await;
8179

8280
kernel
8381
.with_registry(|reg| reg.register_konly::<EmbDisplayService>(&cmd_prod))
@@ -113,9 +111,10 @@ struct Context {
113111

114112
impl CommanderTask {
115113
/// The entrypoint for the driver execution
116-
async fn run(self, width: u32, height: u32, frames_per_second: usize) {
114+
async fn run(self, width: u32, height: u32, settings: DisplayConfig) {
117115
let output_settings = OutputSettingsBuilder::new()
118116
.theme(BinaryColorTheme::OledBlue)
117+
.scale(settings.scaling)
119118
.build();
120119

121120
let bytes = (width * height) as usize;
@@ -146,7 +145,7 @@ impl CommanderTask {
146145
self.kernel
147146
.spawn({
148147
let mutex = mutex.clone();
149-
render_loop(self.kernel, mutex, frames_per_second)
148+
render_loop(self.kernel, mutex, settings.frames_per_second)
150149
})
151150
.await;
152151

0 commit comments

Comments
 (0)