Initial implementation

Percentage implementation

Settings fix, formatting

Add support for different number of motors

Optimize and cut superfluous code

Hard-add mixer.h

Formatting adjustment to fit BF standards, linking error in unittest fix attempt

Add stubs and variables for unittests

Character based indicators

Change output to special characters

Fix spacing

Update test code, add variable

Include changes as per peer review
This commit is contained in:
Maciej Janowski 2018-06-13 22:17:00 +02:00 committed by cahe
parent 11d8171c36
commit 3d2d5a2efa
4 changed files with 25 additions and 3 deletions

View File

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

View File

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

View File

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

View File

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