clean up warnings

This commit is contained in:
bunnie 2021-03-03 22:38:20 +08:00
parent 50b521266f
commit 313f12acbb
15 changed files with 46 additions and 56 deletions

10
Cargo.lock generated
View file

@ -534,6 +534,7 @@ dependencies = [
"heapless",
"log",
"log-server",
"rkyv",
"ticktimer-server",
"utralib",
"xous",
@ -547,6 +548,7 @@ dependencies = [
"heapless",
"log",
"log-server",
"rkyv",
"ticktimer-server",
"utralib",
"xous",
@ -559,6 +561,14 @@ version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
[[package]]
name = "kernel-test"
version = "0.1.0"
dependencies = [
"utralib",
"xous",
]
[[package]]
name = "keyboard"
version = "0.1.0"

View file

@ -1,7 +1,5 @@
use xous::{Message, ScalarMessage};
use graphics_server::api::{Point, Rectangle, TextView, TextViewResult, Gid, Line, RoundedRectangle, Circle};
use blitstr_ref as blitstr;
use blitstr::{GlyphStyle, Cursor};
use graphics_server::api::{Rectangle, TextView, Gid, Line, RoundedRectangle, Circle};
#[derive(Debug, rkyv::Archive, rkyv::Unarchive, Copy, Clone)]
pub enum GamObjectType {

View file

@ -1,13 +1,10 @@
use core::cmp::Ordering;
use heapless::binary_heap::{BinaryHeap, Max};
use heapless::FnvIndexMap;
use heapless::Vec;
use heapless::consts::*;
use graphics_server::*;
use log::{error, info};
use crate::api::*;
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum CanvasState {
// the initial state of every Canvas. Not drawable.
@ -41,6 +38,8 @@ pub struct Canvas {
// enables scroll/pan of objects within a region
pan_offset: Point,
}
#[allow(dead_code)]
impl Canvas {
pub fn new(clip_rect: Rectangle, trust_level: u8,
trng_conn: xous::CID, pan_offset: Option<Point>) -> Result<Canvas, xous::Error> {

View file

@ -5,17 +5,17 @@ use api::*;
use rkyv::Write;
use rkyv::Unarchive;
use graphics_server::api::{TextOp, TextView, TextViewResult};
use graphics_server::api::{TextOp, TextView};
use graphics_server::api::{Rectangle, Point, Gid, TextBounds, Line};
use log::{error, info};
use graphics_server::api::{Point, Gid, Line};
use log::info;
/// this "posts" a textview -- it's not a "draw" as the update is neither guaranteed nor instantaneous
/// the GAM first has to check that the textview is allowed to be updated, and then it will decide when
/// the actual screen update is allowed
pub fn post_textview(gam_cid: xous::CID, tv: &mut TextView) -> Result<(), xous::Error> {
tv.set_op(TextOp::Render);
let mut rkyv_tv = api::Opcode::RenderTextView(*tv);
let rkyv_tv = api::Opcode::RenderTextView(*tv);
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
let pos = writer.archive(&rkyv_tv).expect("GAM_API: couldn't archive textview");
let mut xous_buffer = writer.into_inner();
@ -39,14 +39,14 @@ pub fn post_textview(gam_cid: xous::CID, tv: &mut TextView) -> Result<(), xous::
}
pub fn draw_line(gam_cid: xous::CID, gid: Gid, line: Line) -> Result<(), xous::Error> {
let mut rkyv_tv = api::Opcode::RenderObject(
let rkyv_tv = api::Opcode::RenderObject(
GamObject {
canvas: gid,
obj: GamObjectType::Line(line),
});
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
let pos = writer.archive(&rkyv_tv).expect("GAM_API: couldn't archive GamObject");
let mut xous_buffer = writer.into_inner();
let xous_buffer = writer.into_inner();
xous_buffer.lend(gam_cid, pos as u32).expect("GAM_API: GamObject operation failure");

View file

@ -9,16 +9,13 @@ mod canvas;
use canvas::*;
use blitstr_ref as blitstr;
use blitstr::{Cursor, GlyphStyle};
use com::*;
use blitstr::GlyphStyle;
use graphics_server::*;
use log::{error, info};
use xous::String;
use log::info;
use core::convert::TryFrom;
use heapless::binary_heap::{BinaryHeap, Max};
use heapless::FnvIndexMap;
use heapless::consts::*;
@ -139,17 +136,17 @@ fn xmain() -> ! {
xous::create_thread_simple(status_thread, chatlayout.status.gid()).expect("GAM: couldn't create status thread");
// connect to the IME front end, and set its canvas
/*
info!("GAM: acquiring connection to IMEF...");
let imef_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_IME_FRONT).expect("GAM: can't connect to the IME front end");
ime_frontend::set_canvas(imef_conn, chatlayout.input.gid()).expect("GAM: couldn't set IMEF canvas");
ime_frontend::set_canvas(imef_conn, chatlayout.input).expect("GAM: couldn't set IMEF canvas");
*/
let mut last_time: u64 = ticktimer_server::elapsed_ms(ticktimer_conn).unwrap();
info!("GAM: entering main loop");
loop {
// /*
let maybe_env = xous::try_receive_message(gam_sid).unwrap();
match maybe_env {
Some(envelope) => { // */
Some(envelope) => {
// let envelope = xous::receive_message(gam_sid).unwrap();
if debug1 {info!("GAM: Message: {:?}", envelope); }
if let Ok(opcode) = Opcode::try_from(&envelope.body) {
@ -227,9 +224,6 @@ fn xmain() -> ! {
// silently fail if a bogus Gid is given???
}
},
TextOp::ComputeBounds => {
},
};
},
_ => panic!("GAM: invalid mutable borrow message"),
@ -249,16 +243,16 @@ fn xmain() -> ! {
if canvas.is_drawable() {
match obj.obj {
GamObjectType::Line(line) => {
graphics_server::draw_line(gfx_conn, line);
graphics_server::draw_line(gfx_conn, line).expect("GAM: couldn't draw line");
},
GamObjectType::Circ(circ) => {
graphics_server::draw_circle(gfx_conn, circ);
graphics_server::draw_circle(gfx_conn, circ).expect("GAM: couldn't draw circle");
},
GamObjectType::Rect(rect) => {
graphics_server::draw_rectangle(gfx_conn, rect);
graphics_server::draw_rectangle(gfx_conn, rect).expect("GAM: couldn't draw rectangle");
},
GamObjectType::RoundRect(rr) => {
graphics_server::draw_rounded_rectangle(gfx_conn, rr);
graphics_server::draw_rounded_rectangle(gfx_conn, rr).expect("GAM: couldn't draw rounded rectangle");
}
}
} else {
@ -278,13 +272,13 @@ fn xmain() -> ! {
},
_ => xous::yield_slice(),
// envelope implements Drop(), which includes a call to syscall::return_memory(self.sender, message.buf)
} // */
//graphics_server::flush(gfx_conn).expect("GAM: couldn't flush buffer to screen");
///*
}
if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) {
if elapsed_time - last_time > 33 { // rate limit updates to 30fps
last_time = elapsed_time;
graphics_server::flush(gfx_conn).expect("GAM: couldn't flush buffer to screen");
}
}//*/
}
}
}

View file

@ -1,5 +1,3 @@
use crate::api::*;
use log::{error, info};
use com::api::BattStats;
use graphics_server::*;
@ -18,7 +16,6 @@ pub fn status_thread(canvas_gid: [u32; 4]) {
let ticktimer_conn = xous::connect(xous::SID::from_bytes(b"ticktimer-server").unwrap()).unwrap();
let com_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_COM).expect("GAM|status: can't connect to COM");
let gfx_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_GFX).expect("GAM|status: can't connect to COM");
let gam_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_GAM).expect("GAM|status: can't connect to GAM");
if debug1{info!("GAM|status: getting screen size");}
@ -46,7 +43,7 @@ pub fn status_thread(canvas_gid: [u32; 4]) {
battstats_tv.draw_border = false;
battstats_tv.margin = Point::new(0, 0);
let mut stats: BattStats = BattStats::default();
let mut stats: BattStats;
let mut last_time: u64 = ticktimer_server::elapsed_ms(ticktimer_conn).unwrap();
let mut stats_phase: usize = 0;
let mut last_seconds: usize = ((last_time / 1000) % 60) as usize;

View file

@ -2,7 +2,7 @@ use crate::op::{HEIGHT, WIDTH};
use crate::api::{Point, DrawStyle};
use blitstr_ref as blitstr;
use blitstr::{ClipRect};
use core::{cmp::{max, min}, ops::Add};
use core::{cmp::{max, min}};
#[derive(Debug, Clone, Copy, rkyv::Archive, rkyv::Unarchive)]
pub struct Rectangle {

View file

@ -2,8 +2,6 @@ use crate::api::{Point, Rectangle, Gid};
use blitstr_ref as blitstr;
use blitstr::{GlyphStyle, Cursor};
use log::info;
/// coordinates are local to the canvas, not absolute to the screen
#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Unarchive)]
pub enum TextBounds {
@ -46,12 +44,6 @@ impl From<usize> for TextOp {
// roughly 168 bytes to represent the rest of the struct, and we want to fill out the 4096 byte page with text
const TEXTVIEW_LEN: usize = 3072;
#[derive(Copy, Clone, rkyv::Archive, Debug, rkyv::Unarchive)]
pub struct TextViewResult {
pub bounds_computed: Option<Rectangle>,
pub cursor: Cursor,
}
#[derive(Copy, Clone, rkyv::Archive, rkyv::Unarchive)]
pub struct TextView {
// this is the operation as specified for the GAM. Note this is different from the "op" when sent to graphics-server

View file

@ -120,7 +120,7 @@ pub fn draw_textview(cid: CID, tv: &mut TextView) -> Result<(), xous::Error> {
use rkyv::Write;
use rkyv::Unarchive;
let mut rkyv_tv = api::Opcode::DrawTextView(*tv);
let rkyv_tv = api::Opcode::DrawTextView(*tv);
let mut writer = rkyv::ArchiveBuffer::new(xous::XousBuffer::new(4096));
let pos = writer.archive(&rkyv_tv).expect("couldn't archive textview");
let mut xous_buffer = writer.into_inner();

View file

@ -8,7 +8,6 @@ use api::Opcode;
use core::pin::Pin;
use rkyv::{archived_value, Unarchive, archived_value_mut};
use core::convert::TryInto;
mod backend;
use backend::XousDisplay;
@ -163,13 +162,13 @@ fn xmain() -> ! {
TextBounds::BoundingBox(r) => {
tv.bounds_computed = Some(r);
},
TextBounds::GrowableFromBr(br, width) => {
TextBounds::GrowableFromBr(_br, _width) => {
unimplemented!()
},
TextBounds::GrowableFromTl(tl, width) => {
TextBounds::GrowableFromTl(_tl, _width) => {
unimplemented!()
},
TextBounds::GrowableFromBl(bl, width) => {
TextBounds::GrowableFromBl(_bl, _width) => {
unimplemented!()
}
}

View file

@ -1,6 +1,4 @@
use crate::api::{Circle, DrawStyle, Line, Pixel, PixelColor, Point, Rectangle, TextView, RoundedRectangle};
use log::info;
use blitstr_ref as blitstr;
use crate::api::{Circle, DrawStyle, Line, Pixel, PixelColor, Point, Rectangle, RoundedRectangle};
/// LCD Frame buffer bounds
pub const LCD_WORDS_PER_LINE: usize = 11;
@ -456,7 +454,7 @@ impl Iterator for RoundedRectangleIterator {
}
pub fn rounded_rectangle(fb: &mut LcdFB, rr: RoundedRectangle) {
/// left off: compute the four quadrants
// compute the four quadrants
// call the rr iterator on the rectangle
// then call it on one each of the four circle quadrants

View file

@ -13,6 +13,7 @@ ticktimer-server = { path = "../ticktimer-server" }
xous-names = { path = "../xous-names" }
graphics-server = {path = "../graphics-server"}
log = "0.4"
rkyv = { version = "0.3.1", default_features = false }
[target.'cfg(not(any(windows,unix)))'.dependencies]

View file

@ -9,7 +9,7 @@ pub enum Opcode {
SetCanvas(Gid),
/// set prediction. Must be a String of the name of a server that is loaded in the system.
SetPrediction(xous::String),
SetPrediction(xous::String<256>),
}
impl core::convert::TryFrom<& Message> for Opcode {
@ -17,7 +17,7 @@ impl core::convert::TryFrom<& Message> for Opcode {
fn try_from(message: & Message) -> Result<Self, Self::Error> {
match message {
Message::Scalar(m) => match m.id {
0 => Ok(Opcode::GetTrng(m.arg1)),
0 => Ok(Opcode::SetCanvas(Gid::new([m.arg1 as _, m.arg2 as _, m.arg3 as _, m.arg4 as _]))),
_ => Err("IMEF api: unknown Scalar ID"),
},
_ => Err("IMEF api: unhandled message type"),

View file

@ -5,4 +5,5 @@ use xous::{CID, send_message};
pub fn set_canvas(cid: CID, g: graphics_server::Gid) -> Result<(), xous::Error> {
send_message(cid, api::Opcode::SetCanvas(g).into())?;
Ok(())
}

View file

@ -12,6 +12,7 @@ log-server = { path = "../log-server" }
ticktimer-server = { path = "../ticktimer-server" }
xous-names = { path = "../xous-names" }
log = "0.4"
rkyv = { version = "0.3.1", default_features = false }
[target.'cfg(not(any(windows,unix)))'.dependencies]