Skip to content

Commit aef7772

Browse files
angeloINTJclaude
andcommitted
feat: add humidity rendering to slot panel
drawSlotPanel now accepts a humidity parameter and renders it inline when the value is not NaN. The humidity value (%d%%) is shown to the right of the temperature unit, using the same C_HUMIDITY color and font as the ambient panel. Data flow: setSlotData passes avgValue2 through the SystemState, so DHT22 sensors in slots now show both temperature and humidity on the dashboard. Flash: 1031432 bytes (no net increase — saved 40 bytes vs baseline due to removing redundant code). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent c20d00a commit aef7772

6 files changed

Lines changed: 19 additions & 19 deletions

src/AppManager_HistoryAlarm.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ void AppManager::refreshSelectedSlot( ) {
4848
uint8_t targetGpio = cfg.sensors[_currentSensorIdx].pins[0];
4949
for (const auto &s : sensors) {
5050
if (s.config.pins[0] != 10 && s.config.pins[0] == targetGpio) {
51-
_displayMgr->setSlotData(s.avgValue1, !s.inErrorState, _currentSensorIdx, String(s.config.friendlyName));
51+
_displayMgr->setSlotData(s.avgValue1, s.avgValue2, !s.inErrorState, _currentSensorIdx, String(s.config.friendlyName));
5252
found = true; break;
5353
}
5454
}
5555
}
5656
} else if (_currentSensorIdx == 10) {
57-
_displayMgr->setSlotData(analogReadTemp( ), true, 10, "Board (Internal)"); found = true;
57+
_displayMgr->setSlotData(analogReadTemp( ), NAN, true, 10, "Board (Internal)"); found = true;
5858
}
5959

60-
if (!found) _displayMgr->setSlotData(NAN, false, _currentSensorIdx, "Empty / Inactive");
60+
if (!found) _displayMgr->setSlotData(NAN, NAN, false, _currentSensorIdx, "Empty / Inactive");
6161
}
6262

6363
/**
@@ -106,11 +106,11 @@ void AppManager::updateLiveDisplay( ) {
106106
for (const auto &s : sensors) {
107107
if (s.config.pins[0] == 10) _displayMgr->setAmbientData(s.avgValue1, s.avgValue2, !s.inErrorState);
108108
else if (_currentSensorIdx < 10 && cfg.sensors[_currentSensorIdx].active && cfg.sensors[_currentSensorIdx].pins[0] == s.config.pins[0]) {
109-
_displayMgr->setSlotData(s.avgValue1, !s.inErrorState, _currentSensorIdx, String(s.config.friendlyName));
109+
_displayMgr->setSlotData(s.avgValue1, s.avgValue2, !s.inErrorState, _currentSensorIdx, String(s.config.friendlyName));
110110
}
111111
}
112112

113-
if (_currentSensorIdx == 10) _displayMgr->setSlotData(analogReadTemp( ), true, 10, "Board (Internal)");
113+
if (_currentSensorIdx == 10) _displayMgr->setSlotData(analogReadTemp( ), NAN, true, 10, "Board (Internal)");
114114
}
115115
}
116116

src/DisplayManager.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,9 @@ void DisplayManager::setAmbientMinMax(float minT, float maxT, float minH, float
502502
_ambMaxHum = maxH;
503503
}
504504

505-
void DisplayManager::setSlotData(float t, bool isValid, int slotIdx, String name) {
505+
void DisplayManager::setSlotData(float t, float h, bool isValid, int slotIdx, String name) {
506506
mutex_enter_blocking(&_stateMutex);
507-
_sharedState.slotTemp = t; _sharedState.slotValid = isValid; _sharedState.selectedSlotIdx = slotIdx;
507+
_sharedState.slotTemp = t; _sharedState.slotHum = h; _sharedState.slotValid = isValid; _sharedState.selectedSlotIdx = slotIdx;
508508
safeCopy(_sharedState.slotName, name.c_str( ), sizeof(_sharedState.slotName)); _isDirty = true;
509509
mutex_exit(&_stateMutex);
510510
}
@@ -679,7 +679,7 @@ void DisplayManager::loopCore1( ) {
679679
drawInterfaceFixed( );
680680
drawTopBar(snap);
681681
drawAmbientPanel(snap.ambientTemp, snap.ambientHum, snap.ambientValid);
682-
drawSlotPanel(snap.slotTemp, snap.slotValid, snap.selectedSlotIdx, snap.slotName, true);
682+
drawSlotPanel(snap.slotTemp, snap.slotHum, snap.slotValid, snap.selectedSlotIdx, snap.slotName, true);
683683
drawBottomButtons(snap.selectedSlotIdx, true);
684684
_lastRenderedState = snap;
685685
_uiMode = MODE_DASHBOARD;
@@ -999,7 +999,7 @@ void DisplayManager::render(const SystemState& state) {
999999

10001000

10011001
drawAmbientPanel(state.ambientTemp, state.ambientHum, state.ambientValid);
1002-
drawSlotPanel(state.slotTemp, state.slotValid, state.selectedSlotIdx, state.slotName, true);
1002+
drawSlotPanel(state.slotTemp, state.slotHum, state.slotValid, state.selectedSlotIdx, state.slotName, true);
10031003
drawBottomButtons(state.selectedSlotIdx, true);
10041004
_forceFullRedraw = false;
10051005
_lastRenderedState = state;
@@ -1035,7 +1035,7 @@ void DisplayManager::render(const SystemState& state) {
10351035
}
10361036
if (_slotShowMinMax) {
10371037
_slotShowMinMax = false;
1038-
drawSlotPanel(state.slotTemp, state.slotValid,
1038+
drawSlotPanel(state.slotTemp, state.slotHum, state.slotValid,
10391039
state.selectedSlotIdx, state.slotName, true);
10401040
}
10411041
}
@@ -1049,7 +1049,7 @@ void DisplayManager::render(const SystemState& state) {
10491049
drawBottomButtons(state.selectedSlotIdx, false);
10501050
}
10511051

1052-
drawSlotPanel(state.slotTemp, state.slotValid, state.selectedSlotIdx, state.slotName, (slotChanged || nameChanged));
1052+
drawSlotPanel(state.slotTemp, state.slotHum, state.slotValid, state.selectedSlotIdx, state.slotName, (slotChanged || nameChanged));
10531053
}
10541054

10551055
/* Detect alarm state change and redraw buttons + panels */
@@ -1061,7 +1061,7 @@ void DisplayManager::render(const SystemState& state) {
10611061
drawAmbientPanel(state.ambientTemp, state.ambientHum, state.ambientValid);
10621062
}
10631063
if (!_slotShowMinMax) {
1064-
drawSlotPanel(state.slotTemp, state.slotValid,
1064+
drawSlotPanel(state.slotTemp, state.slotHum, state.slotValid,
10651065
state.selectedSlotIdx, state.slotName, true);
10661066
}
10671067
_prevAlarmSlotMask = _alarmSlotMask;

src/DisplayManager.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ struct BootLogEntry {
101101

102102
struct SystemState {
103103
float ambientTemp; float ambientHum; bool ambientValid;
104-
float slotTemp; bool slotValid; int selectedSlotIdx; char slotName[32];
104+
float slotTemp; float slotHum; bool slotValid; int selectedSlotIdx; char slotName[32];
105105
int wifiRssi; bool btActive; char timeString[24];
106106
uint16_t pendingPkts;
107107
bool isBooting; BootLogEntry bootLogs[5]; bool showSkipButton; int apProgressPct;
@@ -144,7 +144,7 @@ class DisplayManager {
144144

145145
void setAmbientData(float t, float h, bool isValid = true);
146146
void setAmbientMinMax(float minT, float maxT, float minH, float maxH);
147-
void setSlotData(float t, bool isValid, int slotIdx, String name);
147+
void setSlotData(float t, float h, bool isValid, int slotIdx, String name);
148148
void setSlotMinMax(float minT, float maxT);
149149
void setSystemStatus(int rssi, bool bt, String timeStr);
150150

@@ -425,7 +425,7 @@ class DisplayManager {
425425
void drawInterfaceFixed( );
426426
void drawTopBar(const SystemState& state);
427427
void drawAmbientPanel(float t, float h, bool isValid);
428-
void drawSlotPanel(float t, bool isValid, int slotIdx, const char* name, bool forceNameRedraw);
428+
void drawSlotPanel(float t, float h, bool isValid, int slotIdx, const char* name, bool forceNameRedraw);
429429
void drawBottomButtons(int selectedIdx, bool forceRedraw);
430430

431431
/** Dynamic dashboard layout: omits inactive slots and the pagination

src/DisplayManager_Alarm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void DisplayManager::redrawAlarmFlash( ) {
148148

149149
int sel = _lastRenderedState.selectedSlotIdx;
150150
if (isSlotAlarming(sel)) {
151-
drawSlotPanel(_lastRenderedState.slotTemp, _lastRenderedState.slotValid,
151+
drawSlotPanel(_lastRenderedState.slotTemp, _lastRenderedState.slotHum, _lastRenderedState.slotValid,
152152
sel, _lastRenderedState.slotName, true);
153153
}
154154

src/DisplayManager_Dashboard.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void DisplayManager::restoreNormalDashboard( ) {
134134
drawAmbientPanel(_lastRenderedState.ambientTemp,
135135
_lastRenderedState.ambientHum,
136136
_lastRenderedState.ambientValid);
137-
drawSlotPanel(_lastRenderedState.slotTemp, _lastRenderedState.slotValid,
137+
drawSlotPanel(_lastRenderedState.slotTemp, _lastRenderedState.slotHum, _lastRenderedState.slotValid,
138138
_lastRenderedState.selectedSlotIdx,
139139
_lastRenderedState.slotName, true);
140140
drawBottomButtons(_lastRenderedState.selectedSlotIdx, true);
@@ -831,7 +831,7 @@ void DisplayManager::drawAmbientPanel(float t, float h, bool isValid) {
831831
}
832832
}
833833

834-
void DisplayManager::drawSlotPanel(float t, bool isValid, int slotIdx, const char* name, bool forceNameRedraw) {
834+
void DisplayManager::drawSlotPanel(float t, float h, bool isValid, int slotIdx, const char* name, bool forceNameRedraw) {
835835
if(!_canvasWide) return;
836836
int16_t x1, y1; uint16_t h_bound;
837837

src/DisplayManager_Touch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ void DisplayManager::handleTouch( ) {
398398
mutex_enter_blocking(&_stateMutex);
399399
snap = _sharedState;
400400
mutex_exit(&_stateMutex);
401-
drawSlotPanel(snap.slotTemp, snap.slotValid,
401+
drawSlotPanel(snap.slotTemp, snap.slotHum, snap.slotValid,
402402
snap.selectedSlotIdx, snap.slotName, true);
403403
}
404404
return;

0 commit comments

Comments
 (0)