mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_OSD: Add configurable sidebar horizontal and vertical size extensions
This commit is contained in:
parent
19ea0944b1
commit
e07980db43
@ -230,6 +230,22 @@ const AP_Param::GroupInfo AP_OSD::var_info[] = {
|
|||||||
AP_GROUPINFO("_W_SNR", 34, AP_OSD, warn_snr, 0),
|
AP_GROUPINFO("_W_SNR", 34, AP_OSD, warn_snr, 0),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAL_OSD_SIDEBAR_ENABLE
|
||||||
|
// @Param: _SB_H_OFS
|
||||||
|
// @DisplayName: Sidebar horizontal offset
|
||||||
|
// @Description: Extends the spacing between the sidebar elements by this amount of columns. Positive values increases the width to the right of the screen.
|
||||||
|
// @Range: 0 20
|
||||||
|
// @User: Standard
|
||||||
|
AP_GROUPINFO("_SB_H_OFS", 35, AP_OSD, sidebar_h_offset, 0),
|
||||||
|
|
||||||
|
// @Param: _SB_V_EXT
|
||||||
|
// @DisplayName: Sidebar vertical extension
|
||||||
|
// @Description: Increase of vertical length of the sidebar itens by this amount of lines. Applied equally both above and below the default setting.
|
||||||
|
// @Range: 0 10
|
||||||
|
// @User: Standard
|
||||||
|
AP_GROUPINFO("_SB_V_EXT", 36, AP_OSD, sidebar_v_ext, 0),
|
||||||
|
#endif // HAL_OSD_SIDEBAR_ENABLE
|
||||||
|
|
||||||
#endif //osd enabled
|
#endif //osd enabled
|
||||||
#if OSD_PARAM_ENABLED
|
#if OSD_PARAM_ENABLED
|
||||||
// @Group: 5_
|
// @Group: 5_
|
||||||
|
@ -591,6 +591,11 @@ public:
|
|||||||
AP_Int8 warn_snr;
|
AP_Int8 warn_snr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAL_OSD_SIDEBAR_ENABLE
|
||||||
|
AP_Int8 sidebar_h_offset;
|
||||||
|
AP_Int8 sidebar_v_ext;
|
||||||
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
OPTION_DECIMAL_PACK = 1U<<0,
|
OPTION_DECIMAL_PACK = 1U<<0,
|
||||||
OPTION_INVERTED_WIND = 1U<<1,
|
OPTION_INVERTED_WIND = 1U<<1,
|
||||||
|
@ -1862,10 +1862,14 @@ void AP_OSD_Screen::draw_sidebars(uint8_t x, uint8_t y)
|
|||||||
static const int aspd_interval = 10; //units between large tick marks
|
static const int aspd_interval = 10; //units between large tick marks
|
||||||
int alt_interval = (osd->units == AP_OSD::UNITS_AVIATION || osd->units == AP_OSD::UNITS_IMPERIAL) ? 20 : 10;
|
int alt_interval = (osd->units == AP_OSD::UNITS_AVIATION || osd->units == AP_OSD::UNITS_IMPERIAL) ? 20 : 10;
|
||||||
|
|
||||||
|
// Height values taking into account configurable vertical extension
|
||||||
|
const int bar_total_height = 7 + (osd->sidebar_v_ext * 2);
|
||||||
|
const int bar_middle = bar_total_height / 2; // Integer division
|
||||||
|
|
||||||
// render airspeed ladder
|
// render airspeed ladder
|
||||||
int aspd_symbol_index = fmodf(scaled_aspd, aspd_interval) / aspd_interval * total_sectors;
|
int aspd_symbol_index = fmodf(scaled_aspd, aspd_interval) / aspd_interval * total_sectors;
|
||||||
for (int i = 0; i < 7; i++){
|
for (int i = 0; i < bar_total_height; i++){
|
||||||
if (i == 3) {
|
if (i == bar_middle) {
|
||||||
// the middle section of the ladder with the currrent airspeed
|
// the middle section of the ladder with the currrent airspeed
|
||||||
backend->write(x, y+i, false, "%3d%c%c", (int) scaled_aspd, u_icon(SPEED), SYMBOL(SYM_SIDEBAR_R_ARROW));
|
backend->write(x, y+i, false, "%3d%c%c", (int) scaled_aspd, u_icon(SPEED), SYMBOL(SYM_SIDEBAR_R_ARROW));
|
||||||
} else {
|
} else {
|
||||||
@ -1877,12 +1881,12 @@ void AP_OSD_Screen::draw_sidebars(uint8_t x, uint8_t y)
|
|||||||
// render the altitude ladder
|
// render the altitude ladder
|
||||||
// similar formula to above, but accounts for negative altitudes
|
// similar formula to above, but accounts for negative altitudes
|
||||||
int alt_symbol_index = fmodf(fmodf(scaled_alt, alt_interval) + alt_interval, alt_interval) / alt_interval * total_sectors;
|
int alt_symbol_index = fmodf(fmodf(scaled_alt, alt_interval) + alt_interval, alt_interval) / alt_interval * total_sectors;
|
||||||
for (int i = 0; i < 7; i++){
|
for (int i = 0; i < bar_total_height; i++){
|
||||||
if (i == 3) {
|
if (i == bar_middle) {
|
||||||
// the middle section of the ladder with the currrent altitude
|
// the middle section of the ladder with the currrent altitude
|
||||||
backend->write(x+16, y+i, false, "%c%d%c", SYMBOL(SYM_SIDEBAR_L_ARROW), (int) scaled_alt, u_icon(ALTITUDE));
|
backend->write(x + 16 + osd->sidebar_h_offset, y+i, false, "%c%d%c", SYMBOL(SYM_SIDEBAR_L_ARROW), (int) scaled_alt, u_icon(ALTITUDE));
|
||||||
} else {
|
} else {
|
||||||
backend->write(x+16, y+i, false, "%c", SYMBOL(sidebar_sectors[alt_symbol_index]));
|
backend->write(x + 16 + osd->sidebar_h_offset, y+i, false, "%c", SYMBOL(sidebar_sectors[alt_symbol_index]));
|
||||||
}
|
}
|
||||||
alt_symbol_index = (alt_symbol_index + 12) % 18;
|
alt_symbol_index = (alt_symbol_index + 12) % 18;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user