mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
refactor heapless version in attempt to debug issue that cropped up in xous-names
somehow, updating the toolchain has broken the FnvIndexMap implementation
This commit is contained in:
parent
b904a114fe
commit
391122823d
24 changed files with 64 additions and 141 deletions
88
Cargo.lock
generated
88
Cargo.lock
generated
|
|
@ -32,18 +32,6 @@ version = "1.0.38"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1"
|
||||
|
||||
[[package]]
|
||||
name = "as-slice"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0"
|
||||
dependencies = [
|
||||
"generic-array 0.12.4",
|
||||
"generic-array 0.13.3",
|
||||
"generic-array 0.14.4",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atomic-polyfill"
|
||||
version = "0.1.2"
|
||||
|
|
@ -193,7 +181,6 @@ name = "cb-test-c1"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cb-test-srv",
|
||||
"heapless 0.5.6",
|
||||
"log",
|
||||
"log-server",
|
||||
"num-derive",
|
||||
|
|
@ -211,7 +198,6 @@ name = "cb-test-c2"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cb-test-srv",
|
||||
"heapless 0.5.6",
|
||||
"log",
|
||||
"log-server",
|
||||
"num-derive",
|
||||
|
|
@ -320,7 +306,6 @@ dependencies = [
|
|||
name = "codec"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"heapless 0.5.6",
|
||||
"llio",
|
||||
"log",
|
||||
"log-server",
|
||||
|
|
@ -341,7 +326,7 @@ name = "com"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"com_rs-ref",
|
||||
"heapless 0.5.6",
|
||||
"heapless",
|
||||
"log",
|
||||
"log-server",
|
||||
"num-derive",
|
||||
|
|
@ -530,7 +515,7 @@ dependencies = [
|
|||
"com",
|
||||
"content-plugin-api",
|
||||
"graphics-server",
|
||||
"heapless 0.5.6",
|
||||
"heapless",
|
||||
"ime-plugin-api",
|
||||
"keyboard",
|
||||
"log",
|
||||
|
|
@ -547,34 +532,6 @@ dependencies = [
|
|||
"xous-names",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f797e67af32588215eaaab8327027ee8e71b9dd0b2b26996aedf20c030fce309"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.2"
|
||||
|
|
@ -597,7 +554,7 @@ name = "graphics-server"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"blitstr-ref",
|
||||
"hash32 0.1.1",
|
||||
"hash32",
|
||||
"hash32-derive",
|
||||
"keyboard",
|
||||
"log",
|
||||
|
|
@ -613,15 +570,6 @@ dependencies = [
|
|||
"xous-names",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hash32"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4041af86e63ac4298ce40e5cca669066e75b6f1aa3390fe2561ffa5e1d9f4cc"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hash32"
|
||||
version = "0.2.1"
|
||||
|
|
@ -642,18 +590,6 @@ dependencies = [
|
|||
"syn 0.13.11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heapless"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74911a68a1658cfcfb61bc0ccfbd536e3b6e906f8c2f7883ee50157e3e2184f1"
|
||||
dependencies = [
|
||||
"as-slice",
|
||||
"generic-array 0.13.3",
|
||||
"hash32 0.1.1",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heapless"
|
||||
version = "0.7.0"
|
||||
|
|
@ -661,7 +597,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "e94c13b78b595d2adbd708bce276664f1047f98fc32ddbf463b4c191158334a6"
|
||||
dependencies = [
|
||||
"atomic-polyfill",
|
||||
"hash32 0.2.1",
|
||||
"hash32",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
|
|
@ -734,7 +670,7 @@ dependencies = [
|
|||
name = "ime-plugin-shell"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"heapless 0.5.6",
|
||||
"heapless",
|
||||
"ime-plugin-api",
|
||||
"log",
|
||||
"log-server",
|
||||
|
|
@ -769,7 +705,7 @@ dependencies = [
|
|||
name = "keyboard"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"heapless 0.5.6",
|
||||
"heapless",
|
||||
"llio",
|
||||
"log",
|
||||
"log-server",
|
||||
|
|
@ -816,7 +752,7 @@ dependencies = [
|
|||
name = "llio"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"heapless 0.7.0",
|
||||
"heapless",
|
||||
"log",
|
||||
"log-server",
|
||||
"num-derive",
|
||||
|
|
@ -1304,7 +1240,6 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"bitflags",
|
||||
"chrono",
|
||||
"heapless 0.5.6",
|
||||
"llio",
|
||||
"log",
|
||||
"log-server",
|
||||
|
|
@ -1403,7 +1338,7 @@ dependencies = [
|
|||
"content-plugin-api",
|
||||
"gam",
|
||||
"graphics-server",
|
||||
"heapless 0.7.0",
|
||||
"heapless",
|
||||
"ime-plugin-api",
|
||||
"keyboard",
|
||||
"llio",
|
||||
|
|
@ -1549,7 +1484,7 @@ dependencies = [
|
|||
name = "ticktimer-server"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"heapless 0.5.6",
|
||||
"heapless",
|
||||
"log",
|
||||
"log-server",
|
||||
"num-derive",
|
||||
|
|
@ -1588,7 +1523,6 @@ dependencies = [
|
|||
name = "trng"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"heapless 0.5.6",
|
||||
"log",
|
||||
"log-server",
|
||||
"num-derive",
|
||||
|
|
@ -1910,9 +1844,9 @@ dependencies = [
|
|||
name = "xous-names"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"hash32 0.1.1",
|
||||
"hash32",
|
||||
"hash32-derive",
|
||||
"heapless 0.5.6",
|
||||
"heapless",
|
||||
"log",
|
||||
"log-server",
|
||||
"num-derive",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ description = "Callback Test Client 1"
|
|||
|
||||
[dependencies]
|
||||
xous = { path = "../../xous-rs" }
|
||||
heapless = "0.5.6"
|
||||
log-server = { path = "../log-server" }
|
||||
ticktimer-server = { path = "../ticktimer-server" }
|
||||
xous-names = { path = "../xous-names" }
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ description = "Callback Test Client 2"
|
|||
|
||||
[dependencies]
|
||||
xous = { path = "../../xous-rs" }
|
||||
heapless = "0.5.6"
|
||||
log-server = { path = "../log-server" }
|
||||
ticktimer-server = { path = "../ticktimer-server" }
|
||||
xous-names = { path = "../xous-names" }
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ description = "Audio CODEC server"
|
|||
|
||||
[dependencies]
|
||||
xous = { path = "../../xous-rs" }
|
||||
heapless = "0.5.6"
|
||||
log-server = { path = "../log-server" }
|
||||
ticktimer-server = { path = "../ticktimer-server" }
|
||||
xous-names = { path = "../xous-names" }
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ version = "0.1.0"
|
|||
|
||||
[dependencies]
|
||||
com_rs-ref = {path = "../../imports/com_rs-ref"}
|
||||
heapless = "0.5"
|
||||
heapless = "0.7"
|
||||
log = "0.4"
|
||||
log-server = {path = "../log-server"}
|
||||
ticktimer-server = {path = "../ticktimer-server"}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ mod implementation {
|
|||
use susres::{RegManager, RegOrField, SuspendResume};
|
||||
|
||||
use heapless::Vec;
|
||||
use heapless::consts::U64;
|
||||
|
||||
const STD_TIMEOUT: u32 = 100;
|
||||
|
||||
|
|
@ -49,7 +48,7 @@ mod implementation {
|
|||
csr: utralib::CSR<u32>,
|
||||
susres: RegManager::<{utra::com::COM_NUMREGS}>,
|
||||
ticktimer: ticktimer_server::Ticktimer,
|
||||
pub workqueue: Vec<WorkRequest, U64>,
|
||||
pub workqueue: Vec<WorkRequest, 64>,
|
||||
busy: bool,
|
||||
stby_current: Option<i16>,
|
||||
}
|
||||
|
|
@ -209,7 +208,7 @@ mod implementation {
|
|||
use heapless::consts::*;
|
||||
|
||||
pub struct XousCom {
|
||||
pub workqueue: Vec<WorkRequest, U64>,
|
||||
pub workqueue: Vec<WorkRequest, 64>,
|
||||
busy: bool,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ blitstr-ref = {path = "../../imports/blitstr-ref"}
|
|||
com = {path = "../com"}
|
||||
content-plugin-api = {path = "../content-plugin-api"}
|
||||
graphics-server = {path = "../graphics-server"}
|
||||
heapless = "0.5"
|
||||
heapless = "0.7"
|
||||
ime-plugin-api = {path = "../ime-plugin-api"}
|
||||
keyboard = {path = "../keyboard"}
|
||||
log = "0.4"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use core::cmp::Ordering;
|
||||
use heapless::binary_heap::{BinaryHeap, Max};
|
||||
use heapless::FnvIndexMap;
|
||||
use heapless::consts::*;
|
||||
use graphics_server::*;
|
||||
use log::{error, info};
|
||||
|
||||
|
|
@ -146,7 +145,7 @@ impl PartialEq for Canvas {
|
|||
impl Eq for Canvas {}
|
||||
|
||||
|
||||
pub fn deface(gfx: &graphics_server::Gfx, canvases: &mut FnvIndexMap<Gid, Canvas, U32>) -> Result<(), xous::Error> {
|
||||
pub fn deface(gfx: &graphics_server::Gfx, canvases: &mut FnvIndexMap<Gid, Canvas, 32>) -> Result<(), xous::Error> {
|
||||
// first check if any need defacing, if not, then we're done
|
||||
let mut needs_defacing = false;
|
||||
for (_, c) in canvases.iter() {
|
||||
|
|
@ -179,19 +178,19 @@ pub fn deface(gfx: &graphics_server::Gfx, canvases: &mut FnvIndexMap<Gid, Canvas
|
|||
}
|
||||
|
||||
// we use the "screen" parameter to determine when we can turn off drawing to canvases that are off-screen
|
||||
pub fn recompute_canvases(canvases: FnvIndexMap<Gid, Canvas, U32>, screen: Rectangle) -> FnvIndexMap<Gid, Canvas, U32> {
|
||||
pub fn recompute_canvases(canvases: FnvIndexMap<Gid, Canvas, 32>, screen: Rectangle) -> FnvIndexMap<Gid, Canvas, 32> {
|
||||
let debug = false;
|
||||
// first, sort canvases by trust_level. Canvas implements ord/eq based on the trust_level attribute
|
||||
// so jush pushing it into a max binary heap does the trick.
|
||||
if debug { info!("CANVAS: recompute canvas"); }
|
||||
let mut sorted_clipregions: BinaryHeap<Canvas, U32, Max> = BinaryHeap::new();
|
||||
let mut sorted_clipregions: BinaryHeap<Canvas, Max, 32> = BinaryHeap::new();
|
||||
for (&k, &c) in canvases.iter() {
|
||||
if debug { info!(" CANVAS: sorting gid {:?}, canvas {:?}", k, c);}
|
||||
sorted_clipregions.push(c).unwrap(); // always succeeds because incoming type is the same size
|
||||
}
|
||||
|
||||
// now, descend through trust levels and compute intersections, putting the updated drawable states into higher_clipregions
|
||||
let mut higher_clipregions: BinaryHeap<Canvas, U32, Max> = BinaryHeap::new();
|
||||
let mut higher_clipregions: BinaryHeap<Canvas, Max, 32> = BinaryHeap::new();
|
||||
let mut trust_level: u8 = 255;
|
||||
// sorted_clipregions is a Max heap keyed on trust, so popping the elements off will return them sorted from most to least trusted
|
||||
if debug{info!("CANVAS: received screen argument of {:?}", screen);}
|
||||
|
|
@ -227,7 +226,7 @@ pub fn recompute_canvases(canvases: FnvIndexMap<Gid, Canvas, U32>, screen: Recta
|
|||
}
|
||||
|
||||
// create a new index map out of the recomputed higher_clipregions
|
||||
let mut map: FnvIndexMap<Gid, Canvas, U32> = FnvIndexMap::new();
|
||||
let mut map: FnvIndexMap<Gid, Canvas, 32> = FnvIndexMap::new();
|
||||
if debug { info!("CANVAS: reconstituting index map");}
|
||||
for &c in higher_clipregions.iter() {
|
||||
if debug { info!(" CANVAS: inserting gid {:?}, canvas {:?}", c.gid(), c);}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ use content_plugin_api::{ContentCanvasConnection, ContentCanvasApi};
|
|||
use log::info;
|
||||
|
||||
use heapless::FnvIndexMap;
|
||||
use heapless::consts::*;
|
||||
|
||||
use num_traits::FromPrimitive;
|
||||
use xous_ipc::Buffer;
|
||||
|
|
@ -40,7 +39,7 @@ struct ChatLayout {
|
|||
gfx: graphics_server::Gfx,
|
||||
}
|
||||
impl ChatLayout {
|
||||
pub fn init(xns: &xous_names::XousNames, trng: &trng::Trng, canvases: &mut FnvIndexMap<Gid, Canvas, U32>) -> Result<ChatLayout, xous::Error> {
|
||||
pub fn init(xns: &xous_names::XousNames, trng: &trng::Trng, canvases: &mut FnvIndexMap<Gid, Canvas, 32>) -> Result<ChatLayout, xous::Error> {
|
||||
let gfx = graphics_server::Gfx::new(&xns).unwrap();
|
||||
let screensize = gfx.screen_size().expect("Couldn't get screen size");
|
||||
// get the height of various text regions to compute the layout
|
||||
|
|
@ -85,7 +84,7 @@ impl ChatLayout {
|
|||
gfx,
|
||||
})
|
||||
}
|
||||
pub fn clear(&self, canvases: &mut FnvIndexMap<Gid, Canvas, U32>) -> Result<(), xous::Error> {
|
||||
pub fn clear(&self, canvases: &mut FnvIndexMap<Gid, Canvas, 32>) -> Result<(), xous::Error> {
|
||||
let input_canvas = canvases.get(&self.input).expect("couldn't find input canvas");
|
||||
let content_canvas = canvases.get(&self.content).expect("couldn't find content canvas");
|
||||
let predictive_canvas = canvases.get(&self.predictive).expect("couldn't find predictive canvas");
|
||||
|
|
@ -108,7 +107,7 @@ impl ChatLayout {
|
|||
self.gfx.draw_rectangle(rect).expect("can't clear canvas");
|
||||
Ok(())
|
||||
}
|
||||
pub fn resize_input(&mut self, new_height: i16, canvases: &mut FnvIndexMap<Gid, Canvas, U32>) -> Result<Point, xous::Error> {
|
||||
pub fn resize_input(&mut self, new_height: i16, canvases: &mut FnvIndexMap<Gid, Canvas, 32>) -> Result<Point, xous::Error> {
|
||||
let input_canvas = canvases.get(&self.input).expect("couldn't find input canvas");
|
||||
let predictive_canvas = canvases.get(&self.predictive).expect("couldn't find predictive canvas");
|
||||
let status_canvas = canvases.get(&self.status).expect("couldn't find status canvas");
|
||||
|
|
@ -149,7 +148,7 @@ struct ModalCanvases {
|
|||
pub alert: Gid,
|
||||
}
|
||||
impl ModalCanvases {
|
||||
fn init(trng: &trng::Trng, canvases: &mut FnvIndexMap<Gid, Canvas, U32>) -> Result<ModalCanvases, xous::Error> {
|
||||
fn init(trng: &trng::Trng, canvases: &mut FnvIndexMap<Gid, Canvas, 32>) -> Result<ModalCanvases, xous::Error> {
|
||||
let password_canvas = Canvas::new(
|
||||
Rectangle::new_coords(-1, -1, -1, -1),
|
||||
255, &trng, None
|
||||
|
|
@ -196,7 +195,7 @@ fn xmain() -> ! {
|
|||
let screensize = gfx.screen_size().expect("Couldn't get screen size");
|
||||
|
||||
// a map of canvases accessable by Gid
|
||||
let mut canvases: FnvIndexMap<Gid, Canvas, U32> = FnvIndexMap::new();
|
||||
let mut canvases: FnvIndexMap<Gid, Canvas, 32> = FnvIndexMap::new();
|
||||
// let modallayout = ModalCanvases::init(trng, &mut canvases).expect("can't add modal layouts");
|
||||
let mut chatlayout = ChatLayout::init(&xns, &trng, &mut canvases).expect("couldn't create chat layout");
|
||||
chatlayout.clear(&mut canvases).expect("couldn't clear initial chatlayout");
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ version = "0.1.0"
|
|||
|
||||
[dependencies]
|
||||
blitstr-ref = {path = "../../imports/blitstr-ref"}
|
||||
hash32 = "0.1.0"
|
||||
hash32 = "0.2"
|
||||
hash32-derive = "0.1.0"
|
||||
keyboard = {path = "../keyboard"}
|
||||
log = "0.4"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ name = "ime-plugin-shell"
|
|||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
heapless = "0.5.6"
|
||||
heapless = "0.7"
|
||||
ime-plugin-api = {path = "../ime-plugin-api"}
|
||||
log = "0.4"
|
||||
log-server = {path = "../log-server"}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ use ime_plugin_api::*;
|
|||
|
||||
use log::{error, info};
|
||||
use heapless::spsc::Queue;
|
||||
use heapless::consts::U4;
|
||||
|
||||
use xous_ipc::{String, Buffer};
|
||||
use num_traits::FromPrimitive;
|
||||
|
|
@ -20,7 +19,7 @@ fn xmain() -> ! {
|
|||
let ime_sh_sid = xns.register_name(xous::names::SERVER_NAME_IME_PLUGIN_SHELL).expect("can't register server");
|
||||
log::trace!("registered with NS -- {:?}", ime_sh_sid);
|
||||
|
||||
let mut history: Queue<String<64>, U4> = Queue::new(); // this has 2^4 elements = 16??? or does it just have 4 elements.
|
||||
let mut history: Queue<String<64>, 4> = Queue::new(); // this has 2^4 elements = 16??? or does it just have 4 elements.
|
||||
let history_max = 4;
|
||||
|
||||
if false { // loads defaults into the predictor array to test things
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ xous-names = {path = "../xous-names"}
|
|||
llio = {path = "../llio"}
|
||||
susres = {path = "../susres"}
|
||||
|
||||
heapless = "0.5.6"
|
||||
heapless = "0.7"
|
||||
|
||||
num-derive = {version = "0.3", default-features = false}
|
||||
num-traits = {version = "0.2", default-features = false}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ mod api;
|
|||
use api::*;
|
||||
|
||||
use heapless::Vec;
|
||||
use heapless::consts::*;
|
||||
|
||||
use log::info;
|
||||
|
||||
|
|
@ -173,7 +172,6 @@ mod implementation {
|
|||
use susres::{RegManager, RegOrField, SuspendResume};
|
||||
|
||||
use heapless::Vec;
|
||||
use heapless::consts::*;
|
||||
|
||||
/// note: the code is structured to use at most 16 rows or 16 cols
|
||||
const KBD_ROWS: usize = 9;
|
||||
|
|
@ -401,7 +399,7 @@ mod implementation {
|
|||
krs
|
||||
}
|
||||
|
||||
pub fn track_chord(&mut self, keyups: Option<Vec<RowCol, U16>>, keydowns: Option<Vec<RowCol, U16>>) -> Vec<char, U4> {
|
||||
pub fn track_chord(&mut self, keyups: Option<Vec<RowCol, 16>>, keydowns: Option<Vec<RowCol, 16>>) -> Vec<char, 4> {
|
||||
/*
|
||||
Chording algorithm:
|
||||
|
||||
|
|
@ -420,7 +418,7 @@ mod implementation {
|
|||
}
|
||||
}
|
||||
log::trace!("self.chord: {:?}", self.chord);
|
||||
let mut keystates: Vec<char, U4> = Vec::new();
|
||||
let mut keystates: Vec<char, 4> = Vec::new();
|
||||
|
||||
let now = self.ticktimer.elapsed_ms();
|
||||
if was_idle && self.chord_active != 0 {
|
||||
|
|
@ -537,7 +535,7 @@ mod implementation {
|
|||
keystates
|
||||
}
|
||||
|
||||
pub fn track_keys(&mut self, keyups: Option<Vec<RowCol, U16>>, keydowns: Option<Vec<RowCol, U16>>) -> Vec<char, U4> {
|
||||
pub fn track_keys(&mut self, keyups: Option<Vec<RowCol, 16>>, keydowns: Option<Vec<RowCol, 16>>) -> Vec<char, 4> {
|
||||
/*
|
||||
"conventional" keyboard algorithm. The goals of this are to differentiate
|
||||
the cases of "shift", "alt", and "hold".
|
||||
|
|
@ -548,7 +546,7 @@ mod implementation {
|
|||
then for all others, we note the down time, and compare it to the current time
|
||||
to determine if a "hold" modifier applies
|
||||
*/
|
||||
let mut ks: Vec<char, U4> = Vec::new();
|
||||
let mut ks: Vec<char, 4> = Vec::new();
|
||||
|
||||
// first check for shift and alt keys
|
||||
if let Some(kds) = &keydowns {
|
||||
|
|
@ -584,9 +582,9 @@ mod implementation {
|
|||
}
|
||||
}
|
||||
}
|
||||
let keyups_noshift: Option<Vec<RowCol, U16>> =
|
||||
let keyups_noshift: Option<Vec<RowCol, 16>> =
|
||||
if let Some(kus) = &keyups {
|
||||
let mut ku_ns: Vec<RowCol, U16> = Vec::new();
|
||||
let mut ku_ns: Vec<RowCol, 16> = Vec::new();
|
||||
for &rc in kus.iter() {
|
||||
match self.map {
|
||||
KeyMap::Azerty => {
|
||||
|
|
@ -747,7 +745,6 @@ mod implementation {
|
|||
#[cfg(not(target_os = "none"))]
|
||||
mod implementation {
|
||||
use heapless::Vec;
|
||||
use heapless::consts::*;
|
||||
use crate::api::*;
|
||||
//use crate::{map_dvorak, map_qwerty};
|
||||
|
||||
|
|
@ -784,11 +781,11 @@ mod implementation {
|
|||
KeyRawStates::new()
|
||||
}
|
||||
|
||||
pub fn track_chord(&mut self, _keyups: Option<Vec<RowCol, U16>>, _keydowns: Option<Vec<RowCol, U16>>) -> Vec<char, U4> {
|
||||
pub fn track_chord(&mut self, _keyups: Option<Vec<RowCol, 16>>, _keydowns: Option<Vec<RowCol, 16>>) -> Vec<char, 4> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
pub fn track_keys(&mut self, _keyups: Option<Vec<RowCol, U16>>, _keydowns: Option<Vec<RowCol, U16>>) -> Vec<char, U4> {
|
||||
pub fn track_keys(&mut self, _keyups: Option<Vec<RowCol, 16>>, _keydowns: Option<Vec<RowCol, 16>>) -> Vec<char, 4> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
|
|
@ -935,8 +932,8 @@ fn xmain() -> ! {
|
|||
// and push(), len() etc. which doesn't really make sense to re-implement. But, maybe someone much
|
||||
// more clever than I could do extend RowColVec to have these feature and get rid of this ugly copy
|
||||
// step and make the rest of this routine operate natively on RowColVec types....
|
||||
let mut keyups_core: Vec<RowCol, U16> = Vec::new();
|
||||
let mut keydowns_core: Vec<RowCol, U16> = Vec::new();
|
||||
let mut keyups_core: Vec<RowCol, 16> = Vec::new();
|
||||
let mut keydowns_core: Vec<RowCol, 16> = Vec::new();
|
||||
for i in 0..rawstates.keyups.len() {
|
||||
if let Some(rc) = rawstates.keyups.get(i) {
|
||||
keyups_core.push(rc).unwrap();
|
||||
|
|
@ -960,7 +957,7 @@ fn xmain() -> ! {
|
|||
|
||||
// interpret scancodes
|
||||
// the track_* functions track the keyup/keydowns to modify keys with shift, hold, and chord state
|
||||
let kc: Vec<char, U4> = match kbd.get_map() {
|
||||
let kc: Vec<char, 4> = match kbd.get_map() {
|
||||
KeyMap::Braille => {
|
||||
kbd.track_chord(keyups, keydowns)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ description = "RTC server"
|
|||
|
||||
[dependencies]
|
||||
xous = { path = "../../xous-rs" }
|
||||
heapless = "0.5.6"
|
||||
log-server = { path = "../log-server" }
|
||||
ticktimer-server = { path = "../ticktimer-server" }
|
||||
xous-names = { path = "../xous-names" }
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ keyboard = {path = "../keyboard"}
|
|||
susres = {path = "../susres"}
|
||||
codec = {path = "../codec"}
|
||||
|
||||
heapless = "0.7.0"
|
||||
heapless = "0.7"
|
||||
trng = {path = "../trng"}
|
||||
|
||||
num-derive = {version = "0.3", default-features = false}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ impl<'a> ShellCmdApi<'a> for Audio {
|
|||
}
|
||||
"info" => {
|
||||
write!(ret, "Loaded sample is {}kHz, {} channels, {} format, {} bytes", self.header.sampling_rate, self.header.channel_count, self.header.audio_format, self.raw_len_bytes).unwrap();
|
||||
}
|
||||
}/*
|
||||
"dump" => {
|
||||
let mut temp = String::<9>::new();
|
||||
for i in 0..8 {
|
||||
|
|
@ -131,7 +131,7 @@ impl<'a> ShellCmdApi<'a> for Audio {
|
|||
ret.append(temp.to_str()).unwrap();
|
||||
temp.clear();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
_ => write!(ret, "{}", helpstring).unwrap(),
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ description = "Audio CODEC server"
|
|||
|
||||
[dependencies]
|
||||
xous = { path = "../../xous-rs" }
|
||||
heapless = "0.5.6"
|
||||
log-server = { path = "../log-server" }
|
||||
ticktimer-server = { path = "../ticktimer-server" }
|
||||
xous-names = { path = "../xous-names" }
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ name = "ticktimer-server"
|
|||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
heapless = "0.5"
|
||||
heapless = "0.7"
|
||||
log = "0.4"
|
||||
log-server = {path = "../log-server"}
|
||||
xous = {path = "../../xous-rs"}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
mod api;
|
||||
|
||||
use heapless::binary_heap::{BinaryHeap, Min};
|
||||
use heapless::consts::*;
|
||||
|
||||
use log::{error, info};
|
||||
|
||||
|
|
@ -447,7 +446,7 @@ use implementation::*;
|
|||
|
||||
fn recalculate_sleep(
|
||||
ticktimer: &mut XousTickTimer,
|
||||
sleep_heap: &mut BinaryHeap<SleepRequest, U32, Min>,
|
||||
sleep_heap: &mut BinaryHeap<SleepRequest, Min, 64>,
|
||||
new: Option<SleepRequest>,
|
||||
) {
|
||||
// If there's a sleep request ongoing now, grab it.
|
||||
|
|
@ -490,7 +489,7 @@ fn recalculate_sleep(
|
|||
|
||||
#[xous::xous_main]
|
||||
fn xmain() -> ! {
|
||||
let mut sleep_heap: BinaryHeap<SleepRequest, U32, Min> = BinaryHeap::new();
|
||||
let mut sleep_heap: BinaryHeap<SleepRequest, Min, 64> = BinaryHeap::new();
|
||||
|
||||
log_server::init_wait().unwrap();
|
||||
log::set_max_level(log::LevelFilter::Info);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ description = "TRNG server"
|
|||
|
||||
[dependencies]
|
||||
xous = { path = "../../xous-rs" }
|
||||
heapless = "0.5.6"
|
||||
log-server = { path = "../log-server" }
|
||||
ticktimer-server = { path = "../ticktimer-server" }
|
||||
xous-names = { path = "../xous-names" }
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ name = "xous-names"
|
|||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
hash32 = "0.1.0"
|
||||
hash32 = "0.2"
|
||||
hash32-derive = "0.1.0"
|
||||
heapless = "0.5"
|
||||
heapless = "0.7"
|
||||
num-derive = {version = "0.3", default-features = false}
|
||||
num-traits = {version = "0.2", default-features = false}
|
||||
log = "0.4"
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ pub(crate) struct AuthenticateRequest {
|
|||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct XousServerName {
|
||||
value: [u8; 64],
|
||||
length: u32,
|
||||
length: usize,
|
||||
}
|
||||
|
||||
impl Default for XousServerName {
|
||||
|
|
@ -84,12 +84,13 @@ impl XousServerName {
|
|||
}
|
||||
// Set the string length to the length of the passed-in String,
|
||||
// or the maximum possible length. Which ever is smaller.
|
||||
s.length = s.value.len().min(src.as_bytes().len()) as u32;
|
||||
s.length = s.value.len().min(src.as_bytes().len());
|
||||
|
||||
// If the string is not valid, set its length to 0.
|
||||
if s.as_str().is_err() {
|
||||
s.length = 0;
|
||||
}
|
||||
assert!(s.length < s.value.len(), "incorrect length derivation!");
|
||||
|
||||
s
|
||||
}
|
||||
|
|
@ -127,7 +128,8 @@ impl core::fmt::Write for XousServerName {
|
|||
if b.len() > self.value.len() {
|
||||
Err(core::fmt::Error)?;
|
||||
}
|
||||
self.length = b.len() as u32;
|
||||
self.length = b.len();
|
||||
assert!(self.length < self.value.len(), "incorrect length derivation!");
|
||||
|
||||
// Copy the string into this variable
|
||||
for (dest, src) in self.value.iter_mut().zip(s.bytes()) {
|
||||
|
|
@ -148,6 +150,7 @@ impl hash32::Hash for XousServerName {
|
|||
where
|
||||
H: Hasher,
|
||||
{
|
||||
assert!(self.length < self.value.len(), "incorret length on hash!");
|
||||
Hash::hash(&self.value[..self.length as usize], state);
|
||||
Hash::hash(&self.length, state)
|
||||
}
|
||||
|
|
@ -155,6 +158,8 @@ impl hash32::Hash for XousServerName {
|
|||
|
||||
impl PartialEq for XousServerName {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
assert!(self.length < self.value.len(), "incorret length on Eq!");
|
||||
assert!(other.length < other.value.len(), "incorrect length on Eq (other)!");
|
||||
self.value[..self.length as usize] == other.value[..other.length as usize]
|
||||
&& self.length == other.length
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ extern crate hash32_derive;
|
|||
mod api;
|
||||
use api::*;
|
||||
|
||||
// use heapless::String;
|
||||
use heapless::consts::*;
|
||||
use heapless::FnvIndexMap;
|
||||
|
||||
use num_traits::FromPrimitive;
|
||||
|
|
@ -61,9 +59,9 @@ mod implementation {
|
|||
#[xous::xous_main]
|
||||
fn xmain() -> ! {
|
||||
use implementation::*;
|
||||
let debug1 = false;
|
||||
let debug1 = true;
|
||||
log_server::init_wait().unwrap();
|
||||
log::set_max_level(log::LevelFilter::Info);
|
||||
log::set_max_level(log::LevelFilter::Trace);
|
||||
info!("my PID is {}", xous::process::id());
|
||||
|
||||
let name_server = xous::create_server_with_address(b"xous-name-server")
|
||||
|
|
@ -72,7 +70,7 @@ fn xmain() -> ! {
|
|||
let d11ctimeout = D11cTimeout::new();
|
||||
|
||||
// this limits the number of available servers to be requested to 128...!
|
||||
let mut name_table = FnvIndexMap::<_, _, U128>::new();
|
||||
let mut name_table = FnvIndexMap::<XousServerName, xous::SID, 128>::new();
|
||||
|
||||
info!("started");
|
||||
loop {
|
||||
|
|
@ -82,8 +80,8 @@ fn xmain() -> ! {
|
|||
Some(api::Opcode::Register) => {
|
||||
let mem = msg.body.memory_message_mut().unwrap();
|
||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) };
|
||||
let xous_string = buffer.as_flat::<String::<64>, _>().unwrap();
|
||||
let name = XousServerName::from_str(xous_string.as_str());
|
||||
let xous_string = buffer.to_original::<String::<64>, _>().unwrap();
|
||||
let name = XousServerName::from_str(xous_string.as_str().expect("couldn't convert server name to string"));
|
||||
|
||||
let response: api::Return;
|
||||
|
||||
|
|
@ -108,8 +106,8 @@ fn xmain() -> ! {
|
|||
Some(api::Opcode::Lookup) => {
|
||||
let mem = msg.body.memory_message_mut().unwrap();
|
||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) };
|
||||
let name_string = buffer.as_flat::<String::<64>, _>().unwrap();
|
||||
let name = XousServerName::from_str(name_string.as_str());
|
||||
let name_string = buffer.to_original::<String::<64>, _>().unwrap();
|
||||
let name = XousServerName::from_str(name_string.as_str().expect("couldn't convert server name to string"));
|
||||
if debug1{info!("Lookup request for '{}'", name);}
|
||||
let response: api::Return;
|
||||
if let Some(server_sid) = name_table.get(&name) {
|
||||
|
|
@ -146,7 +144,7 @@ fn xmain() -> ! {
|
|||
// no authenticate remedy currently supported, but we'd put that code somewhere around here eventually.
|
||||
let (c1, c2, c3, c4) = xous::create_server_id().unwrap().to_u32();
|
||||
let auth_request = AuthenticateRequest {
|
||||
name: String::<64>::from_str(name_string.as_str()),
|
||||
name: String::<64>::from_str(name_string.as_str().expect("couldn't convert server name to string")),
|
||||
pubkey_id: [0; 20], // placeholder
|
||||
challenge: [c1, c2, c3, c4],
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue