Merge pull request #6114 from cahe/motor-diag

Motor diagnostic OSD feature
This commit is contained in:
Michael Keller 2018-10-30 22:10:27 +13:00 committed by GitHub
commit e6ff5f2b24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 3 deletions

View File

@ -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]) },

View File

@ -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,
@ -655,6 +654,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.
//TODO: When iterative updating is implemented, change this so the craft name is only printed once whenever the OSD 'flight' screen is entered.

View File

@ -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,

View File

@ -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; }
}