mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-23 16:25:12 +03:00
Re #2826: Lua API: return proper values for Cels-
and Cels+
This commit is contained in:
parent
164844319a
commit
67c0326cca
1 changed files with 12 additions and 7 deletions
|
@ -179,20 +179,23 @@ void luaGetValueAndPush(int src)
|
||||||
getvalue_t value = getValue(src); // ignored for GPS, DATETIME, and CELLS
|
getvalue_t value = getValue(src); // ignored for GPS, DATETIME, and CELLS
|
||||||
|
|
||||||
if (src >= MIXSRC_FIRST_TELEM && src <= MIXSRC_LAST_TELEM) {
|
if (src >= MIXSRC_FIRST_TELEM && src <= MIXSRC_LAST_TELEM) {
|
||||||
src = (src-MIXSRC_FIRST_TELEM) / 3;
|
div_t qr = div(src-MIXSRC_FIRST_TELEM, 3);
|
||||||
// telemetry values
|
// telemetry values
|
||||||
if (TELEMETRY_STREAMING() && telemetryItems[src].isAvailable()) {
|
if (TELEMETRY_STREAMING() && telemetryItems[qr.quot].isAvailable()) {
|
||||||
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[src];
|
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[qr.quot];
|
||||||
switch (telemetrySensor.unit) {
|
switch (telemetrySensor.unit) {
|
||||||
case UNIT_GPS:
|
case UNIT_GPS:
|
||||||
luaPushLatLon(telemetrySensor, telemetryItems[src]);
|
luaPushLatLon(telemetrySensor, telemetryItems[qr.quot]);
|
||||||
break;
|
break;
|
||||||
case UNIT_DATETIME:
|
case UNIT_DATETIME:
|
||||||
luaPushTelemetryDateTime(telemetrySensor, telemetryItems[src]);
|
luaPushTelemetryDateTime(telemetrySensor, telemetryItems[qr.quot]);
|
||||||
break;
|
break;
|
||||||
case UNIT_CELLS:
|
case UNIT_CELLS:
|
||||||
luaPushCells(telemetrySensor, telemetryItems[src]);
|
if (qr.rem == 0) {
|
||||||
break;
|
luaPushCells(telemetrySensor, telemetryItems[qr.quot]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// deliberate no break here to properly return `Cels-` and `Cels+`
|
||||||
default:
|
default:
|
||||||
if (telemetrySensor.prec > 0)
|
if (telemetrySensor.prec > 0)
|
||||||
lua_pushnumber(L, float(value)/telemetrySensor.getPrecDivisor());
|
lua_pushnumber(L, float(value)/telemetrySensor.getPrecDivisor());
|
||||||
|
@ -417,6 +420,8 @@ case the returned value is 0):
|
||||||
@status current Introduced in 2.0.0, changed in 2.1.0
|
@status current Introduced in 2.0.0, changed in 2.1.0
|
||||||
|
|
||||||
@notice Getting a value by its numerical identifier is faster then by its name.
|
@notice Getting a value by its numerical identifier is faster then by its name.
|
||||||
|
While `Cels` sensor returns current values of all cells in a table, a `Cels+` or
|
||||||
|
`Cels-` will return a single value - the maximum or minimum Cels value.
|
||||||
*/
|
*/
|
||||||
static int luaGetValue(lua_State *L)
|
static int luaGetValue(lua_State *L)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue