minor refinements requested on PR

This commit is contained in:
nworbnhoj 2022-04-24 20:09:43 +10:00
parent e879ff4b17
commit 2070236695
4 changed files with 11 additions and 11 deletions

View file

@ -20,7 +20,7 @@ gam = {path="../gam"}
trng = {path="../trng"}
tts-frontend = {path="../tts"}
locales = {path = "../../locales"}
bit_field = "0.10.1"
bit_field = "0.9.0"
[target.'cfg(not(any(windows,unix)))'.dependencies]
utralib = { path = "../../utralib"}

View file

@ -140,8 +140,8 @@ impl Modals {
self.unlock();
Ok(())
}
pub fn add_list(&mut self, items: Vec<&str>) -> Result<(), xous::Error> {
pub fn add_list(&self, items: Vec<&str>) -> Result<(), xous::Error> {
for (_, text) in items.iter().enumerate() {
self.add_list_item(text)
.or(Err(xous::Error::InternalError))?;
@ -172,16 +172,16 @@ impl Modals {
self.unlock();
Ok(String::from(itemname.as_str()))
}
pub fn get_radio_index(&self) -> Result<usize, xous::Error> {
let msg = Message::new_blocking_scalar(Opcode::GetModalIndex.to_usize().unwrap(), 0, 0, 0, 0);
match send_message(self.conn, msg) {
Ok(xous::Result::Scalar1(bitfield)) => {
let mut i = 0;
while (i < u32::BIT_LENGTH) & !bitfield.get_bit(i) {
while (i < u32::bit_length()) & !bitfield.get_bit(i) {
i = i + 1;
}
if i < u32::BIT_LENGTH {
if i < u32::bit_length() {
Ok(i)
} else {
Err(xous::Error::InternalError)
@ -209,14 +209,14 @@ impl Modals {
self.unlock();
Ok(ret)
}
pub fn get_check_index(&self) -> Result<Vec<usize>, xous::Error> {
let mut ret = Vec::<usize>::new();
let msg = Message::new_blocking_scalar(Opcode::GetModalIndex.to_usize().unwrap(), 0, 0, 0, 0);
match send_message(self.conn, msg) {
Ok(xous::Result::Scalar1(bitfield)) => {
let mut i = 0;
while i < u32::BIT_LENGTH {
while i < u32::bit_length() {
if bitfield.get_bit(i) {
ret.push(i);
}

View file

@ -113,7 +113,7 @@ fn xmain() -> ! {
Opcode::ModalKeypress.to_u32().unwrap(),
Opcode::ModalDrop.to_u32().unwrap(),
);
let mut list_hash = HashMap::<String, usize>::new();
let mut list_selected = 0u32;
@ -248,7 +248,7 @@ fn xmain() -> ! {
continue;
}
fixed_items.push(manageditem.item);
}
}
Some(Opcode::GetModalIndex) => {
xous::return_scalar(msg.sender, list_selected as usize).expect("couldn't return list selected");
}

View file

@ -31,7 +31,7 @@ pub(crate) fn spawn_test() {
thread::spawn({
move || {
let xns = XousNames::new().unwrap();
let mut modals = modals::Modals::new(&xns).unwrap();
let modals = modals::Modals::new(&xns).unwrap();
let tt = ticktimer_server::Ticktimer::new().unwrap();
// 1. test progress bar