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

Add pitch and roll attitude angles in OSD #3169

Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Add pitch and roll attitude angles in OSD

  • Loading branch information...
shellixyz committed Mar 23, 2018
commit d7f77f75bc5c8a1b440412f01e972891fa7f0c51
@@ -195,6 +195,9 @@ static const OSD_Entry menuOsdElemsEntries[] =
OSD_ELEMENT_ENTRY("PITCH PIDS", OSD_PITCH_PIDS),
OSD_ELEMENT_ENTRY("YAW PIDS", OSD_YAW_PIDS),

OSD_ELEMENT_ENTRY("ATTI PITCH", OSD_ATTITUDE_PITCH),
OSD_ELEMENT_ENTRY("ATTI ROLL", OSD_ATTITUDE_ROLL),

OSD_BACK_ENTRY,
OSD_END_ENTRY,
};
@@ -232,4 +232,11 @@
#define SYM_MIN 0xB3
#define SYM_AVG 0xB4

// Attitude angles
#define SYM_ROLL_LEFT 0xCC
#define SYM_ROLL_LEVEL 0xCD
#define SYM_ROLL_RIGHT 0xCE
#define SYM_PITCH_UP 0xCF
#define SYM_PITCH_DOWN 0xDF

#endif // USE_MAX7456
@@ -1467,6 +1467,10 @@ groups:
field: main_voltage_decimals
min: 1
max: 2
- name: osd_attitude_angle_decimals
field: attitude_angle_decimals
min: 0
max: 1

- name: PG_SYSTEM_CONFIG
type: systemConfig_t
@@ -158,7 +158,7 @@ static displayPort_t *osdDisplayPort;
#define AH_SIDEBAR_WIDTH_POS 7
#define AH_SIDEBAR_HEIGHT_POS 3

PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 1);
PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 2);

static int digitCount(int32_t value)
{
@@ -1099,6 +1099,23 @@ static bool osdDrawSingleElement(uint8_t item)
}
break;

case OSD_ATTITUDE_ROLL:
buff[0] = SYM_ROLL_LEVEL;
if (attitude.values.roll)
buff[0] += (attitude.values.roll < 0 ? -1 : 1);
osdFormatCentiNumber(buff + 1, ABS(attitude.values.roll) * 10, 0, osdConfig()->attitude_angle_decimals, 0, 2 + osdConfig()->attitude_angle_decimals);
break;

case OSD_ATTITUDE_PITCH:
if (attitude.values.pitch == 0)
buff[0] = 'P';
else if (attitude.values.pitch > 0)
buff[0] = SYM_PITCH_DOWN;
else if (attitude.values.pitch < 0)
buff[0] = SYM_PITCH_UP;
osdFormatCentiNumber(buff + 1, ABS(attitude.values.pitch) * 10, 0, osdConfig()->attitude_angle_decimals, 0, 2 + osdConfig()->attitude_angle_decimals);
break;

case OSD_ARTIFICIAL_HORIZON:
{
elemPosX = 14;
@@ -1586,8 +1603,8 @@ static uint8_t osdIncElementIndex(uint8_t elementIndex)
elementIndex = OSD_MAIN_BATT_CELL_VOLTAGE;
}
if (elementIndex == OSD_TRIP_DIST) {
STATIC_ASSERT(OSD_TRIP_DIST == OSD_ITEM_COUNT - 1, OSD_TRIP_DIST_not_last_element);
elementIndex = OSD_ITEM_COUNT;
STATIC_ASSERT(OSD_ATTITUDE_ROLL == OSD_ITEM_COUNT - 1, OSD_ATTITUDE_ROLL_not_last_element);
elementIndex = OSD_ATTITUDE_PITCH;
}
}

@@ -1631,6 +1648,9 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
osdConfig->item_pos[0][OSD_EFFICIENCY_MAH_PER_KM] = OSD_POS(1, 5);
osdConfig->item_pos[0][OSD_EFFICIENCY_WH_PER_KM] = OSD_POS(1, 5);

osdConfig->item_pos[0][OSD_ATTITUDE_ROLL] = OSD_POS(1, 7);
osdConfig->item_pos[0][OSD_ATTITUDE_PITCH] = OSD_POS(1, 8);

// avoid OSD_VARIO under OSD_CROSSHAIRS
osdConfig->item_pos[0][OSD_VARIO] = OSD_POS(23, 5);
// OSD_VARIO_NUM at the right of OSD_VARIO
@@ -1686,6 +1706,7 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)

osdConfig->units = OSD_UNIT_METRIC;
osdConfig->main_voltage_decimals = 1;
osdConfig->attitude_angle_decimals = 0;
}

static void osdSetNextRefreshIn(uint32_t timeMs) {
@@ -75,6 +75,8 @@ typedef enum {
OSD_BATTERY_REMAINING_PERCENT,
OSD_EFFICIENCY_WH_PER_KM,
OSD_TRIP_DIST,
OSD_ATTITUDE_PITCH,
OSD_ATTITUDE_ROLL,
OSD_ITEM_COUNT // MUST BE LAST
} osd_items_e;

@@ -117,6 +119,7 @@ typedef struct osdConfig_s {

// Preferences
uint8_t main_voltage_decimals;
uint8_t attitude_angle_decimals;
uint8_t ahi_reverse_roll;
uint8_t crosshairs_style; // from osd_crosshairs_style_e
uint8_t left_sidebar_scroll; // from osd_sidebar_scroll_e
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.