fix(ui): the chip's temperature when no sensor reads one

The telemetry reply adds the MCU temperature, the screens read only the
sensors: on a board without a temperature sensor (the L1) the app showed
a temperature and the clock field '--'. The clock, Status and the L2's
Home now fall back to the chip's, like the reply. The bot's !temp and
{temp} still read only the sensors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-23 22:33:52 +02:00
co-authored by Claude Opus 5.5
parent 467d64af40
commit d2e1f086e2
4 changed files with 21 additions and 4 deletions
@@ -7,6 +7,8 @@
#include <stdint.h>
#include <stdio.h>
#include <math.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/LPPDataHelpers.h>
#include <helpers/sensors/LocationProvider.h>
#include "Battery.h"
@@ -64,6 +66,21 @@ static uint8_t lppType(uint8_t f) {
// Read from the sensors, not the radio or GPS.
static bool isSensor(uint8_t f) { return lppType(f) != 0; }
// The sensors' readings, plus the chip's own temperature (NaN where a board has
// none) when no sensor reads one: the telemetry reply sends it too, so a board
// without a temperature sensor shows on screen what the app shows.
static void querySensors(SensorManager& sm, float mcu_temp, CayenneLPP& lpp) {
sm.querySensors(0xFF, lpp);
if (isnan(mcu_temp)) return;
LPPReader r(lpp.getBuffer(), lpp.getSize());
uint8_t ch, type;
while (r.readHeader(ch, type)) {
if (type == LPP_TEMPERATURE) return;
r.skipData(type);
}
lpp.addTemperature(TELEM_CHANNEL_SELF, mcu_temp);
}
// Altitude always in the small unit (never km / mi).
static void altText(float m, bool imperial, const Style& st, char* v, int n) {
snprintf(v, n, "%.0f%s%s", imperial ? m * 3.28084f : m, st.spaced ? " " : "", imperial ? "ft" : "m");