1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 16:55:20 +03:00

POC for review and discussion

This commit is contained in:
3djc 2018-02-28 11:34:32 +01:00
parent 4cccff934f
commit fdf4d4926f
5 changed files with 21 additions and 1 deletions

View file

@ -218,6 +218,11 @@ static void luaPushCells(lua_State* L, TelemetrySensor & telemetrySensor, Teleme
void luaGetValueAndPush(lua_State* L, int src) void luaGetValueAndPush(lua_State* L, int src)
{ {
if(IS_FAI_FORBIDDEN(src)) {
lua_pushinteger(L, 0);
return;
}
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) {
@ -587,6 +592,7 @@ or a name (string) of the source.
@retval value current source value (number). Zero is returned for: @retval value current source value (number). Zero is returned for:
* non-existing sources * non-existing sources
* for all telemetry source when the telemetry stream is not received * for all telemetry source when the telemetry stream is not received
* far all non allowed sensors while FAI MODE is active
@retval table GPS position is returned in a table: @retval table GPS position is returned in a table:
* `lat` (number) latitude, positive is North * `lat` (number) latitude, positive is North

View file

@ -448,6 +448,9 @@ getvalue_t getValue(mixsrc_t i)
#if defined(CPUARM) #if defined(CPUARM)
else if (i <= MIXSRC_LAST_TELEM) { else if (i <= MIXSRC_LAST_TELEM) {
if(IS_FAI_FORBIDDEN(i)) {
return 0;
}
i -= MIXSRC_FIRST_TELEM; i -= MIXSRC_FIRST_TELEM;
div_t qr = div(i, 3); div_t qr = div(i, 3);
TelemetryItem & telemetryItem = telemetryItems[qr.quot]; TelemetryItem & telemetryItem = telemetryItems[qr.quot];

View file

@ -231,7 +231,7 @@
#define IF_FAI_CHOICE(x) #define IF_FAI_CHOICE(x)
#endif #endif
#define IS_FAI_FORBIDDEN(idx) (IS_FAI_ENABLED() && idx >= MIXSRC_FIRST_TELEM) #define IS_FAI_FORBIDDEN(idx) (IS_FAI_ENABLED() && isFaiForbidden(idx))
#if defined(BLUETOOTH) #if defined(BLUETOOTH)
#if defined(X9E) && !defined(USEHORUSBT) #if defined(X9E) && !defined(USEHORUSBT)

View file

@ -23,6 +23,16 @@
TelemetryItem telemetryItems[MAX_TELEMETRY_SENSORS]; TelemetryItem telemetryItems[MAX_TELEMETRY_SENSORS];
uint8_t allowNewSensors; uint8_t allowNewSensors;
bool isFaiForbidden(source_t idx) {
TelemetrySensor * sensor = &g_model.telemetrySensors[idx-MIXSRC_FIRST_TELEM];
if (sensor->id == RSSI_ID) {
return false;
}
else {
return true;
}
}
// TODO in maths // TODO in maths
uint32_t getDistFromEarthAxis(int32_t latitude) uint32_t getDistFromEarthAxis(int32_t latitude)
{ {

View file

@ -136,5 +136,6 @@ class TelemetryItem
extern TelemetryItem telemetryItems[MAX_TELEMETRY_SENSORS]; extern TelemetryItem telemetryItems[MAX_TELEMETRY_SENSORS];
extern uint8_t allowNewSensors; extern uint8_t allowNewSensors;
bool isFaiForbidden(source_t idx);
#endif // _TELEMETRY_SENSORS_H_ #endif // _TELEMETRY_SENSORS_H_