Added OSD Battery Usage progressbar
This commit is contained in:
parent
61d66c8a88
commit
37e2b8be24
|
@ -103,7 +103,8 @@ OSD_Entry menuOsdActiveElemsEntries[] =
|
|||
{
|
||||
{"--- ACTIV ELEM ---", OME_Label, NULL, NULL, 0},
|
||||
{"RSSI", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_RSSI_VALUE], 0},
|
||||
{"MAIN BATTERY", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_MAIN_BATT_VOLTAGE], 0},
|
||||
{"BATTERY VOLTAGE", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_MAIN_BATT_VOLTAGE], 0},
|
||||
{"BATTERY USAGE", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_MAIN_BATT_USAGE], 0},
|
||||
{"AVG CELL VOLTAGE", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_AVG_CELL_VOLTAGE], 0},
|
||||
{"CROSSHAIRS", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_CROSSHAIRS], 0},
|
||||
{"HORIZON", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_ARTIFICIAL_HORIZON], 0},
|
||||
|
|
|
@ -217,3 +217,11 @@
|
|||
//sport
|
||||
#define SYM_MIN 0xB3
|
||||
#define SYM_AVG 0xB4
|
||||
|
||||
// Progress bar
|
||||
#define SYM_PB_START 0x8A
|
||||
#define SYM_PB_FULL 0x8B
|
||||
#define SYM_PB_HALF 0x8C
|
||||
#define SYM_PB_EMPTY 0x8D
|
||||
#define SYM_PB_END 0x8E
|
||||
#define SYM_PB_CLOSE 0x8F
|
||||
|
|
|
@ -649,6 +649,8 @@ const clivalue_t valueTable[] = {
|
|||
{ "osd_avg_cell_voltage_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_AVG_CELL_VOLTAGE]) },
|
||||
{ "osd_pit_ang_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_PITCH_ANGLE]) },
|
||||
{ "osd_rol_ang_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ROLL_ANGLE]) },
|
||||
{ "osd_battery_usage_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_MAIN_BATT_USAGE]) },
|
||||
|
||||
#endif
|
||||
|
||||
// PG_SYSTEM_CONFIG
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
|
@ -479,6 +480,42 @@ static void osdDrawSingleElement(uint8_t item)
|
|||
break;
|
||||
}
|
||||
|
||||
case OSD_MAIN_BATT_USAGE:
|
||||
{
|
||||
//Set length of indicator bar
|
||||
uint8_t progressSteps = 10;
|
||||
|
||||
//Calculate constrained value
|
||||
float value = constrain(osdConfig()->cap_alarm - getMAhDrawn(), 0, osdConfig()->cap_alarm);
|
||||
|
||||
//Calculate mAh used progress
|
||||
uint8_t mAhUsedProgress = ceil((value / (osdConfig()->cap_alarm / progressSteps)));
|
||||
|
||||
//Create empty battery indicator bar
|
||||
buff[0] = SYM_PB_START;
|
||||
for(uint8_t i = 1; i <= progressSteps; i++)
|
||||
{
|
||||
buff[i] = SYM_PB_EMPTY;
|
||||
}
|
||||
buff[progressSteps+1] = SYM_PB_CLOSE;
|
||||
|
||||
//Fill indicator bar progress
|
||||
for(uint8_t i = 1; i <= mAhUsedProgress; i++)
|
||||
{
|
||||
buff[i] = SYM_PB_FULL;
|
||||
}
|
||||
|
||||
if (mAhUsedProgress > 0 && mAhUsedProgress < progressSteps)
|
||||
{
|
||||
buff[1+mAhUsedProgress] = SYM_PB_END;
|
||||
}
|
||||
|
||||
buff[progressSteps+2] = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
@ -532,6 +569,7 @@ void osdDrawElements(void)
|
|||
osdDrawSingleElement(OSD_DEBUG);
|
||||
osdDrawSingleElement(OSD_PITCH_ANGLE);
|
||||
osdDrawSingleElement(OSD_ROLL_ANGLE);
|
||||
osdDrawSingleElement(OSD_MAIN_BATT_USAGE);
|
||||
|
||||
#ifdef GPS
|
||||
#ifdef CMS
|
||||
|
@ -579,6 +617,8 @@ void pgResetFn_osdConfig(osdConfig_t *osdProfile)
|
|||
|
||||
osdProfile->item_pos[OSD_GPS_LAT] = OSD_POS(18, 14) | VISIBLE_FLAG;
|
||||
osdProfile->item_pos[OSD_GPS_LON] = OSD_POS(18, 15) | VISIBLE_FLAG;
|
||||
osdProfile->item_pos[OSD_MAIN_BATT_USAGE] = OSD_POS(15, 10) | VISIBLE_FLAG;
|
||||
|
||||
|
||||
osdProfile->units = OSD_UNIT_METRIC;
|
||||
osdProfile->rssi_alarm = 20;
|
||||
|
@ -667,9 +707,15 @@ void osdUpdateAlarms(void)
|
|||
CLR_BLINK(OSD_FLYTIME);
|
||||
|
||||
if (getMAhDrawn() >= osdConfig()->cap_alarm)
|
||||
{
|
||||
SET_BLINK(OSD_MAH_DRAWN);
|
||||
SET_BLINK(OSD_MAIN_BATT_USAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
CLR_BLINK(OSD_MAH_DRAWN);
|
||||
CLR_BLINK(OSD_MAIN_BATT_USAGE);
|
||||
}
|
||||
|
||||
if (alt >= osdConfig()->alt_alarm)
|
||||
SET_BLINK(OSD_ALTITUDE);
|
||||
|
@ -687,6 +733,7 @@ void osdResetAlarms(void)
|
|||
CLR_BLINK(OSD_MAH_DRAWN);
|
||||
CLR_BLINK(OSD_ALTITUDE);
|
||||
CLR_BLINK(OSD_AVG_CELL_VOLTAGE);
|
||||
CLR_BLINK(OSD_MAIN_BATT_USAGE);
|
||||
}
|
||||
|
||||
static void osdResetStats(void)
|
||||
|
|
|
@ -55,6 +55,7 @@ typedef enum {
|
|||
OSD_DEBUG,
|
||||
OSD_PITCH_ANGLE,
|
||||
OSD_ROLL_ANGLE,
|
||||
OSD_MAIN_BATT_USAGE,
|
||||
OSD_ITEM_COUNT // MUST BE LAST
|
||||
} osd_items_e;
|
||||
|
||||
|
|
Loading…
Reference in New Issue