diff --git a/src/main/interface/settings.c b/src/main/interface/settings.c index 097fb6d380..50d60ad3ed 100644 --- a/src/main/interface/settings.c +++ b/src/main/interface/settings.c @@ -1010,6 +1010,7 @@ const clivalue_t valueTable[] = { { "osd_ah_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_ARTIFICIAL_HORIZON]) }, { "osd_current_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_CURRENT_DRAW]) }, { "osd_mah_drawn_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_MAH_DRAWN]) }, + { "osd_motor_diag_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_MOTOR_DIAG]) }, { "osd_craft_name_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_CRAFT_NAME]) }, { "osd_gps_speed_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_GPS_SPEED]) }, { "osd_gps_lon_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_GPS_LON]) }, diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 341f4415ff..33849d29ce 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -71,9 +71,7 @@ #include "flight/failsafe.h" #include "flight/position.h" #include "flight/imu.h" -#ifdef USE_ESC_SENSOR #include "flight/mixer.h" -#endif #include "flight/pid.h" #include "io/asyncfatfs/asyncfatfs.h" @@ -207,6 +205,7 @@ static const uint8_t osdElementDisplayOrder[] = { OSD_NUMERICAL_VARIO, OSD_COMPASS_BAR, OSD_ANTI_GRAVITY, + OSD_MOTOR_DIAG, OSD_FLIP_ARROW, #ifdef USE_RTC_TIME OSD_RTC_DATETIME, @@ -654,6 +653,20 @@ static bool osdDrawSingleElement(uint8_t item) break; } + + case OSD_MOTOR_DIAG: + if(areMotorsRunning()) { + int maxIdx = 0; + int i = 0; + for(; i < getMotorCount(); i++) { + if(motor[i] > motor[maxIdx]) { + maxIdx = i; + } + buff[i] = 0x88 - scaleRange(motor[i], motorOutputLow, motorOutputHigh, 0, 8); + } + buff[i] = '\0'; + } + break; case OSD_CRAFT_NAME: // This does not strictly support iterative updating if the craft name changes at run time. But since the craft name is not supposed to be changing this should not matter, and blanking the entire length of the craft name string on update will make it impossible to configure elements to be displayed on the right hand side of the craft name. diff --git a/src/main/io/osd.h b/src/main/io/osd.h index d9c226d33e..3566d36f33 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -95,6 +95,7 @@ typedef enum { OSD_ADJUSTMENT_RANGE, OSD_CORE_TEMPERATURE, OSD_ANTI_GRAVITY, + OSD_MOTOR_DIAG, OSD_G_FORCE, OSD_LOG_STATUS, OSD_FLIP_ARROW, diff --git a/src/test/unit/osd_unittest.cc b/src/test/unit/osd_unittest.cc index e842af53e9..c35a03ad57 100644 --- a/src/test/unit/osd_unittest.cc +++ b/src/test/unit/osd_unittest.cc @@ -54,6 +54,7 @@ extern "C" { #include "sensors/battery.h" #include "rx/rx.h" + #include "flight/mixer.h" void osdRefresh(timeUs_t currentTimeUs); void osdFormatTime(char * buff, osd_timer_precision_e precision, timeUs_t time); @@ -70,6 +71,10 @@ extern "C" { int16_t GPS_directionToHome; int32_t GPS_coord[2]; gpsSolutionData_t gpsSol; + float motor[8]; + float motorOutputHigh = 2047; + float motorOutputLow = 1000; + acc_t acc; float accAverage[XYZ_AXIS_COUNT]; @@ -1052,7 +1057,9 @@ extern "C" { return false; } + float pidItermAccelerator(void) { return 1.0; } + uint8_t getMotorCount(void){ return 4; } + bool areMotorsRunning(void){ return true; } bool pidOsdAntiGravityActive(void) { return false; } - bool failsafeIsActive(void) { return false; } }