Skip to content

Commit e1f70e8

Browse files
committed
CR151
1 parent 6251cea commit e1f70e8

4 files changed

Lines changed: 24 additions & 12 deletions

File tree

src/main/fc/settings.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3934,6 +3934,14 @@ groups:
39343934
field: osd_switch_indicators_align_left
39353935
type: bool
39363936
default_value: ON
3937+
# CR151
3938+
- name: multifunction_warning_cycle_time
3939+
description: "Cycle time for display of full multifunction warning messages [s]. Full messages will be displayed for 5s every cycle period. Set to 0 to constantly display full warnings."
3940+
field: multifunction_warning_cycle_time
3941+
min: 0
3942+
max: 60
3943+
default_value: 30
3944+
# CR151
39373945
- name: PG_OSD_COMMON_CONFIG
39383946
type: osdCommonConfig_t
39393947
headers: ["io/osd_common.h"]

src/main/io/osd.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4368,6 +4368,7 @@ PG_RESET_TEMPLATE(osdConfig_t, osdConfig,
43684368
.use_pilot_logo = SETTING_OSD_USE_PILOT_LOGO_DEFAULT,
43694369
.inav_to_pilot_logo_spacing = SETTING_OSD_INAV_TO_PILOT_LOGO_SPACING_DEFAULT,
43704370
.arm_screen_display_time = SETTING_OSD_ARM_SCREEN_DISPLAY_TIME_DEFAULT,
4371+
.multifunction_warning_cycle_time = SETTING_MULTIFUNCTION_WARNING_CYCLE_TIME_DEFAULT, // CR151
43714372

43724373
#ifdef USE_WIND_ESTIMATOR
43734374
.estimations_wind_compensation = SETTING_OSD_ESTIMATIONS_WIND_COMPENSATION_DEFAULT,
@@ -6471,7 +6472,8 @@ static bool osdCheckWarning(bool condition, uint8_t warningFlag, uint8_t *warnin
64716472
if (currentTimeMs > redisplayStartTimeMs) {
64726473
warningDisplayStartTime = currentTimeMs;
64736474
osdWarningTimerDuration = newWarningFlags ? 10000 : WARNING_REDISPLAY_DURATION;
6474-
redisplayStartTimeMs = currentTimeMs + osdWarningTimerDuration + 30000;
6475+
// redisplayStartTimeMs = currentTimeMs + osdWarningTimerDuration + 30000;
6476+
redisplayStartTimeMs = currentTimeMs + osdWarningTimerDuration + S2MS(osdConfig()->multifunction_warning_cycle_time); // CR151
64756477
}
64766478

64776479
if (currentTimeMs - warningDisplayStartTime < osdWarningTimerDuration) {
@@ -6568,15 +6570,15 @@ static textAttributes_t osdGetMultiFunctionMessage(char *buff)
65686570
const batteryState_e batteryVoltageState = checkBatteryVoltageState();
65696571
warningCondition = batteryVoltageState == BATTERY_CRITICAL || batteryVoltageState == BATTERY_WARNING;
65706572
if (osdCheckWarning(warningCondition, warningFlagID, &warningsCount)) {
6571-
messages[messageCount++] = batteryVoltageState == BATTERY_CRITICAL ? "VBATT CRIT" : "VBATT LOW ";
6573+
messages[messageCount++] = batteryVoltageState == BATTERY_CRITICAL ? "VBATT LAND" : "VBATT LOW ";
65726574
}
65736575

65746576
// Low Battery Capacity
65756577
if (batteryUsesCapacityThresholds()) {
65766578
const batteryState_e batteryState = getBatteryState();
6577-
warningCondition = batteryState == BATTERY_CRITICAL || batteryVoltageState == BATTERY_WARNING;
6579+
warningCondition = batteryState == BATTERY_CRITICAL || batteryState == BATTERY_WARNING;
65786580
if (osdCheckWarning(warningCondition, warningFlagID <<= 1, &warningsCount)) {
6579-
messages[messageCount++] = batteryState == BATTERY_CRITICAL ? "BATT EMPTY" : "BATT LOW ";
6581+
messages[messageCount++] = batteryState == BATTERY_CRITICAL ? "BATT EMPTY" : "BATT DYING";
65806582
}
65816583
}
65826584
#if defined(USE_GPS)
@@ -6642,7 +6644,6 @@ static textAttributes_t osdGetMultiFunctionMessage(char *buff)
66426644
if (messageCount) {
66436645
message = messages[OSD_ALTERNATING_CHOICES(1000, messageCount)]; // display each warning on 1s cycle
66446646
strcpy(buff, message);
6645-
TEXT_ATTRIBUTES_ADD_BLINK(elemAttr);
66466647
} else if (warningsCount) {
66476648
buff[0] = SYM_ALERT;
66486649
tfp_sprintf(buff + 1, "%u ", warningsCount);

src/main/io/osd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ typedef struct osdConfig_s {
529529
bool use_pilot_logo; // If enabled, the pilot logo (last 40 characters of page 2 font) will be used with the INAV logo.
530530
uint8_t inav_to_pilot_logo_spacing; // The space between the INAV and pilot logos, if pilot logo is used. This number may be adjusted so that it fits the odd/even col width.
531531
uint16_t arm_screen_display_time; // Length of time the arm screen is displayed
532+
uint8_t multifunction_warning_cycle_time; // Cycle time for display of full multifunction warning messages (s) CR151
532533
#ifndef DISABLE_MSP_DJI_COMPAT
533534
bool highlight_djis_missing_characters; // If enabled, show question marks where there is no character in DJI's font to represent an OSD element symbol
534535
#endif

src/main/sensors/battery.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,34 +324,36 @@ static void updateBatteryVoltage(timeUs_t timeDelta, bool justConnected)
324324
vbat = pt1FilterApply4(&vbatFilterState, vbat, VBATT_LPF_FREQ, US2S(timeDelta));
325325
}
326326
}
327-
327+
// CR151
328328
batteryState_e checkBatteryVoltageState(void)
329329
{
330330
uint16_t stateVoltage = getBatteryVoltage();
331-
switch (batteryState)
331+
static batteryState_e currentBatteryVoltageState = BATTERY_OK; // CR151
332+
333+
switch (currentBatteryVoltageState) // CR151
332334
{
333335
case BATTERY_OK:
334336
if (stateVoltage <= (batteryWarningVoltage - VBATT_HYSTERESIS)) {
335-
return BATTERY_WARNING;
337+
currentBatteryVoltageState = BATTERY_WARNING; // CR151
336338
}
337339
break;
338340
case BATTERY_WARNING:
339341
if (stateVoltage <= (batteryCriticalVoltage - VBATT_HYSTERESIS)) {
340-
return BATTERY_CRITICAL;
342+
currentBatteryVoltageState = BATTERY_CRITICAL; // CR151
341343
} else if (stateVoltage > (batteryWarningVoltage + VBATT_HYSTERESIS)){
342-
return BATTERY_OK;
344+
currentBatteryVoltageState = BATTERY_OK; // CR151
343345
}
344346
break;
345347
case BATTERY_CRITICAL:
346348
if (stateVoltage > (batteryCriticalVoltage + VBATT_HYSTERESIS)) {
347-
return BATTERY_WARNING;
349+
currentBatteryVoltageState = BATTERY_WARNING; // CR151
348350
}
349351
break;
350352
default:
351353
break;
352354
}
353355

354-
return batteryState;
356+
return currentBatteryVoltageState; // CR151
355357
}
356358

357359
static void checkBatteryCapacityState(void)

0 commit comments

Comments
 (0)