2020-08-14 09:25:20 +00:00
|
|
|
#![cfg_attr(target_os = "none", no_std)]
|
|
|
|
|
#![cfg_attr(target_os = "none", no_main)]
|
|
|
|
|
|
2020-08-29 14:09:20 +00:00
|
|
|
mod api;
|
2021-02-14 20:42:30 +00:00
|
|
|
|
|
|
|
|
mod backend;
|
|
|
|
|
use backend::XousDisplay;
|
|
|
|
|
|
2020-10-30 02:22:03 +00:00
|
|
|
mod op;
|
2020-08-14 09:25:20 +00:00
|
|
|
|
2020-10-11 19:23:15 +00:00
|
|
|
mod logo;
|
2021-03-10 20:09:35 +00:00
|
|
|
mod poweron;
|
2021-05-01 19:36:54 +00:00
|
|
|
mod sleep_note;
|
2020-08-14 10:46:23 +00:00
|
|
|
|
2021-04-02 16:53:30 +00:00
|
|
|
use api::{DrawStyle, PixelColor, Rectangle, TextBounds, RoundedRectangle, Point, TextView, Line, Circle};
|
|
|
|
|
use api::{Opcode, ClipObject, ClipObjectType};
|
2021-01-20 08:22:38 +00:00
|
|
|
use blitstr_ref as blitstr;
|
2021-04-02 16:53:30 +00:00
|
|
|
use blitstr::GlyphStyle;
|
2020-11-27 18:05:55 +00:00
|
|
|
|
2021-04-02 16:53:30 +00:00
|
|
|
use num_traits::FromPrimitive;
|
|
|
|
|
use xous_ipc::Buffer;
|
|
|
|
|
use xous::{msg_scalar_unpack, msg_blocking_scalar_unpack};
|
2021-03-26 12:22:33 +00:00
|
|
|
|
2021-02-26 18:12:19 +00:00
|
|
|
mod fontmap;
|
|
|
|
|
|
2020-10-11 19:23:15 +00:00
|
|
|
fn draw_boot_logo(display: &mut XousDisplay) {
|
2021-03-10 20:09:35 +00:00
|
|
|
display.blit_screen(poweron::LOGO_MAP);
|
2020-08-29 14:09:20 +00:00
|
|
|
}
|
|
|
|
|
|
2021-02-26 18:12:19 +00:00
|
|
|
#[cfg(target_os = "none")]
|
|
|
|
|
fn map_fonts() {
|
2021-04-02 16:53:30 +00:00
|
|
|
log::trace!("mapping fonts");
|
2021-02-26 18:12:19 +00:00
|
|
|
// this maps an extra page if the total length happens to fall on a 4096-byte boundary, but this is ok
|
|
|
|
|
// because the reserved area is much larger
|
|
|
|
|
let fontlen: u32 = ((fontmap::FONT_TOTAL_LEN as u32) & 0xFFFF_F000) + 0x1000;
|
2021-04-02 16:53:30 +00:00
|
|
|
log::trace!("requesting map of length 0x{:08x} at 0x{:08x}", fontlen, fontmap::FONT_BASE);
|
2021-02-26 18:12:19 +00:00
|
|
|
let fontregion = xous::syscall::map_memory(
|
|
|
|
|
xous::MemoryAddress::new(fontmap::FONT_BASE),
|
|
|
|
|
None,
|
|
|
|
|
fontlen as usize,
|
|
|
|
|
xous::MemoryFlags::R,
|
2021-04-02 16:53:30 +00:00
|
|
|
).expect("couldn't map fonts");
|
|
|
|
|
log::info!("font base at virtual 0x{:08x}, len of 0x{:08x}", usize::from(fontregion.addr), usize::from(fontregion.size));
|
2021-02-26 18:12:19 +00:00
|
|
|
|
2021-04-02 16:53:30 +00:00
|
|
|
log::trace!("mapping regular font to 0x{:08x}", usize::from(fontregion.addr) + fontmap::REGULAR_OFFSET as usize);
|
2021-02-26 18:12:19 +00:00
|
|
|
blitstr::map_font(blitstr::GlyphData::Emoji((usize::from(fontregion.addr) + fontmap::EMOJI_OFFSET) as usize));
|
|
|
|
|
blitstr::map_font(blitstr::GlyphData::Hanzi((usize::from(fontregion.addr) + fontmap::HANZI_OFFSET) as usize));
|
|
|
|
|
blitstr::map_font(blitstr::GlyphData::Regular((usize::from(fontregion.addr) + fontmap::REGULAR_OFFSET) as usize));
|
|
|
|
|
blitstr::map_font(blitstr::GlyphData::Small((usize::from(fontregion.addr) + fontmap::SMALL_OFFSET) as usize));
|
|
|
|
|
blitstr::map_font(blitstr::GlyphData::Bold((usize::from(fontregion.addr) + fontmap::BOLD_OFFSET) as usize));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(not(target_os = "none"))]
|
|
|
|
|
fn map_fonts() {
|
|
|
|
|
// does nothing
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-29 14:09:20 +00:00
|
|
|
#[xous::xous_main]
|
|
|
|
|
fn xmain() -> ! {
|
2020-10-30 13:27:06 +00:00
|
|
|
log_server::init_wait().unwrap();
|
2021-04-06 14:38:11 +00:00
|
|
|
let debugtv = false;
|
|
|
|
|
log::set_max_level(log::LevelFilter::Info);
|
2021-04-02 16:53:30 +00:00
|
|
|
log::info!("my PID is {}", xous::process::id());
|
2020-10-30 13:27:06 +00:00
|
|
|
|
2021-03-29 18:13:23 +00:00
|
|
|
let xns = xous_names::XousNames::new().unwrap();
|
2021-04-02 16:53:30 +00:00
|
|
|
let sid = xns.register_name(api::SERVER_NAME_GFX).expect("can't register server");
|
|
|
|
|
log::trace!("Server listening on address {:?}", sid);
|
2021-03-05 17:10:18 +00:00
|
|
|
|
2020-08-29 14:09:20 +00:00
|
|
|
// Create a new monochrome simulator display.
|
|
|
|
|
let mut display = XousDisplay::new();
|
|
|
|
|
|
|
|
|
|
draw_boot_logo(&mut display);
|
2020-08-14 10:46:23 +00:00
|
|
|
|
2021-02-26 18:12:19 +00:00
|
|
|
map_fonts();
|
|
|
|
|
|
2021-05-01 19:36:54 +00:00
|
|
|
let mut use_sleep_note = true;
|
2021-02-28 17:49:22 +00:00
|
|
|
if false {
|
|
|
|
|
// leave this test case around
|
|
|
|
|
// for some reason, the top right quadrant draws an extra pixel inside the fill area
|
|
|
|
|
// when a fill color of "Light" is specified. However, if `None` fill is specified, it
|
|
|
|
|
// works correctly. This is really puzzling, because the test for filled drawing happens
|
|
|
|
|
// after the test for border drawing.
|
|
|
|
|
use api::Point;
|
|
|
|
|
let mut r = Rectangle::new(Point::new(20, 200), Point::new(151, 301));
|
|
|
|
|
r.style = DrawStyle {
|
|
|
|
|
fill_color: Some(PixelColor::Light),
|
|
|
|
|
stroke_color: Some(PixelColor::Dark),
|
|
|
|
|
stroke_width: 1,
|
|
|
|
|
};
|
|
|
|
|
let rr = RoundedRectangle::new(r, 16);
|
2021-03-05 17:10:18 +00:00
|
|
|
op::rounded_rectangle(display.native_buffer(), rr, None);
|
2021-02-28 17:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
2021-05-02 08:10:51 +00:00
|
|
|
let screen_clip = Rectangle::new(Point::new(0,0), display.screen_size());
|
|
|
|
|
|
|
|
|
|
display.redraw();
|
|
|
|
|
|
2021-05-01 17:38:44 +00:00
|
|
|
// register a suspend/resume listener
|
|
|
|
|
let sr_cid = xous::connect(sid).expect("couldn't create suspend callback connection");
|
|
|
|
|
let mut susres = susres::Susres::new(&xns, Opcode::SuspendResume as u32, sr_cid).expect("couldn't create suspend/resume object");
|
|
|
|
|
|
2020-08-14 10:46:23 +00:00
|
|
|
loop {
|
2021-04-02 16:53:30 +00:00
|
|
|
let mut msg = xous::receive_message(sid).unwrap();
|
|
|
|
|
log::trace!("Message: {:?}", msg);
|
|
|
|
|
match FromPrimitive::from_usize(msg.body.id()) {
|
2021-05-01 17:38:44 +00:00
|
|
|
Some(Opcode::SuspendResume) => xous::msg_scalar_unpack!(msg, token, _, _, _, {
|
2021-05-01 19:36:54 +00:00
|
|
|
display.suspend(use_sleep_note);
|
2021-05-01 17:38:44 +00:00
|
|
|
susres.suspend_until_resume(token).expect("couldn't execute suspend/resume");
|
2021-05-01 19:36:54 +00:00
|
|
|
display.resume(use_sleep_note);
|
|
|
|
|
}),
|
|
|
|
|
Some(Opcode::SetSleepNote) => xous::msg_scalar_unpack!(msg, set_use, _, _, _, {
|
|
|
|
|
if set_use == 0 {
|
|
|
|
|
use_sleep_note = false;
|
|
|
|
|
} else {
|
|
|
|
|
use_sleep_note = true;
|
|
|
|
|
}
|
2021-05-01 17:38:44 +00:00
|
|
|
}),
|
2021-04-02 16:53:30 +00:00
|
|
|
Some(Opcode::DrawClipObject) => {
|
|
|
|
|
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
|
|
|
|
let obj = buffer.to_original::<ClipObject, _>().unwrap();
|
|
|
|
|
log::trace!("DrawClipObject {:?}", obj);
|
|
|
|
|
match obj.obj {
|
|
|
|
|
ClipObjectType::Line(line) => {
|
|
|
|
|
op::line(display.native_buffer(), line, Some(obj.clip));
|
|
|
|
|
},
|
|
|
|
|
ClipObjectType::Circ(circ) => {
|
|
|
|
|
op::circle(display.native_buffer(), circ, Some(obj.clip));
|
|
|
|
|
},
|
|
|
|
|
ClipObjectType::Rect(rect) => {
|
|
|
|
|
op::rectangle(display.native_buffer(), rect, Some(obj.clip));
|
|
|
|
|
},
|
|
|
|
|
ClipObjectType::RoundRect(rr) => {
|
|
|
|
|
op::rounded_rectangle(display.native_buffer(), rr, Some(obj.clip));
|
2021-03-05 17:10:18 +00:00
|
|
|
}
|
2021-04-02 16:53:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Some(Opcode::DrawTextView) => {
|
|
|
|
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
|
|
|
|
let mut tv = buffer.to_original::<TextView, _>().unwrap();
|
|
|
|
|
|
|
|
|
|
if tv.clip_rect.is_none() { continue } // if no clipping rectangle is specified, nothing to draw
|
|
|
|
|
let clip_rect = tv.clip_rect.unwrap(); // this is the clipping rectangle of the canvas
|
|
|
|
|
let screen_offset: Point = tv.clip_rect.unwrap().tl; // this is the translation vector to and from screen space
|
|
|
|
|
|
|
|
|
|
let paintfn = if tv.dry_run {
|
|
|
|
|
if debugtv { log::trace!("(TV): doing dry run"); }
|
|
|
|
|
blitstr::simulate_char
|
|
|
|
|
} else {
|
|
|
|
|
if debugtv { log::trace!("(TV): doing live run"); }
|
|
|
|
|
blitstr::xor_char
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// first compute the bounding box, if it isn't computed
|
|
|
|
|
if tv.bounds_computed.is_none() {
|
|
|
|
|
match tv.bounds_hint {
|
|
|
|
|
TextBounds::BoundingBox(r) => {
|
|
|
|
|
tv.bounds_computed = Some(r);
|
|
|
|
|
},
|
|
|
|
|
TextBounds::GrowableFromBr(br, width) => {
|
|
|
|
|
if !clip_rect.intersects_point(br) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// assume: clip_rect is the total canvas area we could draw
|
|
|
|
|
// assume: br is the point we want to extend the drawable text bubble on
|
|
|
|
|
let checkedwidth: i16 = if width as i16 <= (br.x - clip_rect.tl.x) {
|
|
|
|
|
width as _
|
|
|
|
|
} else {
|
|
|
|
|
(br.x - clip_rect.tl.x) as _
|
|
|
|
|
};
|
|
|
|
|
// first, create a clip that's the width of the growable, but as big as the height of the screen
|
|
|
|
|
let clip = blitstr::ClipRect::new(0, 0, checkedwidth as _, display.screen_size().y as _);
|
|
|
|
|
let mut c = blitstr::Cursor::new(0, 0, 0);
|
|
|
|
|
// now simulate the string painting
|
|
|
|
|
blitstr::paint_str(
|
|
|
|
|
display.native_buffer(),
|
|
|
|
|
clip,
|
|
|
|
|
&mut c,
|
|
|
|
|
tv.style.into(),
|
|
|
|
|
tv.text.as_str().unwrap(),
|
|
|
|
|
false,
|
|
|
|
|
None,
|
|
|
|
|
false,
|
|
|
|
|
blitstr::simulate_char
|
|
|
|
|
);
|
|
|
|
|
// the resulting cursor position + line_height + margin is the height of the bounds
|
|
|
|
|
let checkedheight: i16 = if (c.pt.y as i16 + c.line_height as i16 + (tv.margin.y as i16) * 2) <= (br.y - clip_rect.tl.y as i16) {
|
|
|
|
|
c.pt.y as i16 + c.line_height as i16 + 2 * tv.margin.y
|
|
|
|
|
} else {
|
|
|
|
|
br.y as i16 - clip_rect.tl.y as i16
|
|
|
|
|
};
|
|
|
|
|
// if less than one line of text, shrink the box
|
|
|
|
|
let finalwidth = if c.pt.y == 0 {
|
|
|
|
|
if c.pt.x as i16 + tv.margin.x * 3 < checkedwidth {
|
|
|
|
|
c.pt.x as i16 + tv.margin.x * 3
|
2021-03-09 16:25:14 +00:00
|
|
|
} else {
|
|
|
|
|
checkedwidth
|
|
|
|
|
}
|
2021-04-02 16:53:30 +00:00
|
|
|
} else {
|
|
|
|
|
checkedwidth
|
|
|
|
|
};
|
|
|
|
|
let tl = Point::new(br.x - finalwidth, br.y - checkedheight);
|
|
|
|
|
if clip_rect.intersects_point(tl) {
|
|
|
|
|
tv.bounds_computed = Some(Rectangle::new(
|
|
|
|
|
tl,
|
|
|
|
|
br
|
|
|
|
|
));
|
|
|
|
|
} else {
|
|
|
|
|
tv.bounds_computed = None;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
TextBounds::GrowableFromTl(_tl, _width) => {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
},
|
|
|
|
|
TextBounds::GrowableFromBl(bl, width) => {
|
|
|
|
|
if !clip_rect.intersects_point(bl) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// assume: clip_rect is the total canvas area we could draw
|
|
|
|
|
// assume: bl is the point we want to extend the drawable text bubble on
|
|
|
|
|
let checkedwidth: i16 = if width as i16 <= (clip_rect.br.x - bl.x) {
|
|
|
|
|
width as _
|
|
|
|
|
} else {
|
|
|
|
|
(clip_rect.br.x - bl.x) as _
|
|
|
|
|
};
|
|
|
|
|
// first, create a clip that's the width of the growable, but as big as the height of the screen
|
|
|
|
|
let clip = blitstr::ClipRect::new(0, 0, checkedwidth as _, display.screen_size().y as _);
|
|
|
|
|
let mut c = blitstr::Cursor::new(0, 0, 0);
|
|
|
|
|
// now simulate the string painting
|
|
|
|
|
blitstr::paint_str(
|
|
|
|
|
display.native_buffer(),
|
|
|
|
|
clip,
|
|
|
|
|
&mut c,
|
|
|
|
|
tv.style.into(),
|
|
|
|
|
tv.text.as_str().unwrap(),
|
|
|
|
|
false,
|
|
|
|
|
None,
|
|
|
|
|
false,
|
|
|
|
|
blitstr::simulate_char
|
|
|
|
|
);
|
|
|
|
|
// the resulting cursor position + line_height is the height of the bounds
|
|
|
|
|
let checkedheight: i16 = if (c.pt.y as i16 + c.line_height as i16 + 2 * tv.margin.y as i16) <= (bl.y as i16 - clip_rect.tl.y as i16) {
|
|
|
|
|
c.pt.y as i16 + c.line_height as i16 + 2 * tv.margin.y
|
|
|
|
|
} else {
|
|
|
|
|
bl.y as i16 - clip_rect.tl.y as i16
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// if less than one line of text, shrink the box
|
|
|
|
|
let finalwidth = if c.pt.y == 0 {
|
|
|
|
|
if c.pt.x as i16 + tv.margin.x * 3 < checkedwidth {
|
|
|
|
|
c.pt.x as i16 + tv.margin.x * 3
|
2021-03-09 16:25:14 +00:00
|
|
|
} else {
|
|
|
|
|
checkedwidth
|
|
|
|
|
}
|
2021-04-02 16:53:30 +00:00
|
|
|
} else {
|
|
|
|
|
checkedwidth
|
|
|
|
|
};
|
|
|
|
|
let tl = Point::new(bl.x, bl.y - checkedheight);
|
|
|
|
|
if clip_rect.intersects_point(tl) {
|
|
|
|
|
tv.bounds_computed = Some(Rectangle::new(
|
|
|
|
|
tl,
|
|
|
|
|
Point::new(bl.x + finalwidth, bl.y)
|
|
|
|
|
));
|
|
|
|
|
} else {
|
|
|
|
|
tv.bounds_computed = None
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-02-28 17:49:22 +00:00
|
|
|
}
|
2021-02-14 20:42:30 +00:00
|
|
|
}
|
2021-04-02 16:53:30 +00:00
|
|
|
if debugtv { log::info!("(TV): computed bounds {:?}", tv.bounds_computed); }
|
|
|
|
|
if tv.bounds_computed.is_none() {
|
|
|
|
|
// the bounds weren't valid, so don't draw
|
|
|
|
|
continue;
|
2021-02-28 20:01:33 +00:00
|
|
|
}
|
2021-04-02 16:53:30 +00:00
|
|
|
|
|
|
|
|
// clear the bounding box if requested
|
|
|
|
|
let mut clear_rect = tv.bounds_computed.unwrap();
|
|
|
|
|
|
|
|
|
|
// move things into screen coordinates
|
|
|
|
|
clear_rect.translate(screen_offset);
|
|
|
|
|
|
|
|
|
|
let bordercolor = if tv.draw_border {
|
|
|
|
|
Some(PixelColor::Dark)
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
};
|
|
|
|
|
let borderwidth: i16 = if tv.draw_border {
|
|
|
|
|
tv.border_width as i16
|
|
|
|
|
} else {
|
|
|
|
|
0
|
|
|
|
|
};
|
|
|
|
|
let fillcolor = if tv.clear_area {
|
|
|
|
|
Some(PixelColor::Light)
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
clear_rect.style = DrawStyle {
|
|
|
|
|
fill_color: fillcolor,
|
|
|
|
|
stroke_color: bordercolor,
|
|
|
|
|
stroke_width: borderwidth,
|
|
|
|
|
};
|
|
|
|
|
if tv.rounded_border.is_some() {
|
|
|
|
|
op::rounded_rectangle(display.native_buffer(),
|
|
|
|
|
RoundedRectangle::new(clear_rect, tv.rounded_border.unwrap() as _), Some(clear_rect));
|
|
|
|
|
} else {
|
|
|
|
|
if debugtv { log::trace!("(TV): clearing rectangle {:?}", clear_rect); }
|
|
|
|
|
op::rectangle(display.native_buffer(), clear_rect, tv.clip_rect);
|
2021-03-10 17:45:54 +00:00
|
|
|
}
|
2021-04-02 16:53:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// compute the final clipping region for the string
|
|
|
|
|
clear_rect.margin(tv.margin);
|
|
|
|
|
let cr = match clear_rect.clip_with(screen_clip) {
|
|
|
|
|
Some(r) => r,
|
|
|
|
|
_ => continue, // don't draw anything if somehow this doesn't fit in the creen.
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let mut ref_cursor = blitstr::Cursor::from_top_left_of(cr.into());
|
2021-04-06 14:38:11 +00:00
|
|
|
if debugtv { log::trace!("(TV): paint_str with {:?} | {:?} | {:?} | {:?} len: {}", cr, ref_cursor, tv.style, tv.text, tv.text.as_str().unwrap().len()); }
|
2021-04-16 10:57:34 +00:00
|
|
|
log::debug!("{}", tv);
|
2021-04-02 16:53:30 +00:00
|
|
|
blitstr::paint_str(
|
|
|
|
|
display.native_buffer(),
|
|
|
|
|
cr.into(),
|
|
|
|
|
&mut ref_cursor,
|
|
|
|
|
tv.style.into(),
|
|
|
|
|
tv.text.as_str().unwrap(),
|
|
|
|
|
false,
|
|
|
|
|
tv.insertion,
|
|
|
|
|
tv.ellipsis,
|
|
|
|
|
paintfn
|
|
|
|
|
);
|
|
|
|
|
// translate the cursor return value back to canvas coordinates
|
|
|
|
|
tv.cursor = blitstr::Cursor {
|
|
|
|
|
pt: blitstr::Pt::new(
|
|
|
|
|
ref_cursor.pt.x - screen_offset.x as i32,
|
|
|
|
|
ref_cursor.pt.y - screen_offset.y as i32,
|
|
|
|
|
),
|
|
|
|
|
line_height: ref_cursor.line_height,
|
|
|
|
|
};
|
|
|
|
|
if debugtv{log::trace!("(TV): returning cursor of {:?}", tv.cursor);}
|
|
|
|
|
|
|
|
|
|
// pack our data back into the buffer to return
|
|
|
|
|
buffer.replace(tv).unwrap();
|
|
|
|
|
}
|
|
|
|
|
Some(Opcode::Flush) => {
|
|
|
|
|
display.update();
|
|
|
|
|
display.redraw();
|
|
|
|
|
}
|
|
|
|
|
Some(Opcode::Clear) => {
|
|
|
|
|
let mut r = Rectangle::full_screen();
|
|
|
|
|
r.style = DrawStyle::new(PixelColor::Light, PixelColor::Light, 0);
|
2021-04-06 16:45:11 +00:00
|
|
|
op::rectangle(display.native_buffer(), r, screen_clip.into())
|
2020-08-29 14:09:20 +00:00
|
|
|
}
|
2021-04-02 16:53:30 +00:00
|
|
|
Some(Opcode::Line) => msg_scalar_unpack!(msg, p1, p2, style, _, {
|
|
|
|
|
let l = Line::new_with_style(Point::from(p1), Point::from(p2), DrawStyle::from(style));
|
2021-04-06 16:45:11 +00:00
|
|
|
op::line(display.native_buffer(), l, screen_clip.into());
|
2021-04-02 16:53:30 +00:00
|
|
|
}),
|
|
|
|
|
Some(Opcode::Rectangle) => msg_scalar_unpack!(msg, tl, br, style, _, {
|
|
|
|
|
let r = Rectangle::new_with_style(Point::from(tl), Point::from(br), DrawStyle::from(style));
|
2021-04-06 16:45:11 +00:00
|
|
|
op::rectangle(display.native_buffer(), r, screen_clip.into());
|
2021-04-02 16:53:30 +00:00
|
|
|
}),
|
|
|
|
|
Some(Opcode::RoundedRectangle) => msg_scalar_unpack!(msg, tl, br, style, r, {
|
|
|
|
|
let rr = RoundedRectangle::new(Rectangle::new_with_style(Point::from(tl), Point::from(br), DrawStyle::from(style)), r as _);
|
2021-04-06 16:45:11 +00:00
|
|
|
op::rounded_rectangle(display.native_buffer(), rr, screen_clip.into());
|
2021-04-02 16:53:30 +00:00
|
|
|
}),
|
|
|
|
|
Some(Opcode::Circle) => msg_scalar_unpack!(msg, center, radius, style, _, {
|
|
|
|
|
let c = Circle::new_with_style(Point::from(center), radius as _, DrawStyle::from(style));
|
2021-04-06 16:45:11 +00:00
|
|
|
op::circle(display.native_buffer(), c, screen_clip.into());
|
2021-04-02 16:53:30 +00:00
|
|
|
}),
|
|
|
|
|
Some(Opcode::ScreenSize) => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
|
|
|
|
let pt = display.screen_size();
|
2021-04-05 15:50:00 +00:00
|
|
|
xous::return_scalar2(msg.sender,
|
|
|
|
|
pt.x as usize,
|
|
|
|
|
pt.y as usize
|
|
|
|
|
).expect("couldn't return ScreenSize request");
|
2021-04-02 16:53:30 +00:00
|
|
|
}),
|
|
|
|
|
Some(Opcode::QueryGlyphProps) => msg_blocking_scalar_unpack!(msg, style, _, _, _, {
|
|
|
|
|
let glyph = GlyphStyle::from(style);
|
2021-04-05 15:50:00 +00:00
|
|
|
xous::return_scalar2(msg.sender,
|
2021-04-02 16:53:30 +00:00
|
|
|
glyph.into(),
|
2021-04-05 15:50:00 +00:00
|
|
|
blitstr::glyph_to_height_hint(glyph)
|
|
|
|
|
).expect("could not return QueryGlyphProps request");
|
2021-04-02 16:53:30 +00:00
|
|
|
}),
|
|
|
|
|
Some(Opcode::DrawSleepScreen) => msg_scalar_unpack!(msg, _, _, _, _, {
|
|
|
|
|
display.blit_screen(logo::LOGO_MAP);
|
|
|
|
|
display.update();
|
|
|
|
|
display.redraw();
|
|
|
|
|
}),
|
2021-04-05 15:50:00 +00:00
|
|
|
None => {log::error!("received opcode scalar that is not handled"); break}
|
2020-08-29 14:09:20 +00:00
|
|
|
}
|
2020-08-14 10:46:23 +00:00
|
|
|
display.update();
|
|
|
|
|
}
|
2021-04-05 15:50:00 +00:00
|
|
|
log::trace!("main loop exit, destroying servers");
|
|
|
|
|
xns.unregister_server(sid).unwrap();
|
|
|
|
|
xous::destroy_server(sid).unwrap();
|
|
|
|
|
log::trace!("quitting");
|
|
|
|
|
xous::terminate_process(); loop {}
|
2020-08-14 09:25:20 +00:00
|
|
|
}
|