aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPol Fernandez <[email protected]>2023-02-20 21:03:39 +0100
committerPol Fernandez <[email protected]>2023-02-20 21:03:39 +0100
commitf34829f534297dfccb1c5b206bffcc7700ef86ae (patch)
tree3727091a527e686e5ba701eb8f2eef506d321b96 /examples
parente3492862e994b0c46b23b486cae2935c2c0e05a0 (diff)
Add stringify function
Diffstat (limited to 'examples')
-rw-r--r--examples/rpi-pico-w/src/main.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/examples/rpi-pico-w/src/main.rs b/examples/rpi-pico-w/src/main.rs
index 71459a122..e71c22345 100644
--- a/examples/rpi-pico-w/src/main.rs
+++ b/examples/rpi-pico-w/src/main.rs
@@ -18,6 +18,9 @@ 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;
22
23
21macro_rules! singleton { 24macro_rules! singleton {
22 ($val:expr) => {{ 25 ($val:expr) => {{
23 type T = impl Sized; 26 type T = impl Sized;
@@ -129,7 +132,8 @@ async fn main(spawner: Spawner) {
129 } 132 }
130 }; 133 };
131 134
132 info!("rxd {:02x}", &buf[..n]); 135 info!("rxd {}", asciify(&buf[..n]));
136
133 137
134 match socket.write_all(&buf[..n]).await { 138 match socket.write_all(&buf[..n]).await {
135 Ok(()) => {} 139 Ok(()) => {}
@@ -214,3 +218,7 @@ impl SpiBusWrite<u32> for MySpi {
214 Ok(()) 218 Ok(())
215 } 219 }
216} 220}
221
222fn asciify(buf: &[u8],) -> String<4096> {
223 buf.into_iter().map(|c| *c as char).into_iter().collect()
224}