diff --git a/services/status/src/main.rs b/services/status/src/main.rs index 966754248..d059f626e 100644 --- a/services/status/src/main.rs +++ b/services/status/src/main.rs @@ -406,8 +406,9 @@ fn wrapped_main() -> ! { pump_run.store(true, Ordering::Relaxed); // start status thread updating loop { let msg = xous::receive_message(status_sid).unwrap(); - log::trace!("|status: Message: {:?}", msg); - match FromPrimitive::from_usize(msg.body.id()) { + let opcode: Option = FromPrimitive::from_usize(msg.body.id()); + log::debug!("{:?}", opcode); + match opcode { Some(StatusOpcode::EnableAutomaticBacklight) => { *enabled.lock().unwrap() = true; @@ -530,12 +531,16 @@ fn wrapped_main() -> ! { let (latest_activity, period) = llio .activity_instantaneous() .expect("couldn't get CPU activity"); - let activity_to_width = ((latest_activity as u64) * 1000u64 * (cpuload_rect.width() as u64 - 4)) / (period as u64 * 1000u64); + let activity_to_width = if period == 0 { + cpuload_rect.width() as i16 - 4 + } else { + (((latest_activity as u64) * 1000u64 * (cpuload_rect.width() as u64 - 4)) / (period as u64 * 1000u64)) as i16 + }; 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.tl().x + 2 + (activity_to_width).min(cpuload_rect.width() as i16 - 4), cpuload_rect.br().y - 2, DrawStyle::new(PixelColor::Dark, PixelColor::Dark, 0)) )).unwrap();