aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPol Fernandez <[email protected]>2023-02-21 08:52:57 +0100
committerPol Fernandez <[email protected]>2023-02-21 08:52:57 +0100
commitf6f041b05d9702982e3cf56bb76f7904485677c8 (patch)
tree21fc5b9b1b9f9fd6b2d38e00ac4da2758cf65c28 /examples
parentf34829f534297dfccb1c5b206bffcc7700ef86ae (diff)
Add from_utf8
Diffstat (limited to 'examples')
-rw-r--r--examples/rpi-pico-w/src/main.rs11
1 files changed, 3 insertions, 8 deletions
diff --git a/examples/rpi-pico-w/src/main.rs b/examples/rpi-pico-w/src/main.rs
index e71c22345..c706e121d 100644
--- a/examples/rpi-pico-w/src/main.rs
+++ b/examples/rpi-pico-w/src/main.rs
@@ -1,4 +1,4 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4#![feature(async_fn_in_trait)] 4#![feature(async_fn_in_trait)]
@@ -18,8 +18,7 @@ use embedded_io::asynch::Write;
18use static_cell::StaticCell; 18use static_cell::StaticCell;
19use {defmt_rtt as _, panic_probe as _}; 19use {defmt_rtt as _, panic_probe as _};
20 20
21use heapless::String; 21use core::str::from_utf8;
22
23 22
24macro_rules! singleton { 23macro_rules! singleton {
25 ($val:expr) => {{ 24 ($val:expr) => {{
@@ -132,7 +131,7 @@ async fn main(spawner: Spawner) {
132 } 131 }
133 }; 132 };
134 133
135 info!("rxd {}", asciify(&buf[..n])); 134 info!("rxd {}", from_utf8(&buf[..n]).unwrap());
136 135
137 136
138 match socket.write_all(&buf[..n]).await { 137 match socket.write_all(&buf[..n]).await {
@@ -218,7 +217,3 @@ impl SpiBusWrite<u32> for MySpi {
218 Ok(()) 217 Ok(())
219 } 218 }
220} 219}
221
222fn asciify(buf: &[u8],) -> String<4096> {
223 buf.into_iter().map(|c| *c as char).into_iter().collect()
224}