Fixes
This commit is contained in:
parent
31471fb6ce
commit
c30a3ef4e7
@ -292,11 +292,29 @@ bool HistoryStore::fillChartSeries(uint16_t groupAddr, TextSource source, ChartP
|
||||
xSemaphoreGive(mutex_);
|
||||
|
||||
bool hasData = false;
|
||||
int32_t lastValidValue = NO_POINT;
|
||||
|
||||
// Optimization: Try to find a starting value from before the window if index 0 is empty?
|
||||
// For now, simple forward-fill (step) is sufficient to connect sparse points.
|
||||
|
||||
for (size_t i = 0; i < outCount; ++i) {
|
||||
if (counts[i] > 0) {
|
||||
float avg = sums[i] / counts[i];
|
||||
outValues[i] = static_cast<int32_t>(lrintf(avg));
|
||||
int32_t val = static_cast<int32_t>(lrintf(avg));
|
||||
outValues[i] = val;
|
||||
lastValidValue = val;
|
||||
hasData = true;
|
||||
} else {
|
||||
// No data in this bucket.
|
||||
// Use the last valid value to draw a connected line (Step Hold).
|
||||
// If we haven't seen any data yet (lastValidValue == NO_POINT),
|
||||
// we leave it as NO_POINT (gap at start).
|
||||
outValues[i] = lastValidValue;
|
||||
|
||||
// If we just filled with a valid value, count it as having data
|
||||
if (lastValidValue != NO_POINT) {
|
||||
hasData = true; // Ensures y-scaling considers this flat line
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user