diff --git a/CHANGELOG.md b/CHANGELOG.md index b40efe757f5..466926487c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Added +- The web status API (`/api/status`) reports a `temperatures` block: the chip temperature on ESP32-S3 devices, the battery fuel gauge's temperature on boards that have one (such as the X3), and on the X4 Pro the e-ink panel controller's own sensor, sampled after a screen refresh at most once a minute. Sensors a board lacks are left out. - View a selected book's reading stats from its Library or File Browser action menu. - Library replaces Recent Books with a searchable book list, and adds various book metadata sort options. - Reset a book's reader settings from the in-reader Settings tab. diff --git a/freeink-sdk b/freeink-sdk index ad146a56210..3c20ecf7871 160000 --- a/freeink-sdk +++ b/freeink-sdk @@ -1 +1 @@ -Subproject commit ad146a5621001a320c35f8f24dfd294a07959c3a +Subproject commit 3c20ecf78717ee791a0bc8852a04731079289745 diff --git a/src/network/CrossPointWebServer.cpp b/src/network/CrossPointWebServer.cpp index b716a5479ef..99743a285ea 100644 --- a/src/network/CrossPointWebServer.cpp +++ b/src/network/CrossPointWebServer.cpp @@ -17,12 +17,14 @@ #include #include #ifndef SIMULATOR +#include #include #include #endif #include #include +#include #include #include @@ -829,6 +831,35 @@ void CrossPointWebServer::handleStatus() const { static const BatteryMonitor monitor; battery["millivolts"] = monitor.readMillivolts(); battery["charging"] = monitor.isCharging(); + + // Temperatures in C, one entry per sensor the board has. The panel value + // is the UC8179's own sensor, sampled after a refresh at most once a + // minute; ageMs says how old it is. + JsonObject temps = doc["temperatures"].to(); +#if !CONFIG_IDF_TARGET_ESP32C3 // the C3's sensor driver costs ~3.8 KB of flash + const float chipC = temperatureRead(); + if (!std::isnan(chipC)) { + JsonObject t = temps["chip"].to(); + t["source"] = CONFIG_IDF_TARGET; + t["c"] = std::round(chipC * 10.0f) / 10.0f; + } +#endif + int16_t gaugeDeciC = 0; + if (monitor.readTemperatureDeciC(gaugeDeciC)) { + JsonObject t = temps["battery"].to(); + t["source"] = BoardConfig::ACTIVE.batteryGauge.gaugeType == BoardConfig::GaugeType::Cw2017 ? "cw2017" : "bq27220"; + t["c"] = gaugeDeciC / 10.0f; + } +#if FREEINK_UC8179_PANEL_TEMP + int8_t panelC = 0; + uint32_t panelAgeMs = 0; + if (freeink::uc8179PanelTemperature(panelC, panelAgeMs)) { + JsonObject t = temps["panel"].to(); + t["source"] = "uc8179"; + t["c"] = panelC; + t["ageMs"] = panelAgeMs; + } +#endif } #endif