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:
Michael Keller 2017-11-12 10:34:58 +13:00 committed by GitHub
commit ba0d05a384
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 23 deletions

View File

@ -42,10 +42,6 @@
#include "io/beeper.h"
#include "io/motors.h"
#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
#include "io/osd.h"
#endif
#include "fc/config.h"
#include "fc/controlrate_profile.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)
static const char * adjustmentLabels[] = {
static const char const *adjustmentLabels[] = {
"RC RATE",
"RC EXPO",
"THROTTLE EXPO",
@ -233,6 +229,9 @@ static const char * adjustmentLabels[] = {
"D SETPOINT TRANSITION",
"HORIZON STRENGTH",
};
const char const *adjustmentRangeName;
int adjustmentRangeValue = -1;
#endif
#define ADJUSTMENT_FUNCTION_CONFIG_INDEX_OFFSET 1
@ -434,6 +433,10 @@ void processRcAdjustments(controlRateConfig_t *controlRateConfig)
if (cmp32(now, adjustmentState->timeoutAt) >= 0) {
adjustmentState->timeoutAt = now + RESET_FREQUENCY_2HZ;
MARK_ADJUSTMENT_FUNCTION_AS_READY(adjustmentIndex);
#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
adjustmentRangeValue = -1;
#endif
}
if (!canUseRxData) {
@ -467,8 +470,9 @@ void processRcAdjustments(controlRateConfig_t *controlRateConfig)
}
#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
if (newValue != -1) {
osdShowAdjustment(adjustmentLabels[adjustmentFunction], newValue);
if (newValue != -1 && adjustmentState->config->adjustmentFunction != ADJUSTMENT_RATE_PROFILE) { // Rate profile already has an OSD element
adjustmentRangeName = &adjustmentLabels[adjustmentFunction - 1][0];
adjustmentRangeValue = newValue;
}
#else
UNUSED(newValue);

View File

@ -93,6 +93,9 @@ typedef struct adjustmentState_s {
#define MAX_ADJUSTMENT_RANGE_COUNT 15
extern char const *adjustmentRangeName;
extern int adjustmentRangeValue;
PG_DECLARE_ARRAY(adjustmentRange_t, MAX_ADJUSTMENT_RANGE_COUNT, adjustmentRanges);
void resetAdjustmentStates(void);

View File

@ -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_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_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_dist", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats[OSD_STAT_MAX_DISTANCE])},

View File

@ -738,6 +738,13 @@ static void osdDrawSingleElement(uint8_t item)
printRtcDateTime(&buff[0]);
break;
#endif
#ifdef USE_OSD_ADJUSTMENTS
case OSD_ADJUSTMENT_RANGE:
tfp_sprintf(buff, "%s: %3d", adjustmentRangeName, adjustmentRangeValue);
break;
#endif
default:
return;
}
@ -807,6 +814,9 @@ static void osdDrawElements(void)
osdDrawSingleElement(OSD_RTC_DATETIME);
#endif
#ifdef USE_OSD_ADJUSTMENTS
osdDrawSingleElement(OSD_ADJUSTMENT_RANGE);
#endif
}
void pgResetFn_osdConfig(osdConfig_t *osdConfig)
@ -1155,12 +1165,6 @@ STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
{
static timeUs_t lastTimeUs = 0;
#ifdef USE_OSD_ADJUSTMENTS
if (isAnyAdjustmentFunctionBusy()) {
return;
}
#endif
// detect arm/disarm
if (armState != ARMING_FLAG(ARMED)) {
if (ARMING_FLAG(ARMED)) {
@ -1274,13 +1278,4 @@ void osdUpdate(timeUs_t currentTimeUs)
#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

View File

@ -84,6 +84,7 @@ typedef enum {
OSD_ESC_TMP,
OSD_ESC_RPM,
OSD_RTC_DATETIME,
OSD_ADJUSTMENT_RANGE,
OSD_ITEM_COUNT // MUST BE LAST
} osd_items_e;
@ -163,6 +164,5 @@ void osdInit(struct displayPort_s *osdDisplayPort);
void osdResetConfig(osdConfig_t *osdProfile);
void osdResetAlarms(void);
void osdUpdate(timeUs_t currentTimeUs);
void osdShowAdjustment(const char * type, int newValue);
#endif