mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 17:25:13 +03:00
Fixes #3047:
* negative altitude on top bar was displayed wrong (same bug affected vertical speed) * add ability to select an altitude sensor with ft unit for top bar * display actual sensor unit for top bar altitude
This commit is contained in:
parent
a1d44d4d9f
commit
f854442c79
4 changed files with 12 additions and 12 deletions
|
@ -164,12 +164,8 @@ enum SensorFields {
|
|||
|
||||
bool isSensorUnit(int sensor, uint8_t unit)
|
||||
{
|
||||
if (sensor == 0)
|
||||
return true;
|
||||
|
||||
sensor -= 1;
|
||||
|
||||
return g_model.telemetrySensors[sensor].unit == unit;
|
||||
if (sensor <= 0 || sensor > MAX_SENSORS ) return true;
|
||||
return g_model.telemetrySensors[--sensor].unit == unit;
|
||||
}
|
||||
|
||||
bool isCellsSensor(int sensor)
|
||||
|
@ -184,7 +180,7 @@ bool isGPSSensor(int sensor)
|
|||
|
||||
bool isAltSensor(int sensor)
|
||||
{
|
||||
return isSensorUnit(sensor, UNIT_DIST);
|
||||
return isSensorUnit(sensor, UNIT_DIST) || isSensorUnit(sensor, UNIT_FEET);
|
||||
}
|
||||
|
||||
bool isVoltsSensor(int sensor)
|
||||
|
|
|
@ -254,7 +254,7 @@ void displayTopBar()
|
|||
if (altitudeItem.isAvailable()) {
|
||||
LCD_ICON(altitude_icon_x, BAR_Y, ICON_ALTITUDE);
|
||||
int32_t value = altitudeItem.value / g_model.telemetrySensors[item].getPrecDivisor();
|
||||
putsValueWithUnit(altitude_icon_x+2*FW-1, BAR_Y+1, value, UNIT_METERS, LEFT);
|
||||
putsValueWithUnit(altitude_icon_x+2*FW-1, BAR_Y+1, value, g_model.telemetrySensors[item].unit, LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1317,8 +1317,8 @@ PACK(typedef struct {
|
|||
int32_t getValue(int32_t value, uint8_t unit, uint8_t prec) const;
|
||||
bool isConfigurable() const;
|
||||
bool isPrecConfigurable() const;
|
||||
uint32_t getPrecMultiplier() const;
|
||||
uint32_t getPrecDivisor() const;
|
||||
int32_t getPrecMultiplier() const;
|
||||
int32_t getPrecDivisor() const;
|
||||
}) TelemetrySensor;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -647,14 +647,18 @@ bool TelemetrySensor::isPrecConfigurable() const
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t TelemetrySensor::getPrecMultiplier() const
|
||||
int32_t TelemetrySensor::getPrecMultiplier() const
|
||||
{
|
||||
/*
|
||||
Important: the return type must be signed, otherwise
|
||||
mathematic operations with a negative telemetry value won't work
|
||||
*/
|
||||
if (prec == 2) return 1;
|
||||
if (prec == 1) return 10;
|
||||
return 100;
|
||||
}
|
||||
|
||||
uint32_t TelemetrySensor::getPrecDivisor() const
|
||||
int32_t TelemetrySensor::getPrecDivisor() const
|
||||
{
|
||||
if (prec == 2) return 100;
|
||||
if (prec == 1) return 10;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue