refactor: unify moisture handling, update config structure, and add peer dependencies
This commit is contained in:
@@ -7,7 +7,7 @@ use deranged::RangedU8;
|
||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
use embassy_sync::mutex::Mutex;
|
||||
use esp_hal::Persistable;
|
||||
use log::info;
|
||||
use log::{info, warn};
|
||||
use serde::Serialize;
|
||||
use strum_macros::IntoStaticStr;
|
||||
use unit_enum::UnitEnum;
|
||||
@@ -159,24 +159,41 @@ impl LogArray {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn limit_length<const LIMIT: usize>(input: &str, target: &mut heapless::String<LIMIT>) {
|
||||
for char in input.chars() {
|
||||
match target.push(char) {
|
||||
Ok(_) => {} //continue adding chars
|
||||
Err(_) => {
|
||||
//clear space for two asci chars
|
||||
info!("pushing char {char} to limit {LIMIT} current value {target} input {input}");
|
||||
while target.len() + 2 >= LIMIT {
|
||||
target.pop().unwrap();
|
||||
target.pop();
|
||||
}
|
||||
//add .. to shortened strings
|
||||
target.push('.').unwrap();
|
||||
target.push('.').unwrap();
|
||||
match target.push('.'){
|
||||
Ok(_) => {}
|
||||
Err(_) => {
|
||||
warn!("Error pushin . to limit {LIMIT} current value {target} input {input}")
|
||||
}
|
||||
}
|
||||
match target.push('.'){
|
||||
Ok(_) => {}
|
||||
Err(_) => {
|
||||
warn!("Error pushin . to limit {LIMIT} current value {target} input {input}")
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
while target.len() < LIMIT {
|
||||
target.push(' ').unwrap();
|
||||
match target.push(' ') {
|
||||
Ok(_) => {}
|
||||
Err(_) => {
|
||||
warn!("Error pushing space to limit {LIMIT} current value {target} input {input}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user