Switched to using ufmt for formatting
This commit is contained in:
parent
275dea77e9
commit
4fb98ee9c5
29
Cargo.lock
generated
29
Cargo.lock
generated
|
@ -732,6 +732,7 @@ dependencies = [
|
||||||
"rustc_version 0.4.0",
|
"rustc_version 0.4.0",
|
||||||
"spin",
|
"spin",
|
||||||
"stable_deref_trait",
|
"stable_deref_trait",
|
||||||
|
"ufmt-write",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1033,6 +1034,7 @@ dependencies = [
|
||||||
"nb 1.0.0",
|
"nb 1.0.0",
|
||||||
"panic-probe",
|
"panic-probe",
|
||||||
"ssd1306",
|
"ssd1306",
|
||||||
|
"ufmt",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1256,6 +1258,33 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ufmt"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1a64846ec02b57e9108d6469d98d1648782ad6bb150a95a9baac26900bbeab9d"
|
||||||
|
dependencies = [
|
||||||
|
"ufmt-macros",
|
||||||
|
"ufmt-write",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ufmt-macros"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d337d3be617449165cb4633c8dece429afd83f84051024079f97ad32a9663716"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ufmt-write"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
|
|
|
@ -21,8 +21,9 @@ cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
cortex-m-rt = "0.7.0"
|
cortex-m-rt = "0.7.0"
|
||||||
embedded-hal = "0.2.6"
|
embedded-hal = "0.2.6"
|
||||||
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
|
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
|
||||||
heapless = { version = "0.7.5", default-features = false }
|
heapless = { version = "0.7.5", default-features = false, features = ['ufmt-impl']}
|
||||||
nb = "1.0.0"
|
nb = "1.0.0"
|
||||||
|
ufmt = "0.2.0"
|
||||||
|
|
||||||
ssd1306 = "0.7.1"
|
ssd1306 = "0.7.1"
|
||||||
embedded-graphics = "0.7.1"
|
embedded-graphics = "0.7.1"
|
||||||
|
|
|
@ -17,8 +17,8 @@ use embedded_graphics::{
|
||||||
text::Text,
|
text::Text,
|
||||||
};
|
};
|
||||||
|
|
||||||
use core::fmt::Write;
|
|
||||||
use heapless::String;
|
use heapless::String;
|
||||||
|
use ufmt::uwrite;
|
||||||
|
|
||||||
use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306};
|
use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306};
|
||||||
|
|
||||||
|
@ -61,13 +61,13 @@ pub async fn display_task(
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let mut tmp: String<16> = String::new();
|
let mut tmp: String<16> = String::new();
|
||||||
write!(tmp, "AZ: {}", rotor_state.actual_pos.az).unwrap();
|
uwrite!(tmp, "AZ: {}", rotor_state.actual_pos.az).unwrap();
|
||||||
Text::new(&tmp, Point::new(1, 17), text_large)
|
Text::new(&tmp, Point::new(1, 17), text_large)
|
||||||
.draw(&mut display)
|
.draw(&mut display)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
tmp.clear();
|
tmp.clear();
|
||||||
write!(tmp, "EL: {}", rotor_state.actual_pos.el).unwrap();
|
uwrite!(tmp, "EL: {}", rotor_state.actual_pos.el).unwrap();
|
||||||
Text::new(&tmp, Point::new(64, 17), text_large)
|
Text::new(&tmp, Point::new(64, 17), text_large)
|
||||||
.draw(&mut display)
|
.draw(&mut display)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -78,13 +78,13 @@ pub async fn display_task(
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
tmp.clear();
|
tmp.clear();
|
||||||
write!(tmp, "AZ: {}", rotor_state.setpoint_pos.az).unwrap();
|
uwrite!(tmp, "AZ: {}", rotor_state.setpoint_pos.az).unwrap();
|
||||||
Text::new(&tmp, Point::new(1, 30), text_large_inv)
|
Text::new(&tmp, Point::new(1, 30), text_large_inv)
|
||||||
.draw(&mut display)
|
.draw(&mut display)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
tmp.clear();
|
tmp.clear();
|
||||||
write!(tmp, "EL: {}", rotor_state.setpoint_pos.el).unwrap();
|
uwrite!(tmp, "EL: {}", rotor_state.setpoint_pos.el).unwrap();
|
||||||
Text::new(&tmp, Point::new(64, 30), text_large_inv)
|
Text::new(&tmp, Point::new(64, 30), text_large_inv)
|
||||||
.draw(&mut display)
|
.draw(&mut display)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use defmt::Format;
|
use defmt::Format;
|
||||||
|
|
||||||
use core::fmt::Write;
|
|
||||||
use embassy_stm32::interrupt;
|
use embassy_stm32::interrupt;
|
||||||
use embassy_stm32::peripherals;
|
use embassy_stm32::peripherals;
|
||||||
use embassy_stm32::usb::Driver;
|
use embassy_stm32::usb::Driver;
|
||||||
|
@ -11,7 +10,9 @@ use embassy_util::channel::mpmc::{Receiver, Sender};
|
||||||
use embassy_util::{select, Either};
|
use embassy_util::{select, Either};
|
||||||
|
|
||||||
use futures::future::join;
|
use futures::future::join;
|
||||||
|
|
||||||
use heapless::String;
|
use heapless::String;
|
||||||
|
use ufmt::uwrite;
|
||||||
|
|
||||||
use crate::AzElPair;
|
use crate::AzElPair;
|
||||||
|
|
||||||
|
@ -101,13 +102,13 @@ pub async fn usb_task(
|
||||||
let mut resp: String<16> = String::new();
|
let mut resp: String<16> = String::new();
|
||||||
match cmd {
|
match cmd {
|
||||||
Gs232Cmd::GetAl => {
|
Gs232Cmd::GetAl => {
|
||||||
write!(&mut resp, "AZ={}\r", current_pos.az).unwrap();
|
uwrite!(&mut resp, "AZ={}\r", current_pos.az).unwrap();
|
||||||
}
|
}
|
||||||
Gs232Cmd::GetEz => {
|
Gs232Cmd::GetEz => {
|
||||||
write!(&mut resp, "EL={}\r", current_pos.el).unwrap();
|
uwrite!(&mut resp, "EL={}\r", current_pos.el).unwrap();
|
||||||
}
|
}
|
||||||
Gs232Cmd::GetAlEz => {
|
Gs232Cmd::GetAlEz => {
|
||||||
write!(&mut resp, "AZ={} EL={}\r", current_pos.az, current_pos.el)
|
uwrite!(&mut resp, "AZ={} EL={}\r", current_pos.az, current_pos.el)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
Gs232Cmd::MoveTo(_) => {
|
Gs232Cmd::MoveTo(_) => {
|
||||||
|
|
Loading…
Reference in a new issue