src.nth.io/

summaryrefslogtreecommitdiff
path: root/main/http_api.c
diff options
context:
space:
mode:
authorLuke Hoersten <[email protected]>2026-07-15 19:18:32 -0500
committerLuke Hoersten <[email protected]>2026-07-15 19:18:32 -0500
commitf59cea3be9eed8d63fa44d4fd360c9c68e9318f6 (patch)
tree699a0b554d04600520505c9e5bf835f89663af9f /main/http_api.c
parent659da7f36473a21494693f031a39fb6bb977b90a (diff)
temp: report on-die temperature in /state and the info screen
New chip_temp module wraps the ESP32-P4 TSENS driver (20-100C range for best accuracy in the warm band a PoE + 200MHz-PSRAM device lives in). /state gains temp_c (0.1C resolution, omitted when the sensor is unavailable); the long-press info overlay gains a temp line (lowercase c suffix — the local 8x8 font has no uppercase C). Junction temperature, ~10-20C above ambient under load.
Diffstat (limited to 'main/http_api.c')
-rw-r--r--main/http_api.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/main/http_api.c b/main/http_api.c
index b9eade0..5e84db6 100644
--- a/main/http_api.c
+++ b/main/http_api.c
@@ -1,6 +1,7 @@
#include "http_api.h"
#include <inttypes.h>
+#include <math.h>
#include <stdio.h>
#include <string.h>
@@ -17,6 +18,7 @@
#include "esp_system.h"
#include "esp_timer.h"
+#include "chip_temp.h"
#include "display.h"
#include "jpeg_decoder.h"
#include "mdns_service.h"
@@ -78,6 +80,13 @@ static esp_err_t state_get_handler(httpd_req_t *req)
// prevented (would-have-torn count under double buffering).
cJSON_AddNumberToObject(root, "tear_guard_engaged",
(double)display_tear_guard_engaged());
+ // On-die junction temperature (°C, ~10-20° above ambient under
+ // load). Omitted entirely if the sensor is unavailable.
+ float temp_c = chip_temp_read();
+ if (!isnan(temp_c)) {
+ cJSON_AddNumberToObject(root, "temp_c",
+ round((double)temp_c * 10.0) / 10.0);
+ }
viewport_state_unlock();