chores: update to LUA 5.3 (#4203)
Co-authored-by: Peter Feerick <peter.feerick@gmail.com> Co-authored-by: philmoz <phil.a.mitchell@gmail.com>
This commit is contained in:
co-authored by
Peter Feerick
philmoz
parent
28b0cb9e71
commit
47cba2211f
+38
-36
@@ -30,6 +30,8 @@
|
||||
#include "gvars.h"
|
||||
#include "mixes.h"
|
||||
|
||||
#include "lua_states.h"
|
||||
|
||||
#include <storage/sdcard_yaml.h>
|
||||
|
||||
#if defined(MULTIMODULE)
|
||||
@@ -100,7 +102,7 @@ static int luaModelSetInfo(lua_State *L)
|
||||
g_model.extendedLimits = lua_toboolean(L, -1);
|
||||
}
|
||||
else if (!strcmp(key, "jitterFilter")) {
|
||||
auto j = lua_tounsigned(L, -1);
|
||||
auto j = lua_tointeger(L, -1);
|
||||
if (j > OVERRIDE_ON) j = OVERRIDE_ON;
|
||||
g_model.jitterFilter = j;
|
||||
}
|
||||
@@ -162,7 +164,7 @@ Get RF module parameters
|
||||
*/
|
||||
static int luaModelGetModule(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
if (idx < NUM_MODULES) {
|
||||
ModuleData & module = g_model.moduleData[idx];
|
||||
lua_newtable(L);
|
||||
@@ -211,7 +213,7 @@ that parameter remains unchanged.
|
||||
*/
|
||||
static int luaModelSetModule(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
|
||||
if (idx < NUM_MODULES) {
|
||||
int protocol = -1;
|
||||
@@ -283,7 +285,7 @@ Get model timer parameters
|
||||
*/
|
||||
static int luaModelGetTimer(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
if (idx < MAX_TIMERS) {
|
||||
TimerData & timer = g_model.timers[idx];
|
||||
lua_newtable(L);
|
||||
@@ -321,7 +323,7 @@ that parameter remains unchanged.
|
||||
*/
|
||||
static int luaModelSetTimer(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
|
||||
if (idx < MAX_TIMERS) {
|
||||
TimerData & timer = g_model.timers[idx];
|
||||
@@ -380,7 +382,7 @@ Reset model timer to a startup value
|
||||
*/
|
||||
static int luaModelResetTimer(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
if (idx < MAX_TIMERS) {
|
||||
timerReset(idx);
|
||||
}
|
||||
@@ -427,7 +429,7 @@ Return number of lines for given input
|
||||
*/
|
||||
static int luaModelGetInputsCount(lua_State *L)
|
||||
{
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int chn = luaL_checkinteger(L, 1);
|
||||
int count = getInputsCount(chn);
|
||||
lua_pushinteger(L, count);
|
||||
return 1;
|
||||
@@ -471,7 +473,7 @@ Return input data for given input and line number
|
||||
*/
|
||||
static int luaModelGetFlightMode(lua_State * L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
if (idx < MAX_FLIGHT_MODES) {
|
||||
FlightModeData * fm = flightModeAddress(idx);
|
||||
lua_newtable(L);
|
||||
@@ -515,7 +517,7 @@ Set Flight mode parameters
|
||||
*/
|
||||
static int luaModelSetFlightMode(lua_State * L)
|
||||
{
|
||||
unsigned int flightMode = luaL_checkunsigned(L, 1);
|
||||
unsigned int flightMode = luaL_checkinteger(L, 1);
|
||||
|
||||
if (flightMode >= MAX_FLIGHT_MODES) {
|
||||
lua_pushinteger(L, 2);
|
||||
@@ -599,8 +601,8 @@ Return input data for given input and line number
|
||||
*/
|
||||
static int luaModelGetInput(lua_State *L)
|
||||
{
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 2);
|
||||
unsigned int chn = luaL_checkinteger(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 2);
|
||||
unsigned int first = getFirstInput(chn);
|
||||
unsigned int count = getInputsCountFromFirst(chn, first);
|
||||
if (idx < count) {
|
||||
@@ -639,8 +641,8 @@ Insert an Input at specified line
|
||||
*/
|
||||
static int luaModelInsertInput(lua_State *L)
|
||||
{
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 2);
|
||||
unsigned int chn = luaL_checkinteger(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 2);
|
||||
|
||||
unsigned int first = getFirstInput(chn);
|
||||
unsigned int count = getInputsCountFromFirst(chn, first);
|
||||
@@ -724,8 +726,8 @@ Delete line from specified input
|
||||
*/
|
||||
static int luaModelDeleteInput(lua_State *L)
|
||||
{
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 2);
|
||||
unsigned int chn = luaL_checkinteger(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 2);
|
||||
|
||||
int first = getFirstInput(chn);
|
||||
unsigned int count = getInputsCountFromFirst(chn, first);
|
||||
@@ -804,7 +806,7 @@ Get the number of Mixer lines that the specified Channel has
|
||||
*/
|
||||
static int luaModelGetMixesCount(lua_State *L)
|
||||
{
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int chn = luaL_checkinteger(L, 1);
|
||||
unsigned int count = getMixesCount(chn);
|
||||
lua_pushinteger(L, count);
|
||||
return 1;
|
||||
@@ -842,8 +844,8 @@ Get configuration for specified Mix
|
||||
*/
|
||||
static int luaModelGetMix(lua_State *L)
|
||||
{
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 2);
|
||||
unsigned int chn = luaL_checkinteger(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 2);
|
||||
unsigned int first = getFirstMix(chn);
|
||||
unsigned int count = getMixesCountFromFirst(chn, first);
|
||||
if (idx < count) {
|
||||
@@ -886,8 +888,8 @@ Insert a mixer line into Channel
|
||||
*/
|
||||
static int luaModelInsertMix(lua_State *L)
|
||||
{
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 2);
|
||||
unsigned int chn = luaL_checkinteger(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 2);
|
||||
|
||||
unsigned int first = getFirstMix(chn);
|
||||
unsigned int count = getMixesCountFromFirst(chn, first);
|
||||
@@ -977,8 +979,8 @@ Delete mixer line from specified Channel
|
||||
*/
|
||||
static int luaModelDeleteMix(lua_State *L)
|
||||
{
|
||||
unsigned int chn = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkunsigned(L, 2);
|
||||
unsigned int chn = luaL_checkinteger(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 2);
|
||||
|
||||
unsigned int first = getFirstMix(chn);
|
||||
unsigned int count = getMixesCountFromFirst(chn, first);
|
||||
@@ -1025,7 +1027,7 @@ Get Logical Switch parameters
|
||||
*/
|
||||
static int luaModelGetLogicalSwitch(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
if (idx < MAX_LOGICAL_SWITCHES) {
|
||||
LogicalSwitchData * sw = lswAddress(idx);
|
||||
lua_newtable(L);
|
||||
@@ -1062,7 +1064,7 @@ use the following syntax: `model.setLogicalSwitch(30, {func=4,v1=1,v2=-99, ["and
|
||||
*/
|
||||
static int luaModelSetLogicalSwitch(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
if (idx < MAX_LOGICAL_SWITCHES) {
|
||||
LogicalSwitchData * sw = lswAddress(idx);
|
||||
memclear(sw, sizeof(LogicalSwitchData));
|
||||
@@ -1126,7 +1128,7 @@ Get Curve parameters
|
||||
*/
|
||||
static int luaModelGetCurve(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
if (idx < MAX_CURVES) {
|
||||
CurveHeader & CurveHeader = g_model.curves[idx];
|
||||
lua_newtable(L);
|
||||
@@ -1207,7 +1209,7 @@ setting a 6-point standard smoothed curve
|
||||
*/
|
||||
static int luaModelSetCurve(lua_State *L)
|
||||
{
|
||||
unsigned int curveIdx = luaL_checkunsigned(L, 1);
|
||||
unsigned int curveIdx = luaL_checkinteger(L, 1);
|
||||
|
||||
if (curveIdx >= MAX_CURVES) {
|
||||
lua_pushinteger(L, 2);
|
||||
@@ -1382,7 +1384,7 @@ Get Custom Function parameters
|
||||
*/
|
||||
static int luaModelGetCustomFunction(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
if (idx < MAX_SPECIAL_FUNCTIONS) {
|
||||
CustomFunctionData * cfn = &g_model.customFn[idx];
|
||||
lua_newtable(L);
|
||||
@@ -1421,7 +1423,7 @@ that parameter remains unchanged.
|
||||
*/
|
||||
static int luaModelSetCustomFunction(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
if (idx < MAX_SPECIAL_FUNCTIONS) {
|
||||
CustomFunctionData * cfn = &g_model.customFn[idx];
|
||||
memclear(cfn, sizeof(CustomFunctionData));
|
||||
@@ -1486,7 +1488,7 @@ Get servo parameters
|
||||
*/
|
||||
static int luaModelGetOutput(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
if (idx < MAX_OUTPUT_CHANNELS) {
|
||||
LimitData * limit = limitAddress(idx);
|
||||
lua_newtable(L);
|
||||
@@ -1522,7 +1524,7 @@ that parameter remains unchanged.
|
||||
*/
|
||||
static int luaModelSetOutput(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
if (idx < MAX_OUTPUT_CHANNELS) {
|
||||
LimitData * limit = limitAddress(idx);
|
||||
memclear(limit, sizeof(LimitData));
|
||||
@@ -1587,8 +1589,8 @@ Example:
|
||||
*/
|
||||
static int luaModelGetGlobalVariable(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int phase = luaL_checkunsigned(L, 2);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
unsigned int phase = luaL_checkinteger(L, 2);
|
||||
if (phase < MAX_FLIGHT_MODES && idx < MAX_GVARS)
|
||||
lua_pushinteger(L, getGVarValue(idx, phase));
|
||||
else
|
||||
@@ -1614,8 +1616,8 @@ by truncating everything behind a floating point.
|
||||
*/
|
||||
static int luaModelSetGlobalVariable(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int phase = luaL_checkunsigned(L, 2);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
unsigned int phase = luaL_checkinteger(L, 2);
|
||||
int value = luaL_checkinteger(L, 3);
|
||||
if (phase < MAX_FLIGHT_MODES && idx < MAX_GVARS && value >= -GVAR_MAX && value <= GVAR_MAX) {
|
||||
SET_GVAR(idx, value, phase);
|
||||
@@ -1722,7 +1724,7 @@ Get Telemetry Sensor parameters
|
||||
*/
|
||||
static int luaModelGetSensor(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
if (idx < MAX_TELEMETRY_SENSORS) {
|
||||
TelemetrySensor & sensor = g_model.telemetrySensors[idx];
|
||||
lua_newtable(L);
|
||||
@@ -1757,7 +1759,7 @@ Reset Telemetry Sensor parameters
|
||||
*/
|
||||
static int luaModelResetSensor(lua_State *L)
|
||||
{
|
||||
unsigned int idx = luaL_checkunsigned(L, 1);
|
||||
unsigned int idx = luaL_checkinteger(L, 1);
|
||||
if (idx < MAX_TELEMETRY_SENSORS) {
|
||||
telemetryItems[idx].clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user