mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-08 04:56:43 +00:00
improve redraw performance on menu
it helps to actually redraw the menu instead of relying upon status updates to redo the Ux.
This commit is contained in:
parent
c0d4cbe81d
commit
f4fbe84b78
3 changed files with 19 additions and 5 deletions
|
|
@ -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();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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::<TextView>());
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue