diff --git a/apps/ball/README.md b/apps/ball/README.md index d6c270d6a..5be02cba7 100644 --- a/apps/ball/README.md +++ b/apps/ball/README.md @@ -9,4 +9,4 @@ but without much emphasis on I/O. 2. Copy this demo application, and rename the relevant structures in its `Cargo.toml` and `main.rs`. 3. Add it to the Workspace `default-members` and `members` arrays by editing `./Cargo.toml` 4. Add it to the build by editing `xtask/src/main.rs` and inserting it into the relevant descriptor. Typically, you would insert your app into the `hw_pkgs` array, as this is what is built and targeted for full hardware builds. Most of the other trimmed-down descriptors are for debug, emulation, and benchmarking. -5. \ No newline at end of file +5. (optional) You may also need to run `cargo xtask generate-locales` if you modify/add any internationalization strings. diff --git a/services/gam/src/modal/slider.rs b/services/gam/src/modal/slider.rs index ad22fb55a..c0f9f7e42 100644 --- a/services/gam/src/modal/slider.rs +++ b/services/gam/src/modal/slider.rs @@ -146,12 +146,13 @@ impl ActionApi for Slider { } // the actual slider + let mut draw_list = GamObjectList::new(modal.canvas); let outer_rect = Rectangle::new_with_style( Point::new(modal.margin * 2, modal.margin + modal.line_height + at_height), Point::new(modal.canvas_width - modal.margin * 2, modal.margin + modal.line_height * 2 + at_height), DrawStyle::new(fill_color, color, 2) ); - modal.gam.draw_rectangle(modal.canvas, outer_rect).expect("couldn't draw outer rectangle"); + draw_list.push(GamObjectType::Rect(outer_rect)).unwrap(); let total_width = modal.canvas_width - modal.margin * 4; let slider_point = (total_width * (self.action_payload - self.min) as i16) / (self.max - self.min) as i16; let inner_rect = Rectangle::new_with_style( @@ -159,7 +160,8 @@ impl ActionApi for Slider { Point::new(modal.margin * 2 + slider_point, modal.margin + modal.line_height * 2 + at_height), DrawStyle::new(color, color, 1) ); - modal.gam.draw_rectangle(modal.canvas, inner_rect).expect("couldn't draw inner rectangle"); + draw_list.push(GamObjectType::Rect(inner_rect)).unwrap(); + modal.gam.draw_list(draw_list).expect("couldn't execute draw list"); } fn key_action(&mut self, k: char) -> (Option, bool) { log::trace!("key_action: {}", k); diff --git a/services/status/src/main.rs b/services/status/src/main.rs index 106dd6da1..ef85225dd 100644 --- a/services/status/src/main.rs +++ b/services/status/src/main.rs @@ -170,7 +170,7 @@ fn xmain() -> ! { const CPU_BAR_WIDTH: i16 = 50; let time_rect = Rectangle::new( Point::new(0, 0), - Point::new(screensize.x / 2 - CPU_BAR_WIDTH / 2, screensize.y / 2 - 1) + Point::new(screensize.x / 2 - CPU_BAR_WIDTH / 2 - 1, screensize.y / 2 - 1) ); let cpuload_rect = Rectangle::new_with_style( Point::new(screensize.x / 2 - CPU_BAR_WIDTH / 2, 0), @@ -178,7 +178,7 @@ fn xmain() -> ! { DrawStyle::new(PixelColor::Light, PixelColor::Dark, 1), ); let stats_rect = Rectangle::new_with_style( - Point::new(screensize.x / 2 - CPU_BAR_WIDTH / 2, 0), + Point::new(screensize.x / 2 + CPU_BAR_WIDTH / 2 + 1, 0), Point::new(screensize.x, screensize.y / 2 - 1), DrawStyle::new(PixelColor::Light, PixelColor::Light, 0), ); @@ -351,6 +351,7 @@ fn xmain() -> ! { Some(StatusOpcode::BattStats) => msg_scalar_unpack!(msg, lo, hi, _, _, { stats = [lo, hi].into(); battstats_tv.clear_str(); + // have to clear the entire rectangle area, because the SSID has a variable width and can be much wider or shorter than battstats gam.draw_rectangle(status_gid, stats_rect).ok(); // toggle between two views of the data every time we have a status update if battstats_phase { @@ -385,6 +386,25 @@ fn xmain() -> ! { }, Some(StatusOpcode::Pump) => { let elapsed_time = ticktimer.elapsed_ms(); + { // update the CPU load bar + let mut draw_list = GamObjectList::new(status_gid); + draw_list.push(GamObjectType::Rect(cpuload_rect)).unwrap(); + let (latest_activity, period) = llio + .activity_instantaneous() + .expect("couldn't get CPU activity"); + let activity_to_width = ((latest_activity as f32) / (period as f32)) * (cpuload_rect.width() - 4) as f32; + draw_list.push(GamObjectType::Rect( + Rectangle::new_coords_with_style( + cpuload_rect.tl().x + 2, + cpuload_rect.tl().y + 2, + cpuload_rect.tl().x + 2 + activity_to_width as i16, + cpuload_rect.br().y - 2, + DrawStyle::new(PixelColor::Dark, PixelColor::Dark, 0)) + )).unwrap(); + gam.draw_list(draw_list).expect("couldn't draw object list"); + } + + // update the security status, if any let (is_locked, force_update) = llio.debug_usb(None).unwrap(); if (debug_locked != is_locked) || force_update @@ -513,23 +533,6 @@ fn xmain() -> ! { gam.post_textview(&mut uptime_tv) .expect("|status: can't draw uptime"); } - { // update the CPU load bar - let mut draw_list = GamObjectList::new(status_gid); - draw_list.push(GamObjectType::Rect(cpuload_rect)).unwrap(); - let (latest_activity, period) = llio - .activity_instantaneous() - .expect("couldn't get CPU activity"); - let activity_to_width = ((latest_activity as f32) / (period as f32)) * (cpuload_rect.width() - 4) as f32; - draw_list.push(GamObjectType::Rect( - Rectangle::new_coords_with_style( - cpuload_rect.tl().x + 2, - cpuload_rect.tl().y + 2, - cpuload_rect.tl().x + 2 + activity_to_width as i16, - cpuload_rect.br().y - 2, - DrawStyle::new(PixelColor::Dark, PixelColor::Dark, 0)) - )).unwrap(); - gam.draw_list(draw_list).expect("couldn't draw object list"); - } gam.redraw().expect("|status: couldn't redraw"); stats_phase = stats_phase.wrapping_add(1);