diff --git a/src/main/interface/settings.c b/src/main/interface/settings.c index 45fb4cd349..e86edc331d 100644 --- a/src/main/interface/settings.c +++ b/src/main/interface/settings.c @@ -933,6 +933,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 c0829e2718..0367a2f25c 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -67,9 +67,7 @@ #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" @@ -197,7 +195,8 @@ static const uint8_t osdElementDisplayOrder[] = { OSD_NUMERICAL_HEADING, OSD_NUMERICAL_VARIO, OSD_COMPASS_BAR, - OSD_ANTI_GRAVITY + OSD_ANTI_GRAVITY, + OSD_MOTOR_DIAG }; PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 3); @@ -600,6 +599,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 644ed0718e..4045a281b6 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_ITEM_COUNT // MUST BE LAST } osd_items_e; diff --git a/src/test/unit/osd_unittest.cc b/src/test/unit/osd_unittest.cc index 353fddcc9d..718f10b274 100644 --- a/src/test/unit/osd_unittest.cc +++ b/src/test/unit/osd_unittest.cc @@ -51,6 +51,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); @@ -67,6 +68,10 @@ extern "C" { int16_t GPS_directionToHome; int32_t GPS_coord[2]; gpsSolutionData_t gpsSol; + float motor[8]; + float motorOutputHigh = 2047; + float motorOutputLow = 1000; + PG_REGISTER(batteryConfig_t, batteryConfig, PG_BATTERY_CONFIG, 0); PG_REGISTER(blackboxConfig_t, blackboxConfig, PG_BLACKBOX_CONFIG, 0); @@ -1032,4 +1037,6 @@ extern "C" { } float pidItermAccelerator(void) { return 1.0; } + uint8_t getMotorCount(void){ return 4; } + bool areMotorsRunning(void){ return true; } }