diff options
| author | Pol Fernandez <[email protected]> | 2023-02-20 21:03:39 +0100 |
|---|---|---|
| committer | Pol Fernandez <[email protected]> | 2023-02-20 21:03:39 +0100 |
| commit | f34829f534297dfccb1c5b206bffcc7700ef86ae (patch) | |
| tree | 3727091a527e686e5ba701eb8f2eef506d321b96 /examples | |
| parent | e3492862e994b0c46b23b486cae2935c2c0e05a0 (diff) | |
Add stringify function
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rpi-pico-w/src/main.rs | 10 |
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; | |||
| 18 | use static_cell::StaticCell; | 18 | use static_cell::StaticCell; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 20 | ||
| 21 | use heapless::String; | ||
| 22 | |||
| 23 | |||
| 21 | macro_rules! singleton { | 24 | macro_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 | |||
| 222 | fn asciify(buf: &[u8],) -> String<4096> { | ||
| 223 | buf.into_iter().map(|c| *c as char).into_iter().collect() | ||
| 224 | } | ||
