Manage BLINK attribute separate from config vars
This commit is contained in:
parent
605066ecf5
commit
3bcf96e6eb
|
@ -774,27 +774,27 @@ const clivalue_t valueTable[] = {
|
||||||
{ "osd_time_alarm", VAR_UINT16 | MASTER_VALUE, &osdProfile()->time_alarm, .config.minmax = { 0, 60 } },
|
{ "osd_time_alarm", VAR_UINT16 | MASTER_VALUE, &osdProfile()->time_alarm, .config.minmax = { 0, 60 } },
|
||||||
{ "osd_alt_alarm", VAR_UINT16 | MASTER_VALUE, &osdProfile()->alt_alarm, .config.minmax = { 0, 10000 } },
|
{ "osd_alt_alarm", VAR_UINT16 | MASTER_VALUE, &osdProfile()->alt_alarm, .config.minmax = { 0, 10000 } },
|
||||||
|
|
||||||
{ "osd_vbat_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_MAIN_BATT_VOLTAGE], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_vbat_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_MAIN_BATT_VOLTAGE], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_rssi_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_RSSI_VALUE], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_rssi_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_RSSI_VALUE], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_flytimer_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_FLYTIME], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_flytimer_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_FLYTIME], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_ontimer_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_ONTIME], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_ontimer_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_ONTIME], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_flymode_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_FLYMODE], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_flymode_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_FLYMODE], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_throttle_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_THROTTLE_POS], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_throttle_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_THROTTLE_POS], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_vtx_channel_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_VTX_CHANNEL], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_vtx_channel_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_VTX_CHANNEL], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_crosshairs", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_CROSSHAIRS], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_crosshairs", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_CROSSHAIRS], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_horizon_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_ARTIFICIAL_HORIZON], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_horizon_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_ARTIFICIAL_HORIZON], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_current_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_CURRENT_DRAW], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_current_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_CURRENT_DRAW], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_mah_drawn_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_MAH_DRAWN], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_mah_drawn_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_MAH_DRAWN], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_craft_name_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_CRAFT_NAME], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_craft_name_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_CRAFT_NAME], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_gps_speed_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_GPS_SPEED], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_gps_speed_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_GPS_SPEED], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_gps_sats_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_GPS_SATS], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_gps_sats_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_GPS_SATS], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_altitude_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_ALTITUDE], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_altitude_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_ALTITUDE], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_pid_roll_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_ROLL_PIDS], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_pid_roll_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_ROLL_PIDS], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_pid_pitch_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_PITCH_PIDS], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_pid_pitch_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_PITCH_PIDS], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_pid_yaw_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_YAW_PIDS], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_pid_yaw_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_YAW_PIDS], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_power_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_POWER], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_power_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_POWER], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_pidrate_profile_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_PIDRATE_PROFILE], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_pidrate_profile_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_PIDRATE_PROFILE], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
{ "osd_battery_warning_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_MAIN_BATT_WARNING], .config.minmax = { 0, OSD_POS_MAX } },
|
{ "osd_battery_warning_pos", VAR_UINT16 | MASTER_VALUE, &osdProfile()->item_pos[OSD_MAIN_BATT_WARNING], .config.minmax = { 0, OSD_POSCFG_MAX } },
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_MAX7456
|
#ifdef USE_MAX7456
|
||||||
{ "vcd_video_system", VAR_UINT8 | MASTER_VALUE, &vcdProfile()->video_system, .config.minmax = { 0, 2 } },
|
{ "vcd_video_system", VAR_UINT8 | MASTER_VALUE, &vcdProfile()->video_system, .config.minmax = { 0, 2 } },
|
||||||
|
|
|
@ -68,20 +68,28 @@
|
||||||
|
|
||||||
#define VIDEO_BUFFER_CHARS_PAL 480
|
#define VIDEO_BUFFER_CHARS_PAL 480
|
||||||
|
|
||||||
// Character coordinate and attributes
|
// Character coordinate
|
||||||
|
|
||||||
#define OSD_POS(x,y) (x | (y << 5))
|
#define OSD_POS(x,y) (x | (y << 5))
|
||||||
#define OSD_X(x) (x & 0x001F)
|
#define OSD_X(x) (x & 0x001F)
|
||||||
#define OSD_Y(x) ((x >> 5) & 0x001F)
|
#define OSD_Y(x) ((x >> 5) & 0x001F)
|
||||||
|
|
||||||
|
// Blink control
|
||||||
|
|
||||||
|
bool blinkState = true;
|
||||||
|
|
||||||
|
static uint32_t blinkBits[(OSD_ITEM_COUNT + 31)/32];
|
||||||
|
#define SET_BLINK(item) (blinkBits[(item) / 32] |= (1 << ((item) % 32)))
|
||||||
|
#define CLR_BLINK(item) (blinkBits[(item) / 32] &= ~(1 << ((item) % 32)))
|
||||||
|
#define IS_BLINK(item) (blinkBits[(item) / 32] & (1 << ((item) % 32)))
|
||||||
|
#define BLINK(item) (IS_BLINK(item) && blinkState)
|
||||||
|
|
||||||
// Things in both OSD and CMS
|
// Things in both OSD and CMS
|
||||||
|
|
||||||
#define IS_HI(X) (rcData[X] > 1750)
|
#define IS_HI(X) (rcData[X] > 1750)
|
||||||
#define IS_LO(X) (rcData[X] < 1250)
|
#define IS_LO(X) (rcData[X] < 1250)
|
||||||
#define IS_MID(X) (rcData[X] > 1250 && rcData[X] < 1750)
|
#define IS_MID(X) (rcData[X] > 1250 && rcData[X] < 1750)
|
||||||
|
|
||||||
bool blinkState = true;
|
|
||||||
|
|
||||||
//extern uint8_t RSSI; // TODO: not used?
|
//extern uint8_t RSSI; // TODO: not used?
|
||||||
|
|
||||||
static uint16_t flyTime = 0;
|
static uint16_t flyTime = 0;
|
||||||
|
@ -139,7 +147,7 @@ static int32_t osdGetAltitude(int32_t alt)
|
||||||
|
|
||||||
static void osdDrawSingleElement(uint8_t item)
|
static void osdDrawSingleElement(uint8_t item)
|
||||||
{
|
{
|
||||||
if (!VISIBLE(osdProfile()->item_pos[item]) || BLINK(osdProfile()->item_pos[item]))
|
if (!VISIBLE(osdProfile()->item_pos[item]) || BLINK(item))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint8_t elemPosX = OSD_X(osdProfile()->item_pos[item]);
|
uint8_t elemPosX = OSD_X(osdProfile()->item_pos[item]);
|
||||||
|
@ -487,6 +495,8 @@ void osdInit(displayPort_t *osdDisplayPortToUse)
|
||||||
|
|
||||||
armState = ARMING_FLAG(ARMED);
|
armState = ARMING_FLAG(ARMED);
|
||||||
|
|
||||||
|
memset(blinkBits, 0, sizeof(blinkBits));
|
||||||
|
|
||||||
displayClearScreen(osdDisplayPort);
|
displayClearScreen(osdDisplayPort);
|
||||||
|
|
||||||
// display logo and help
|
// display logo and help
|
||||||
|
@ -523,48 +533,48 @@ void osdUpdateAlarms(void)
|
||||||
statRssi = rssi * 100 / 1024;
|
statRssi = rssi * 100 / 1024;
|
||||||
|
|
||||||
if (statRssi < pOsdProfile->rssi_alarm)
|
if (statRssi < pOsdProfile->rssi_alarm)
|
||||||
pOsdProfile->item_pos[OSD_RSSI_VALUE] |= BLINK_FLAG;
|
SET_BLINK(OSD_RSSI_VALUE);
|
||||||
else
|
else
|
||||||
pOsdProfile->item_pos[OSD_RSSI_VALUE] &= ~BLINK_FLAG;
|
CLR_BLINK(OSD_RSSI_VALUE);
|
||||||
|
|
||||||
if (getVbat() <= (batteryWarningVoltage - 1)) {
|
if (getVbat() <= (batteryWarningVoltage - 1)) {
|
||||||
pOsdProfile->item_pos[OSD_MAIN_BATT_VOLTAGE] |= BLINK_FLAG;
|
SET_BLINK(OSD_MAIN_BATT_VOLTAGE);
|
||||||
pOsdProfile->item_pos[OSD_MAIN_BATT_WARNING] |= BLINK_FLAG;
|
SET_BLINK(OSD_MAIN_BATT_WARNING);
|
||||||
} else {
|
} else {
|
||||||
pOsdProfile->item_pos[OSD_MAIN_BATT_VOLTAGE] &= ~BLINK_FLAG;
|
CLR_BLINK(OSD_MAIN_BATT_VOLTAGE);
|
||||||
pOsdProfile->item_pos[OSD_MAIN_BATT_WARNING] &= ~BLINK_FLAG;
|
CLR_BLINK(OSD_MAIN_BATT_WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STATE(GPS_FIX) == 0)
|
if (STATE(GPS_FIX) == 0)
|
||||||
pOsdProfile->item_pos[OSD_GPS_SATS] |= BLINK_FLAG;
|
SET_BLINK(OSD_GPS_SATS);
|
||||||
else
|
else
|
||||||
pOsdProfile->item_pos[OSD_GPS_SATS] &= ~BLINK_FLAG;
|
CLR_BLINK(OSD_GPS_SATS);
|
||||||
|
|
||||||
if (flyTime / 60 >= pOsdProfile->time_alarm && ARMING_FLAG(ARMED))
|
if (flyTime / 60 >= pOsdProfile->time_alarm && ARMING_FLAG(ARMED))
|
||||||
pOsdProfile->item_pos[OSD_FLYTIME] |= BLINK_FLAG;
|
SET_BLINK(OSD_FLYTIME);
|
||||||
else
|
else
|
||||||
pOsdProfile->item_pos[OSD_FLYTIME] &= ~BLINK_FLAG;
|
CLR_BLINK(OSD_FLYTIME);
|
||||||
|
|
||||||
if (mAhDrawn >= pOsdProfile->cap_alarm)
|
if (mAhDrawn >= pOsdProfile->cap_alarm)
|
||||||
pOsdProfile->item_pos[OSD_MAH_DRAWN] |= BLINK_FLAG;
|
SET_BLINK(OSD_MAH_DRAWN);
|
||||||
else
|
else
|
||||||
pOsdProfile->item_pos[OSD_MAH_DRAWN] &= ~BLINK_FLAG;
|
CLR_BLINK(OSD_MAH_DRAWN);
|
||||||
|
|
||||||
if (alt >= pOsdProfile->alt_alarm)
|
if (alt >= pOsdProfile->alt_alarm)
|
||||||
pOsdProfile->item_pos[OSD_ALTITUDE] |= BLINK_FLAG;
|
SET_BLINK(OSD_ALTITUDE);
|
||||||
else
|
else
|
||||||
pOsdProfile->item_pos[OSD_ALTITUDE] &= ~BLINK_FLAG;
|
CLR_BLINK(OSD_ALTITUDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void osdResetAlarms(void)
|
void osdResetAlarms(void)
|
||||||
{
|
{
|
||||||
osd_profile_t *pOsdProfile = &masterConfig.osdProfile;
|
CLR_BLINK(OSD_RSSI_VALUE);
|
||||||
|
CLR_BLINK(OSD_MAIN_BATT_VOLTAGE);
|
||||||
pOsdProfile->item_pos[OSD_RSSI_VALUE] &= ~BLINK_FLAG;
|
CLR_BLINK(OSD_MAIN_BATT_WARNING);
|
||||||
pOsdProfile->item_pos[OSD_MAIN_BATT_VOLTAGE] &= ~BLINK_FLAG;
|
CLR_BLINK(OSD_GPS_SATS);
|
||||||
pOsdProfile->item_pos[OSD_GPS_SATS] &= ~BLINK_FLAG;
|
CLR_BLINK(OSD_FLYTIME);
|
||||||
pOsdProfile->item_pos[OSD_FLYTIME] &= ~BLINK_FLAG;
|
CLR_BLINK(OSD_MAH_DRAWN);
|
||||||
pOsdProfile->item_pos[OSD_MAH_DRAWN] &= ~BLINK_FLAG;
|
CLR_BLINK(OSD_ALTITUDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void osdResetStats(void)
|
static void osdResetStats(void)
|
||||||
|
|
|
@ -20,11 +20,9 @@
|
||||||
#include "common/time.h"
|
#include "common/time.h"
|
||||||
|
|
||||||
#define VISIBLE_FLAG 0x0800
|
#define VISIBLE_FLAG 0x0800
|
||||||
#define BLINK_FLAG 0x0400
|
|
||||||
#define VISIBLE(x) (x & VISIBLE_FLAG)
|
#define VISIBLE(x) (x & VISIBLE_FLAG)
|
||||||
#define BLINK(x) ((x & BLINK_FLAG) && blinkState)
|
|
||||||
#define BLINK_OFF(x) (x & ~BLINK_FLAG)
|
|
||||||
#define OSD_POS_MAX 0x3FF
|
#define OSD_POS_MAX 0x3FF
|
||||||
|
#define OSD_POSCFG_MAX (VISIBLE_FLAG|0x3FF) // For CLI values
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OSD_RSSI_VALUE,
|
OSD_RSSI_VALUE,
|
||||||
|
|
Loading…
Reference in New Issue