summaryrefslogtreecommitdiffstats
path: root/ble/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ble/src/main.rs')
-rw-r--r--ble/src/main.rs38
1 files changed, 10 insertions, 28 deletions
diff --git a/ble/src/main.rs b/ble/src/main.rs
index 3c98b7e..71e3b82 100644
--- a/ble/src/main.rs
+++ b/ble/src/main.rs
@@ -90,38 +90,20 @@ fn main() -> ! {
last_tick -= last_tick % 1024;
}
- if !twis_reader.is_empty() {
- let mut i = 0;
- for b in &mut twis_reader {
- if i == buf.len() {
- info!("i²c data: {:?}", &buf[0..i]);
- i = 0;
- }
- buf[i] = b;
- i += 1;
- }
- info!("i²c data: {:?}", &buf[0..i]);
+ let mut len = twis_reader.shift_into(&mut buf);
+ while len > 0 {
+ info!("i²c data: {:?}", &buf[0..len]);
+ len = twis_reader.shift_into(&mut buf);
}
- if !uarte1_reader.is_empty() {
- let mut i = 0;
- for b in &mut uarte1_reader {
- if i == buf.len() {
- info!(
- "serial - {}: {}",
- i,
- core::str::from_utf8(&buf[0..i]).expect("utf8conv")
- );
- i = 0;
- }
- buf[i] = b;
- i += 1;
- }
+ let mut len = uarte1_reader.shift_into(&mut buf);
+ while len > 0 {
info!(
- "serial - {}: {}",
- i,
- core::str::from_utf8(&buf[0..i]).expect("utf8conv")
+ "serial {}: {}",
+ len,
+ core::str::from_utf8(&buf[0..len]).expect("utf8conv")
);
+ len = uarte1_reader.shift_into(&mut buf);
}
wfi();
}