mirror of https://github.com/ArduPilot/ardupilot
AP_OSD: use get_max_rpm_esc()
allow ESC index to be specified for OSD ESC info
This commit is contained in:
parent
038735657a
commit
451c1ae347
|
@ -259,6 +259,9 @@ private:
|
|||
AP_Int8 txt_resolution;
|
||||
AP_Int8 font_index;
|
||||
#endif
|
||||
#if HAL_WITH_ESC_TELEM
|
||||
AP_Int8 esc_index;
|
||||
#endif
|
||||
|
||||
void draw_altitude(uint8_t x, uint8_t y);
|
||||
void draw_bat_volt(uint8_t instance,VoltageType type,uint8_t x, uint8_t y);
|
||||
|
|
|
@ -358,7 +358,7 @@ const AP_Param::GroupInfo AP_OSD_Screen::var_info[] = {
|
|||
#if HAL_WITH_ESC_TELEM
|
||||
// @Param: ESCTEMP_EN
|
||||
// @DisplayName: ESCTEMP_EN
|
||||
// @Description: Displays first esc's temp
|
||||
// @Description: Displays highest temp of all active ESCs, or of a specific ECS if OSDx_ESC_IDX is set
|
||||
// @Values: 0:Disabled,1:Enabled
|
||||
|
||||
// @Param: ESCTEMP_X
|
||||
|
@ -374,7 +374,7 @@ const AP_Param::GroupInfo AP_OSD_Screen::var_info[] = {
|
|||
|
||||
// @Param: ESCRPM_EN
|
||||
// @DisplayName: ESCRPM_EN
|
||||
// @Description: Displays first esc's rpm
|
||||
// @Description: Displays highest rpm of all active ESCs, or of a specific ESC if OSDx_ESC_IDX is set
|
||||
// @Values: 0:Disabled,1:Enabled
|
||||
|
||||
// @Param: ESCRPM_X
|
||||
|
@ -390,7 +390,7 @@ const AP_Param::GroupInfo AP_OSD_Screen::var_info[] = {
|
|||
|
||||
// @Param: ESCAMPS_EN
|
||||
// @DisplayName: ESCAMPS_EN
|
||||
// @Description: Displays first esc's current
|
||||
// @Description: Displays the current of the ESC with the highest rpm of all active ESCs, or of a specific ESC if OSDx_ESC_IDX is set
|
||||
// @Values: 0:Disabled,1:Enabled
|
||||
|
||||
// @Param: ESCAMPS_X
|
||||
|
@ -1166,6 +1166,14 @@ const AP_Param::GroupInfo AP_OSD_Screen::var_info2[] = {
|
|||
AP_SUBGROUPINFO(rc_lq, "RC_LQ", 9, AP_OSD_Screen, AP_OSD_Setting),
|
||||
#endif
|
||||
|
||||
#if HAL_WITH_ESC_TELEM
|
||||
// @Param: ESC_IDX
|
||||
// @DisplayName: ESC_IDX
|
||||
// @Description: Index of the ESC to use for displaying ESC information. 0 means use the ESC with the highest value.
|
||||
// @Range: 0 32
|
||||
AP_GROUPINFO("ESC_IDX", 10, AP_OSD_Screen, esc_index, 0),
|
||||
#endif
|
||||
|
||||
AP_GROUPEND
|
||||
};
|
||||
|
||||
|
@ -2003,8 +2011,13 @@ void AP_OSD_Screen::draw_vspeed(uint8_t x, uint8_t y)
|
|||
void AP_OSD_Screen::draw_esc_temp(uint8_t x, uint8_t y)
|
||||
{
|
||||
int16_t etemp;
|
||||
// first parameter is index into array of ESC's. Hardwire to zero (first) for now.
|
||||
if (!AP::esc_telem().get_temperature(0, etemp)) {
|
||||
|
||||
if (esc_index > 0) {
|
||||
if (!AP::esc_telem().get_motor_temperature(esc_index-1, etemp)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!AP::esc_telem().get_highest_motor_temperature(etemp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2014,8 +2027,12 @@ void AP_OSD_Screen::draw_esc_temp(uint8_t x, uint8_t y)
|
|||
void AP_OSD_Screen::draw_esc_rpm(uint8_t x, uint8_t y)
|
||||
{
|
||||
float rpm;
|
||||
// first parameter is index into array of ESC's. Hardwire to zero (first) for now.
|
||||
if (!AP::esc_telem().get_rpm(0, rpm)) {
|
||||
uint8_t esc = AP::esc_telem().get_max_rpm_esc();
|
||||
if (esc_index > 0) {
|
||||
if (!AP::esc_telem().get_rpm(esc_index-1, rpm)) {
|
||||
return;
|
||||
}
|
||||
} else if (!AP::esc_telem().get_rpm(esc, rpm)) {
|
||||
return;
|
||||
}
|
||||
float krpm = rpm * 0.001f;
|
||||
|
@ -2026,8 +2043,12 @@ void AP_OSD_Screen::draw_esc_rpm(uint8_t x, uint8_t y)
|
|||
void AP_OSD_Screen::draw_esc_amps(uint8_t x, uint8_t y)
|
||||
{
|
||||
float amps;
|
||||
// first parameter is index into array of ESC's. Hardwire to zero (first) for now.
|
||||
if (!AP::esc_telem().get_current(0, amps)) {
|
||||
uint8_t esc = AP::esc_telem().get_max_rpm_esc();
|
||||
if (esc_index > 0) {
|
||||
if (!AP::esc_telem().get_current(esc_index-1, amps)) {
|
||||
return;
|
||||
}
|
||||
} else if (!AP::esc_telem().get_current(esc, amps)) {
|
||||
return;
|
||||
}
|
||||
backend->write(x, y, false, "%4.1f%c", amps, SYMBOL(SYM_AMP));
|
||||
|
|
Loading…
Reference in New Issue