improved telemetry link
reduced send speed and improved receive logic to recover faster a next step is to try forgoing tokio-serial and the codec trait for (hopefully) better real-time performance
This commit is contained in:
parent
ad1f552151
commit
ad82a25329
1 changed files with 32 additions and 13 deletions
|
|
@ -86,7 +86,7 @@ async fn main(spawner: Spawner) {
|
|||
|
||||
Timer::after_secs(13).await; // pi 0 serial ports act strange during the boot process
|
||||
|
||||
//spawner.spawn(bus_voltage_monitor(p.ADC, p.PIN_28, p.ADC_TEMP_SENSOR)).unwrap();
|
||||
spawner.spawn(bus_voltage_monitor(p.ADC, p.PIN_28, p.ADC_TEMP_SENSOR)).unwrap();
|
||||
|
||||
let config = embassy_rp::i2c::Config::default();
|
||||
let bus = embassy_rp::i2c::I2c::new_async(p.I2C1, p.PIN_19, p.PIN_18, Irqs, config);
|
||||
|
|
@ -173,7 +173,7 @@ async fn decoder(mut rx: BufferedUartRx<'static, UART1>) {
|
|||
#[embassy_executor::task]
|
||||
async fn telemetry(mut tx: BufferedUartTx<'static, UART1>) {
|
||||
info!("Telemetry waiting...");
|
||||
//COMMANDS.receiver().unwrap().get().await;
|
||||
COMMANDS.receiver().unwrap().get().await;
|
||||
info!("Telemetry started...");
|
||||
loop {
|
||||
let data = with_timeout(Duration::from_millis(20), SENSOR_DATA.receive()).await.ok();
|
||||
|
|
@ -221,13 +221,20 @@ async fn bus_voltage_monitor(adc: ADC, bus: PIN_28, temp: ADC_TEMP_SENSOR) {
|
|||
(rounded_temp_x10 as f32) / 10.0
|
||||
}
|
||||
|
||||
let mut i = 0;
|
||||
|
||||
loop {
|
||||
i += 1;
|
||||
let level = adc.read(&mut bus_voltage).await.unwrap();
|
||||
BUS_VOLTAGE.store(level, Ordering::Release);
|
||||
// empirically calculated against $20 microcenter voltmeter (10k & 33k divider circuit)
|
||||
SENSOR_DATA.send(SensorData::BusVoltage(level as f32 / BUS_ADC_TO_VOLTS)).await;
|
||||
let temp = adc.read(&mut ts).await.unwrap();
|
||||
SENSOR_DATA.send(SensorData::AmbientTemperature(convert_to_celsius(temp))).await;
|
||||
|
||||
if i % 10 == 0 { // only send telemetry every 30 milliseconds
|
||||
SENSOR_DATA.send(SensorData::BusVoltage(level as f32 / BUS_ADC_TO_VOLTS)).await;
|
||||
SENSOR_DATA.send(SensorData::AmbientTemperature(convert_to_celsius(temp))).await;
|
||||
}
|
||||
|
||||
Timer::after_millis(3).await;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue