Merge pull request #8025 from etracer65/osd_stats_maximize_lines
Maximize OSD stats display lines based on video mode
This commit is contained in:
commit
380889912f
|
@ -121,6 +121,7 @@ static uint8_t osdProfile = 1;
|
|||
static displayPort_t *osdDisplayPort;
|
||||
|
||||
static bool suppressStatsDisplay = false;
|
||||
static uint8_t osdStatsRowCount = 0;
|
||||
|
||||
#ifdef USE_ESC_SENSOR
|
||||
escSensorData_t *osdEscDataCombined;
|
||||
|
@ -472,13 +473,26 @@ static bool isSomeStatEnabled(void)
|
|||
// on the stats screen will have to be more beneficial than the hassle of not matching exactly to the
|
||||
// configurator list.
|
||||
|
||||
static void osdShowStats(uint16_t endBatteryVoltage)
|
||||
static uint8_t osdShowStats(uint16_t endBatteryVoltage, int statsRowCount)
|
||||
{
|
||||
uint8_t top = 2;
|
||||
uint8_t top = 0;
|
||||
char buff[OSD_ELEMENT_BUFFER_LENGTH];
|
||||
bool displayLabel = false;
|
||||
|
||||
displayClearScreen(osdDisplayPort);
|
||||
displayWrite(osdDisplayPort, 2, top++, " --- STATS ---");
|
||||
// if statsRowCount is 0 then we're running an initial analysis of the active stats items
|
||||
if (statsRowCount > 0) {
|
||||
const int availableRows = osdDisplayPort->rows;
|
||||
int displayRows = MIN(statsRowCount, availableRows);
|
||||
if (statsRowCount < availableRows) {
|
||||
displayLabel = true;
|
||||
displayRows++;
|
||||
}
|
||||
top = (availableRows - displayRows) / 2; // center the stats vertically
|
||||
}
|
||||
|
||||
if (displayLabel) {
|
||||
displayWrite(osdDisplayPort, 2, top++, " --- STATS ---");
|
||||
}
|
||||
|
||||
if (osdStatGetState(OSD_STAT_RTC_DATE_TIME)) {
|
||||
bool success = false;
|
||||
|
@ -613,6 +627,22 @@ static void osdShowStats(uint16_t endBatteryVoltage)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return top;
|
||||
}
|
||||
|
||||
static void osdRefreshStats(uint16_t endBatteryVoltage)
|
||||
{
|
||||
displayClearScreen(osdDisplayPort);
|
||||
if (osdStatsRowCount == 0) {
|
||||
// No stats row count has been set yet.
|
||||
// Go through the logic one time to determine how many stats are actually displayed.
|
||||
osdStatsRowCount = osdShowStats(endBatteryVoltage, 0);
|
||||
// Then clear the screen and commence with normal stats display which will
|
||||
// determine if the heading should be displayed and also center the content vertically.
|
||||
displayClearScreen(osdDisplayPort);
|
||||
}
|
||||
osdShowStats(endBatteryVoltage, osdStatsRowCount);
|
||||
}
|
||||
|
||||
static void osdShowArmed(void)
|
||||
|
@ -644,6 +674,7 @@ STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
|
|||
osdStatsEnabled = true;
|
||||
resumeRefreshAt = currentTimeUs + (60 * REFRESH_1S);
|
||||
endBatteryVoltage = getBatteryVoltage();
|
||||
osdStatsRowCount = 0; // reset to 0 so it will be recalculated on the next stats refresh
|
||||
}
|
||||
|
||||
armState = ARMING_FLAG(ARMED);
|
||||
|
@ -671,7 +702,7 @@ STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
|
|||
}
|
||||
if (currentTimeUs >= osdStatsRefreshTimeUs) {
|
||||
osdStatsRefreshTimeUs = currentTimeUs + REFRESH_1S;
|
||||
osdShowStats(endBatteryVoltage);
|
||||
osdRefreshStats(endBatteryVoltage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue