diff --git a/src/main/config/config.c b/src/main/config/config.c index 6e803a920b..c0dce56c91 100755 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -421,19 +421,7 @@ static void resetConf(void) #endif #ifdef OSD - featureSet(FEATURE_OSD); - masterConfig.osdProfile.video_system = AUTO; - masterConfig.osdProfile.item_pos[OSD_MAIN_BATT_VOLTAGE] = -29; - masterConfig.osdProfile.item_pos[OSD_RSSI_VALUE] = -59; - masterConfig.osdProfile.item_pos[OSD_TIMER] = -39; - masterConfig.osdProfile.item_pos[OSD_THROTTLE_POS] = -9; - masterConfig.osdProfile.item_pos[OSD_CPU_LOAD] = 26; - masterConfig.osdProfile.item_pos[OSD_VTX_CHANNEL] = 1; - masterConfig.osdProfile.item_pos[OSD_VOLTAGE_WARNING] = -80; - masterConfig.osdProfile.item_pos[OSD_ARMED] = -107; - masterConfig.osdProfile.item_pos[OSD_DISARMED] = -109; - masterConfig.osdProfile.item_pos[OSD_ARTIFICIAL_HORIZON] = 1; - masterConfig.osdProfile.item_pos[OSD_HORIZON_SIDEBARS] = -1; + resetOsdConfig(); #endif #ifdef USE_RTC6705 diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 8963aa4ba6..e7651c88fc 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -721,4 +721,21 @@ void osdInit(void) } +void resetOsdConfig(void) +{ + featureSet(FEATURE_OSD); + masterConfig.osdProfile.video_system = AUTO; + masterConfig.osdProfile.item_pos[OSD_MAIN_BATT_VOLTAGE] = -29; + masterConfig.osdProfile.item_pos[OSD_RSSI_VALUE] = -59; + masterConfig.osdProfile.item_pos[OSD_TIMER] = -39; + masterConfig.osdProfile.item_pos[OSD_THROTTLE_POS] = -9; + masterConfig.osdProfile.item_pos[OSD_CPU_LOAD] = 26; + masterConfig.osdProfile.item_pos[OSD_VTX_CHANNEL] = 1; + masterConfig.osdProfile.item_pos[OSD_VOLTAGE_WARNING] = -80; + masterConfig.osdProfile.item_pos[OSD_ARMED] = -107; + masterConfig.osdProfile.item_pos[OSD_DISARMED] = -109; + masterConfig.osdProfile.item_pos[OSD_ARTIFICIAL_HORIZON] = -1; + masterConfig.osdProfile.item_pos[OSD_HORIZON_SIDEBARS] = -1; +} + #endif diff --git a/src/main/io/osd.h b/src/main/io/osd.h index 486ff655a9..82932b14c7 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -62,3 +62,4 @@ typedef struct { void updateOsd(void); void osdInit(void); +void resetOsdConfig(void); diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index e08e932287..e87ab7ae6c 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -204,7 +204,7 @@ static const char * const featureNames[] = { "SONAR", "TELEMETRY", "CURRENT_METER", "3D", "RX_PARALLEL_PWM", "RX_MSP", "RSSI_ADC", "LED_STRIP", "DISPLAY", "ONESHOT125", "BLACKBOX", "CHANNEL_FORWARDING", "TRANSPONDER", "AIRMODE", "SUPEREXPO_RATES", - NULL + "OSD", NULL }; // sync this with rxFailsafeChannelMode_e @@ -819,6 +819,8 @@ const clivalue_t valueTable[] = { { "osd_voltage_warning_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_VOLTAGE_WARNING], .config.minmax = { -480, 480 } }, { "osd_armed_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_ARMED], .config.minmax = { -480, 480 } }, { "osd_disarmed_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_DISARMED], .config.minmax = { -480, 480 } }, + { "osd_artificial_horizon", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_ARTIFICIAL_HORIZON], .config.minmax = { -1, 0 } }, + { "osd_horizon_sidebars", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_HORIZON_SIDEBARS], .config.minmax = { -1, 0 } }, #endif }; diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index f1a5e8d318..983cf5884d 100644 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -1214,6 +1214,21 @@ static bool processOutCommand(uint8_t cmdMSP) #endif break; + case MSP_OSD_CONFIG: +#ifdef OSD + headSerialReply(2 + (OSD_MAX_ITEMS * 2)); + serialize8(1); // OSD supported + // send video system (AUTO/PAL/NTSC) + serialize8(masterConfig.osdProfile.video_system); + for (i = 0; i < OSD_MAX_ITEMS; i++) { + serialize16(masterConfig.osdProfile.item_pos[i]); + } +#else + headSerialReply(1); + serialize8(0); // OSD not supported +#endif + break; + case MSP_BF_BUILD_INFO: headSerialReply(11 + 4 + 4); for (i = 0; i < 11; i++) @@ -1524,9 +1539,15 @@ static bool processInCommand(void) #endif #ifdef OSD case MSP_SET_OSD_CONFIG: - masterConfig.osdProfile.video_system = read8(); - for (i = 0; i < OSD_MAX_ITEMS; i++) - masterConfig.osdProfile.item_pos[i] = read16(); + addr = read8(); + // set all the other settings + if ((int8_t)addr == -1) { + masterConfig.osdProfile.video_system = read8(); + } + // set a position setting + else { + masterConfig.osdProfile.item_pos[addr] = read16(); + } break; case MSP_OSD_CHAR_WRITE: addr = read8();