mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
improve the iconography of the status bar
This commit is contained in:
parent
4dbff88015
commit
65bd1d416a
2 changed files with 14 additions and 2 deletions
|
|
@ -60,7 +60,9 @@ fn xmain() -> ! {
|
|||
let screensize = gfx.screen_size().expect("Couldn't get screen size");
|
||||
// the status canvas is special -- there can only be one, and it is ultimately trusted
|
||||
let status_canvas = Canvas::new(
|
||||
Rectangle::new_coords(0, 0, screensize.x, gfx.glyph_height_hint(GlyphStyle::Regular).expect("couldn't get glyph height") as i16 * 2),
|
||||
Rectangle::new_coords(
|
||||
0, 0, screensize.x,
|
||||
gfx.glyph_height_hint(GlyphStyle::Cjk).expect("couldn't get glyph height") as i16 * 2),
|
||||
255, &trng, None, crate::api::CanvasType::Status
|
||||
).expect("couldn't create status canvas");
|
||||
canvases.insert(status_canvas.gid(), status_canvas);
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ fn xmain() -> ! {
|
|||
let susres = susres::Susres::new_without_hook(&xns).unwrap();
|
||||
let mut netmgr = net::NetManager::new();
|
||||
|
||||
// screensize is controlled by the GAM, it's set in main.rs near the top
|
||||
let screensize = gam
|
||||
.get_canvas_bounds(status_gid)
|
||||
.expect("|status: Couldn't get canvas size");
|
||||
|
|
@ -356,8 +357,17 @@ fn xmain() -> ! {
|
|||
// 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
|
||||
let mut wattage = stats.current as f32 / 1000.0 * stats.voltage as f32 / 1000.0;
|
||||
let sign = if wattage > 0.005 {
|
||||
'\u{2b06}' // up arrow
|
||||
} else if wattage < -0.005 {
|
||||
'\u{2b07}' // down arrow
|
||||
} else {
|
||||
'\u{1f50b}' // battery icon (fully charged)
|
||||
};
|
||||
wattage = wattage.abs();
|
||||
if battstats_phase {
|
||||
write!(&mut battstats_tv, "{}mA {:.2}V {}%", stats.current, stats.voltage as f32 / 1000.0, stats.soc)
|
||||
write!(&mut battstats_tv, "{}W{}{:.2}V {}%", wattage, sign, stats.voltage as f32 / 1000.0, stats.soc)
|
||||
.expect("|status: can't write string");
|
||||
} else {
|
||||
if let Some(ssid) = wifi_status.ssid {
|
||||
|
|
|
|||
Loading…
Reference in a new issue