Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSD: display power >1000W in kW #6796

Merged
merged 2 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/drivers/osd_symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@
#define SYM_SNR 0xEE // SNR
#define SYM_MW 0xED // mW

#define SYM_KILOWATT 0xEF // 239 kW


#else

#define TEMP_SENSOR_SYM_COUNT 0
Expand Down
19 changes: 10 additions & 9 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ static float GForce, GForceAxis[XYZ_AXIS_COUNT];
typedef struct statistic_s {
uint16_t max_speed;
uint16_t min_voltage; // /100
int16_t max_current; // /100
int16_t max_power; // /100
int16_t max_current;
int32_t max_power;
int16_t min_rssi;
int16_t min_lq; // for CRSF
int16_t min_rssi_dbm; // for CRSF
Expand Down Expand Up @@ -2136,8 +2136,8 @@ static bool osdDrawSingleElement(uint8_t item)

case OSD_POWER:
{
osdFormatCentiNumber(buff, getPower(), 0, 2, 0, 3);
buff[3] = SYM_WATT;
bool kiloWatt = osdFormatCentiNumber(buff, getPower(), 1000, 2, 2, 3);
buff[3] = kiloWatt ? SYM_KILOWATT : SYM_WATT;
buff[4] = '\0';

uint8_t current_alarm = osdConfig()->current_alarm;
Expand Down Expand Up @@ -3032,11 +3032,11 @@ static void osdUpdateStats(void)
if (stats.min_voltage > value)
stats.min_voltage = value;

value = abs(getAmperage() / 100);
value = abs(getAmperage());
if (stats.max_current < value)
stats.max_current = value;

value = abs(getPower() / 100);
value = abs(getPower());
if (stats.max_power < value)
stats.max_power = value;

Expand Down Expand Up @@ -3139,13 +3139,14 @@ static void osdShowStatsPage2(void)

if (feature(FEATURE_CURRENT_METER)) {
displayWrite(osdDisplayPort, statNameX, top, "MAX CURRENT :");
itoa(stats.max_current, buff, 10);
osdFormatCentiNumber(buff, stats.max_current, 0, 2, 0, 3);
tfp_sprintf(buff, "%s%c", buff, SYM_AMP);
displayWrite(osdDisplayPort, statValuesX, top++, buff);

displayWrite(osdDisplayPort, statNameX, top, "MAX POWER :");
itoa(stats.max_power, buff, 10);
tfp_sprintf(buff, "%s%c", buff, SYM_WATT);
bool kiloWatt = osdFormatCentiNumber(buff, stats.max_power, 1000, 2, 2, 3);
buff[3] = kiloWatt ? SYM_KILOWATT : SYM_WATT;
buff[4] = '\0';
avsaase marked this conversation as resolved.
Show resolved Hide resolved
displayWrite(osdDisplayPort, statValuesX, top++, buff);

if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) {
Expand Down