xous-core/examples/graphics-server/src/lib.rs
Sean Cross 8d438e4796 examples: graphics-server: use try_ calls for messaging
Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-30 17:40:29 +08:00

26 lines
868 B
Rust

#![cfg_attr(target_os = "none", no_std)]
pub mod api;
pub use api::{Point, Color};
use xous::{try_send_message, CID};
pub fn draw_line(cid: CID, start: Point, end: Point) -> Result<(), xous::Error> {
try_send_message(cid, api::Opcode::Line(start, end).into())
}
pub fn draw_circle(cid: CID, center: Point, radius: u32) -> Result<(), xous::Error> {
try_send_message(cid, api::Opcode::Circle(center, radius).into())
}
pub fn draw_rectangle(cid: CID, start: Point, end: Point) -> Result<(), xous::Error> {
try_send_message(cid, api::Opcode::Rectangle(start, end).into())
}
pub fn set_style(cid: CID, width: u32, stroke: Color, fill: Color) -> Result<(), xous::Error> {
try_send_message(cid, api::Opcode::Style(width, stroke, fill).into())
}
pub fn flush(cid: CID) -> Result<(), xous::Error> {
try_send_message(cid, api::Opcode::Flush.into())
}