mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 13:25:30 +03:00
Merge pull request #4546 from mikeller/fixed_adjustment_osd_display
Fixed up adjustment range OSD display and made it configurable.
This commit is contained in:
commit
ba0d05a384
5 changed files with 26 additions and 23 deletions
|
@ -42,10 +42,6 @@
|
||||||
#include "io/beeper.h"
|
#include "io/beeper.h"
|
||||||
#include "io/motors.h"
|
#include "io/motors.h"
|
||||||
|
|
||||||
#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
|
|
||||||
#include "io/osd.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "fc/config.h"
|
#include "fc/config.h"
|
||||||
#include "fc/controlrate_profile.h"
|
#include "fc/controlrate_profile.h"
|
||||||
#include "fc/rc_adjustments.h"
|
#include "fc/rc_adjustments.h"
|
||||||
|
@ -207,7 +203,7 @@ static const adjustmentConfig_t defaultAdjustmentConfigs[ADJUSTMENT_FUNCTION_COU
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
|
#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
|
||||||
static const char * adjustmentLabels[] = {
|
static const char const *adjustmentLabels[] = {
|
||||||
"RC RATE",
|
"RC RATE",
|
||||||
"RC EXPO",
|
"RC EXPO",
|
||||||
"THROTTLE EXPO",
|
"THROTTLE EXPO",
|
||||||
|
@ -233,6 +229,9 @@ static const char * adjustmentLabels[] = {
|
||||||
"D SETPOINT TRANSITION",
|
"D SETPOINT TRANSITION",
|
||||||
"HORIZON STRENGTH",
|
"HORIZON STRENGTH",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char const *adjustmentRangeName;
|
||||||
|
int adjustmentRangeValue = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ADJUSTMENT_FUNCTION_CONFIG_INDEX_OFFSET 1
|
#define ADJUSTMENT_FUNCTION_CONFIG_INDEX_OFFSET 1
|
||||||
|
@ -434,6 +433,10 @@ void processRcAdjustments(controlRateConfig_t *controlRateConfig)
|
||||||
if (cmp32(now, adjustmentState->timeoutAt) >= 0) {
|
if (cmp32(now, adjustmentState->timeoutAt) >= 0) {
|
||||||
adjustmentState->timeoutAt = now + RESET_FREQUENCY_2HZ;
|
adjustmentState->timeoutAt = now + RESET_FREQUENCY_2HZ;
|
||||||
MARK_ADJUSTMENT_FUNCTION_AS_READY(adjustmentIndex);
|
MARK_ADJUSTMENT_FUNCTION_AS_READY(adjustmentIndex);
|
||||||
|
|
||||||
|
#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
|
||||||
|
adjustmentRangeValue = -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canUseRxData) {
|
if (!canUseRxData) {
|
||||||
|
@ -467,8 +470,9 @@ void processRcAdjustments(controlRateConfig_t *controlRateConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
|
#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
|
||||||
if (newValue != -1) {
|
if (newValue != -1 && adjustmentState->config->adjustmentFunction != ADJUSTMENT_RATE_PROFILE) { // Rate profile already has an OSD element
|
||||||
osdShowAdjustment(adjustmentLabels[adjustmentFunction], newValue);
|
adjustmentRangeName = &adjustmentLabels[adjustmentFunction - 1][0];
|
||||||
|
adjustmentRangeValue = newValue;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
UNUSED(newValue);
|
UNUSED(newValue);
|
||||||
|
|
|
@ -93,6 +93,9 @@ typedef struct adjustmentState_s {
|
||||||
|
|
||||||
#define MAX_ADJUSTMENT_RANGE_COUNT 15
|
#define MAX_ADJUSTMENT_RANGE_COUNT 15
|
||||||
|
|
||||||
|
extern char const *adjustmentRangeName;
|
||||||
|
extern int adjustmentRangeValue;
|
||||||
|
|
||||||
PG_DECLARE_ARRAY(adjustmentRange_t, MAX_ADJUSTMENT_RANGE_COUNT, adjustmentRanges);
|
PG_DECLARE_ARRAY(adjustmentRange_t, MAX_ADJUSTMENT_RANGE_COUNT, adjustmentRanges);
|
||||||
|
|
||||||
void resetAdjustmentStates(void);
|
void resetAdjustmentStates(void);
|
||||||
|
|
|
@ -732,6 +732,7 @@ const clivalue_t valueTable[] = {
|
||||||
{ "osd_esc_tmp_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ESC_TMP]) },
|
{ "osd_esc_tmp_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ESC_TMP]) },
|
||||||
{ "osd_esc_rpm_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ESC_RPM]) },
|
{ "osd_esc_rpm_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ESC_RPM]) },
|
||||||
{ "osd_rtc_date_time_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_RTC_DATETIME]) },
|
{ "osd_rtc_date_time_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_RTC_DATETIME]) },
|
||||||
|
{ "osd_adjustment_range_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ADJUSTMENT_RANGE]) },
|
||||||
|
|
||||||
{ "osd_stat_max_spd", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats[OSD_STAT_MAX_SPEED])},
|
{ "osd_stat_max_spd", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats[OSD_STAT_MAX_SPEED])},
|
||||||
{ "osd_stat_max_dist", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats[OSD_STAT_MAX_DISTANCE])},
|
{ "osd_stat_max_dist", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats[OSD_STAT_MAX_DISTANCE])},
|
||||||
|
|
|
@ -738,6 +738,13 @@ static void osdDrawSingleElement(uint8_t item)
|
||||||
printRtcDateTime(&buff[0]);
|
printRtcDateTime(&buff[0]);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_OSD_ADJUSTMENTS
|
||||||
|
case OSD_ADJUSTMENT_RANGE:
|
||||||
|
tfp_sprintf(buff, "%s: %3d", adjustmentRangeName, adjustmentRangeValue);
|
||||||
|
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -807,6 +814,9 @@ static void osdDrawElements(void)
|
||||||
osdDrawSingleElement(OSD_RTC_DATETIME);
|
osdDrawSingleElement(OSD_RTC_DATETIME);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_OSD_ADJUSTMENTS
|
||||||
|
osdDrawSingleElement(OSD_ADJUSTMENT_RANGE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
||||||
|
@ -1155,12 +1165,6 @@ STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
|
||||||
{
|
{
|
||||||
static timeUs_t lastTimeUs = 0;
|
static timeUs_t lastTimeUs = 0;
|
||||||
|
|
||||||
#ifdef USE_OSD_ADJUSTMENTS
|
|
||||||
if (isAnyAdjustmentFunctionBusy()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// detect arm/disarm
|
// detect arm/disarm
|
||||||
if (armState != ARMING_FLAG(ARMED)) {
|
if (armState != ARMING_FLAG(ARMED)) {
|
||||||
if (ARMING_FLAG(ARMED)) {
|
if (ARMING_FLAG(ARMED)) {
|
||||||
|
@ -1274,13 +1278,4 @@ void osdUpdate(timeUs_t currentTimeUs)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_OSD_ADJUSTMENTS
|
|
||||||
void osdShowAdjustment(const char * type, int newValue)
|
|
||||||
{
|
|
||||||
char buff[OSD_ELEMENT_BUFFER_LENGTH];
|
|
||||||
tfp_sprintf(buff, "%s: %3d", type, newValue);
|
|
||||||
displayWrite(osdDisplayPort, round(15 - strlen(buff) / 2), 7, buff);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // OSD
|
#endif // OSD
|
||||||
|
|
|
@ -84,6 +84,7 @@ typedef enum {
|
||||||
OSD_ESC_TMP,
|
OSD_ESC_TMP,
|
||||||
OSD_ESC_RPM,
|
OSD_ESC_RPM,
|
||||||
OSD_RTC_DATETIME,
|
OSD_RTC_DATETIME,
|
||||||
|
OSD_ADJUSTMENT_RANGE,
|
||||||
OSD_ITEM_COUNT // MUST BE LAST
|
OSD_ITEM_COUNT // MUST BE LAST
|
||||||
} osd_items_e;
|
} osd_items_e;
|
||||||
|
|
||||||
|
@ -163,6 +164,5 @@ void osdInit(struct displayPort_s *osdDisplayPort);
|
||||||
void osdResetConfig(osdConfig_t *osdProfile);
|
void osdResetConfig(osdConfig_t *osdProfile);
|
||||||
void osdResetAlarms(void);
|
void osdResetAlarms(void);
|
||||||
void osdUpdate(timeUs_t currentTimeUs);
|
void osdUpdate(timeUs_t currentTimeUs);
|
||||||
void osdShowAdjustment(const char * type, int newValue);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue