diff --git a/services/gam/src/lib.rs b/services/gam/src/lib.rs index cf5689c71..b0bd5ed94 100644 --- a/services/gam/src/lib.rs +++ b/services/gam/src/lib.rs @@ -522,6 +522,7 @@ impl Menu { break; } } + self.gam.redraw().unwrap(); } fn num_items(&self) -> usize { let mut items = 0; @@ -558,6 +559,7 @@ impl Menu { } self.index = 0; // reset the index to 0 } + self.gam.redraw().unwrap(); }, '←' => { // placeholder @@ -569,9 +571,11 @@ impl Menu { } '↑' => { self.prev_item(); + self.gam.redraw().unwrap(); } '↓' => { self.next_item(); + self.gam.redraw().unwrap(); } _ => {} } diff --git a/services/gam/src/status.rs b/services/gam/src/status.rs index 85333a746..31d8d17fe 100644 --- a/services/gam/src/status.rs +++ b/services/gam/src/status.rs @@ -50,7 +50,7 @@ pub fn pump_thread(conn: usize) { Ok(xous::Result::Ok) => {}, _ => panic!("unhandled error in status pump thread") } - ticktimer.sleep_ms(250).unwrap(); + ticktimer.sleep_ms(1000).unwrap(); } } @@ -183,6 +183,8 @@ pub fn status_thread(canvas_gid_0: usize, canvas_gid_1: usize, canvas_gid_2: usi } else { write!(&mut security_tv, " USB secured").unwrap(); } + // only post the view if something has actually changed + gam.post_textview(&mut security_tv).unwrap(); } let elapsed_time = ticktimer.elapsed_ms(); let now_seconds: usize = ((elapsed_time / 1000) % 60) as usize; @@ -235,7 +237,7 @@ pub fn status_thread(canvas_gid_0: usize, canvas_gid_1: usize, canvas_gid_2: usi } last_seconds = now_seconds; uptime_tv.clear_str(); - if (stats_phase > 3) && datetime.is_some() { + if (stats_phase >= 2) && datetime.is_some() { let dt = datetime.unwrap(); let day = match dt.weekday { rtc::Weekday::Monday => "Mon", @@ -257,9 +259,8 @@ pub fn status_thread(canvas_gid_0: usize, canvas_gid_1: usize, canvas_gid_2: usi log::trace!("|status: requesting draw of '{}'", uptime_tv); gam.post_textview(&mut uptime_tv).expect("|status: can't draw uptime"); gam.post_textview(&mut battstats_tv).expect("|status: can't draw battery stats"); - gam.post_textview(&mut security_tv).unwrap(); gam.redraw().expect("|status: couldn't redraw"); - stats_phase = (stats_phase + 1) % 8; + stats_phase = (stats_phase + 1) % 4; } if elapsed_time - last_time > batt_interval { //info!("|status: size of TextView type: {} bytes", core::mem::size_of::()); diff --git a/services/graphics-server/src/backend/betrusted.rs b/services/graphics-server/src/backend/betrusted.rs index 47fbac72d..76bc50bb6 100644 --- a/services/graphics-server/src/backend/betrusted.rs +++ b/services/graphics-server/src/backend/betrusted.rs @@ -128,7 +128,12 @@ impl XousDisplay { pub fn screen_size(&self) -> Point { Point::new(FB_WIDTH_PIXELS as i16, FB_LINES as i16) } pub fn redraw(&mut self) { - while self.busy() {xous::yield_slice()} + let mut busy_count = 0; + let mut dirty_count = 0; + while self.busy() { + xous::yield_slice(); + busy_count += 1; + } let fb: *mut [u32; FB_SIZE] = self.fb.as_mut_ptr() as *mut [u32; FB_SIZE]; let hwfb: *mut [u32; FB_SIZE] = self.hwfb.as_mut_ptr() as *mut [u32; FB_SIZE]; for words in 0..FB_SIZE { @@ -140,10 +145,14 @@ impl XousDisplay { // clear all the dirty bits, under the theory that it's time-wise cheaper on average // to visit every line and clear the dirty bits than it is to do an update_all() for lines in 0..FB_LINES { + if unsafe{(*fb)[lines * FB_WIDTH_WORDS + (FB_WIDTH_WORDS - 1)] & 0xFFFF_0000} != 0x0 { + dirty_count += 1; + } unsafe { (*fb)[lines * FB_WIDTH_WORDS + (FB_WIDTH_WORDS - 1)] &= 0x0000_FFFF; } } + log::trace!("redraw {}/{}", busy_count, dirty_count); } // note: this API is used by emulation, don't remove calls to it