Merge pull request #171 from EdgeTX/model-wizard-fix
ZChar nightmare / take 2
This commit is contained in:
@@ -448,10 +448,15 @@ void deleteMix(uint8_t idx)
|
|||||||
storageDirty(EE_MODEL);
|
storageDirty(EE_MODEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(LUA)
|
||||||
|
// This is necessary as the LUA API uses th old interface
|
||||||
|
// where insertMix() has only one param. The channel is
|
||||||
|
// passed through s_currCh
|
||||||
void insertMix(uint8_t idx)
|
void insertMix(uint8_t idx)
|
||||||
{
|
{
|
||||||
insertMix(idx, s_currCh + 1);
|
insertMix(idx, s_currCh - 1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void copyMix(uint8_t source, uint8_t dest, int8_t ch)
|
void copyMix(uint8_t source, uint8_t dest, int8_t ch)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -362,22 +362,20 @@ bool luaFindFieldByName(const char * name, LuaField & field, unsigned int flags)
|
|||||||
|
|
||||||
// search in telemetry
|
// search in telemetry
|
||||||
field.desc[0] = '\0';
|
field.desc[0] = '\0';
|
||||||
for (int i=0; i<MAX_TELEMETRY_SENSORS; i++) {
|
for (int i = 0; i < MAX_TELEMETRY_SENSORS; i++) {
|
||||||
if (isTelemetryFieldAvailable(i)) {
|
if (isTelemetryFieldAvailable(i)) {
|
||||||
const char* sensorName = g_model.telemetrySensors[i].label;
|
const char* sensorName = g_model.telemetrySensors[i].label;
|
||||||
if (!strncmp(sensorName, name, len)) {
|
if ((len <= TELEM_LABEL_LEN) && !strncmp(sensorName, name, len)) {
|
||||||
if (name[len] == '\0') {
|
if (name[len] == '\0') {
|
||||||
field.id = MIXSRC_FIRST_TELEM + 3*i;
|
field.id = MIXSRC_FIRST_TELEM + 3 * i;
|
||||||
field.desc[0] = '\0';
|
field.desc[0] = '\0';
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (name[len] == '-' && name[len + 1] == '\0') {
|
||||||
else if (name[len] == '-' && name[len+1] == '\0') {
|
field.id = MIXSRC_FIRST_TELEM + 3 * i + 1;
|
||||||
field.id = MIXSRC_FIRST_TELEM + 3*i + 1;
|
|
||||||
field.desc[0] = '\0';
|
field.desc[0] = '\0';
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (name[len] == '+' && name[len + 1] == '\0') {
|
||||||
else if (name[len] == '+' && name[len+1] == '\0') {
|
field.id = MIXSRC_FIRST_TELEM + 3 * i + 2;
|
||||||
field.id = MIXSRC_FIRST_TELEM + 3*i + 2;
|
|
||||||
field.desc[0] = '\0';
|
field.desc[0] = '\0';
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1377,28 +1375,25 @@ static int luaSetTelemetryValue(lua_State * L)
|
|||||||
uint32_t unit = luaL_optunsigned(L, 5, 0);
|
uint32_t unit = luaL_optunsigned(L, 5, 0);
|
||||||
uint32_t prec = luaL_optunsigned(L, 6, 0);
|
uint32_t prec = luaL_optunsigned(L, 6, 0);
|
||||||
|
|
||||||
char zname[4];
|
char name_buf[TELEM_LABEL_LEN]; // 4
|
||||||
const char* name = luaL_optstring(L, 7, NULL);
|
const char* name = luaL_optstring(L, 7, NULL);
|
||||||
if (name != NULL && strlen(name) > 0) {
|
if (name == NULL || strlen(name) > 0) {
|
||||||
str2zchar(zname, name, 4);
|
name_buf[0] = hex2char((id & 0xf000) >> 12);
|
||||||
}
|
name_buf[1] = hex2char((id & 0x0f00) >> 8);
|
||||||
else {
|
name_buf[2] = hex2char((id & 0x00f0) >> 4);
|
||||||
zname[0] = hex2zchar((id & 0xf000) >> 12);
|
name_buf[3] = hex2char((id & 0x000f) >> 0);
|
||||||
zname[1] = hex2zchar((id & 0x0f00) >> 8);
|
|
||||||
zname[2] = hex2zchar((id & 0x00f0) >> 4);
|
|
||||||
zname[3] = hex2zchar((id & 0x000f) >> 0);
|
|
||||||
}
|
}
|
||||||
if (id | subId | instance) {
|
if (id | subId | instance) {
|
||||||
int index = setTelemetryValue(PROTOCOL_TELEMETRY_LUA, id, subId, instance, value, unit, prec);
|
int index = setTelemetryValue(PROTOCOL_TELEMETRY_LUA, id, subId, instance,
|
||||||
|
value, unit, prec);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
TelemetrySensor &telemetrySensor = g_model.telemetrySensors[index];
|
TelemetrySensor &telemetrySensor = g_model.telemetrySensors[index];
|
||||||
telemetrySensor.id = id;
|
telemetrySensor.id = id;
|
||||||
telemetrySensor.subId = subId;
|
telemetrySensor.subId = subId;
|
||||||
telemetrySensor.instance = instance;
|
telemetrySensor.instance = instance;
|
||||||
telemetrySensor.init(zname, unit, prec);
|
telemetrySensor.init(name ? name: name_buf, unit, prec);
|
||||||
lua_pushboolean(L, true);
|
lua_pushboolean(L, true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
lua_pushboolean(L, false);
|
lua_pushboolean(L, false);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
+19
-19
@@ -39,9 +39,9 @@ Get current Model information
|
|||||||
static int luaModelGetInfo(lua_State *L)
|
static int luaModelGetInfo(lua_State *L)
|
||||||
{
|
{
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_pushtablestring(L, "name", g_model.header.name);
|
lua_pushtablenstring(L, "name", g_model.header.name);
|
||||||
#if LCD_DEPTH > 1
|
#if LCD_DEPTH > 1
|
||||||
lua_pushtablestring(L, "bitmap", g_model.header.bitmap);
|
lua_pushtablenstring(L, "bitmap", g_model.header.bitmap);
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ static int luaModelSetInfo(lua_State *L)
|
|||||||
const char * key = luaL_checkstring(L, -2);
|
const char * key = luaL_checkstring(L, -2);
|
||||||
if (!strcmp(key, "name")) {
|
if (!strcmp(key, "name")) {
|
||||||
const char * name = luaL_checkstring(L, -1);
|
const char * name = luaL_checkstring(L, -1);
|
||||||
str2zchar(g_model.header.name, name, sizeof(g_model.header.name));
|
strncpy(g_model.header.name, name, sizeof(g_model.header.name));
|
||||||
#if defined(EEPROM)
|
#if defined(EEPROM)
|
||||||
memcpy(modelHeaders[g_eeGeneral.currModel].name, g_model.header.name, sizeof(g_model.header.name));
|
memcpy(modelHeaders[g_eeGeneral.currModel].name, g_model.header.name, sizeof(g_model.header.name));
|
||||||
#endif
|
#endif
|
||||||
@@ -258,7 +258,7 @@ static int luaModelGetTimer(lua_State *L)
|
|||||||
lua_pushtableinteger(L, "countdownBeep", timer.countdownBeep);
|
lua_pushtableinteger(L, "countdownBeep", timer.countdownBeep);
|
||||||
lua_pushtableboolean(L, "minuteBeep", timer.minuteBeep);
|
lua_pushtableboolean(L, "minuteBeep", timer.minuteBeep);
|
||||||
lua_pushtableinteger(L, "persistent", timer.persistent);
|
lua_pushtableinteger(L, "persistent", timer.persistent);
|
||||||
lua_pushtablestring(L, "name", timer.name);
|
lua_pushtablenstring(L, "name", timer.name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
@@ -310,7 +310,7 @@ static int luaModelSetTimer(lua_State *L)
|
|||||||
}
|
}
|
||||||
if (!strcmp(key, "name")) {
|
if (!strcmp(key, "name")) {
|
||||||
const char * name = luaL_checkstring(L, -1);
|
const char * name = luaL_checkstring(L, -1);
|
||||||
str2zchar(timer.name, name, sizeof(timer.name));
|
strncpy(timer.name, name, sizeof(timer.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storageDirty(EE_MODEL);
|
storageDirty(EE_MODEL);
|
||||||
@@ -424,7 +424,7 @@ static int luaModelGetFlightMode(lua_State * L)
|
|||||||
if (idx < MAX_FLIGHT_MODES) {
|
if (idx < MAX_FLIGHT_MODES) {
|
||||||
FlightModeData * fm = flightModeAddress(idx);
|
FlightModeData * fm = flightModeAddress(idx);
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_pushtablestring(L, "name", fm->name);
|
lua_pushtablenstring(L, "name", fm->name);
|
||||||
lua_pushtableinteger(L, "switch", fm->swtch);
|
lua_pushtableinteger(L, "switch", fm->swtch);
|
||||||
lua_pushtableinteger(L, "fadeIn", fm->fadeIn);
|
lua_pushtableinteger(L, "fadeIn", fm->fadeIn);
|
||||||
lua_pushtableinteger(L, "fadeOut", fm->fadeOut);
|
lua_pushtableinteger(L, "fadeOut", fm->fadeOut);
|
||||||
@@ -477,7 +477,7 @@ static int luaModelSetFlightMode(lua_State * L)
|
|||||||
const char * key = luaL_checkstring(L, -2);
|
const char * key = luaL_checkstring(L, -2);
|
||||||
if (!strcmp(key, "name")) {
|
if (!strcmp(key, "name")) {
|
||||||
const char * name = luaL_checkstring(L, -1);
|
const char * name = luaL_checkstring(L, -1);
|
||||||
str2zchar(fm->name, name, sizeof(fm->name));
|
strncpy(fm->name, name, sizeof(fm->name));
|
||||||
}
|
}
|
||||||
else if (!strcmp(key, "switch")) {
|
else if (!strcmp(key, "switch")) {
|
||||||
fm->swtch = luaL_checkinteger(L, -1);
|
fm->swtch = luaL_checkinteger(L, -1);
|
||||||
@@ -546,8 +546,8 @@ static int luaModelGetInput(lua_State *L)
|
|||||||
if (idx < count) {
|
if (idx < count) {
|
||||||
ExpoData * expo = expoAddress(first+idx);
|
ExpoData * expo = expoAddress(first+idx);
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_pushtablestring(L, "name", expo->name);
|
lua_pushtablenstring(L, "name", expo->name);
|
||||||
lua_pushtablestring(L, "inputName", g_model.inputNames[chn]);
|
lua_pushtablenstring(L, "inputName", g_model.inputNames[chn]);
|
||||||
lua_pushtableinteger(L, "source", expo->srcRaw);
|
lua_pushtableinteger(L, "source", expo->srcRaw);
|
||||||
lua_pushtableinteger(L, "weight", expo->weight);
|
lua_pushtableinteger(L, "weight", expo->weight);
|
||||||
lua_pushtableinteger(L, "offset", expo->offset);
|
lua_pushtableinteger(L, "offset", expo->offset);
|
||||||
@@ -599,11 +599,11 @@ static int luaModelInsertInput(lua_State *L)
|
|||||||
const char * key = luaL_checkstring(L, -2);
|
const char * key = luaL_checkstring(L, -2);
|
||||||
if (!strcmp(key, "name")) {
|
if (!strcmp(key, "name")) {
|
||||||
const char * name = luaL_checkstring(L, -1);
|
const char * name = luaL_checkstring(L, -1);
|
||||||
str2zchar(expo->name, name, sizeof(expo->name));
|
strncpy(expo->name, name, sizeof(expo->name));
|
||||||
}
|
}
|
||||||
else if (!strcmp(key, "inputName")) {
|
else if (!strcmp(key, "inputName")) {
|
||||||
const char * name = luaL_checkstring(L, -1);
|
const char * name = luaL_checkstring(L, -1);
|
||||||
str2zchar(g_model.inputNames[chn], name, LEN_INPUT_NAME);
|
strncpy(g_model.inputNames[chn], name, LEN_INPUT_NAME);
|
||||||
}
|
}
|
||||||
else if (!strcmp(key, "source")) {
|
else if (!strcmp(key, "source")) {
|
||||||
expo->srcRaw = luaL_checkinteger(L, -1);
|
expo->srcRaw = luaL_checkinteger(L, -1);
|
||||||
@@ -773,7 +773,7 @@ static int luaModelGetMix(lua_State *L)
|
|||||||
if (idx < count) {
|
if (idx < count) {
|
||||||
MixData * mix = mixAddress(first+idx);
|
MixData * mix = mixAddress(first+idx);
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_pushtablestring(L, "name", mix->name);
|
lua_pushtablenstring(L, "name", mix->name);
|
||||||
lua_pushtableinteger(L, "source", mix->srcRaw);
|
lua_pushtableinteger(L, "source", mix->srcRaw);
|
||||||
lua_pushtableinteger(L, "weight", mix->weight);
|
lua_pushtableinteger(L, "weight", mix->weight);
|
||||||
lua_pushtableinteger(L, "offset", mix->offset);
|
lua_pushtableinteger(L, "offset", mix->offset);
|
||||||
@@ -827,7 +827,7 @@ static int luaModelInsertMix(lua_State *L)
|
|||||||
const char * key = luaL_checkstring(L, -2);
|
const char * key = luaL_checkstring(L, -2);
|
||||||
if (!strcmp(key, "name")) {
|
if (!strcmp(key, "name")) {
|
||||||
const char * name = luaL_checkstring(L, -1);
|
const char * name = luaL_checkstring(L, -1);
|
||||||
str2zchar(mix->name, name, sizeof(mix->name));
|
strncpy(mix->name, name, sizeof(mix->name));
|
||||||
}
|
}
|
||||||
else if (!strcmp(key, "source")) {
|
else if (!strcmp(key, "source")) {
|
||||||
mix->srcRaw = luaL_checkinteger(L, -1);
|
mix->srcRaw = luaL_checkinteger(L, -1);
|
||||||
@@ -1043,7 +1043,7 @@ static int luaModelGetCurve(lua_State *L)
|
|||||||
if (idx < MAX_CURVES) {
|
if (idx < MAX_CURVES) {
|
||||||
CurveHeader & CurveHeader = g_model.curves[idx];
|
CurveHeader & CurveHeader = g_model.curves[idx];
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_pushtablestring(L, "name", CurveHeader.name);
|
lua_pushtablenstring(L, "name", CurveHeader.name);
|
||||||
lua_pushtableinteger(L, "type", CurveHeader.type);
|
lua_pushtableinteger(L, "type", CurveHeader.type);
|
||||||
lua_pushtableboolean(L, "smooth", CurveHeader.smooth);
|
lua_pushtableboolean(L, "smooth", CurveHeader.smooth);
|
||||||
lua_pushtableinteger(L, "points", CurveHeader.points + 5);
|
lua_pushtableinteger(L, "points", CurveHeader.points + 5);
|
||||||
@@ -1144,7 +1144,7 @@ static int luaModelSetCurve(lua_State *L)
|
|||||||
const char *key = luaL_checkstring(L, -2);
|
const char *key = luaL_checkstring(L, -2);
|
||||||
if (!strcmp(key, "name")) {
|
if (!strcmp(key, "name")) {
|
||||||
const char *name = luaL_checkstring(L, -1);
|
const char *name = luaL_checkstring(L, -1);
|
||||||
str2zchar(newCurveHeader.name, name, sizeof(newCurveHeader.name));
|
strncpy(newCurveHeader.name, name, sizeof(newCurveHeader.name));
|
||||||
}
|
}
|
||||||
else if (!strcmp(key, "type")) {
|
else if (!strcmp(key, "type")) {
|
||||||
newCurveHeader.type = luaL_checkinteger(L, -1);
|
newCurveHeader.type = luaL_checkinteger(L, -1);
|
||||||
@@ -1301,7 +1301,7 @@ static int luaModelGetCustomFunction(lua_State *L)
|
|||||||
lua_pushtableinteger(L, "switch", CFN_SWITCH(cfn));
|
lua_pushtableinteger(L, "switch", CFN_SWITCH(cfn));
|
||||||
lua_pushtableinteger(L, "func", CFN_FUNC(cfn));
|
lua_pushtableinteger(L, "func", CFN_FUNC(cfn));
|
||||||
if (CFN_FUNC(cfn) == FUNC_PLAY_TRACK || CFN_FUNC(cfn) == FUNC_BACKGND_MUSIC || CFN_FUNC(cfn) == FUNC_PLAY_SCRIPT) {
|
if (CFN_FUNC(cfn) == FUNC_PLAY_TRACK || CFN_FUNC(cfn) == FUNC_BACKGND_MUSIC || CFN_FUNC(cfn) == FUNC_PLAY_SCRIPT) {
|
||||||
lua_pushtablestring(L, "name", cfn->play.name);
|
lua_pushtablenstring(L, "name", cfn->play.name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lua_pushtableinteger(L, "value", cfn->all.val);
|
lua_pushtableinteger(L, "value", cfn->all.val);
|
||||||
@@ -1398,7 +1398,7 @@ static int luaModelGetOutput(lua_State *L)
|
|||||||
if (idx < MAX_OUTPUT_CHANNELS) {
|
if (idx < MAX_OUTPUT_CHANNELS) {
|
||||||
LimitData * limit = limitAddress(idx);
|
LimitData * limit = limitAddress(idx);
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_pushtablestring(L, "name", limit->name);
|
lua_pushtablenstring(L, "name", limit->name);
|
||||||
lua_pushtableinteger(L, "min", limit->min-1000);
|
lua_pushtableinteger(L, "min", limit->min-1000);
|
||||||
lua_pushtableinteger(L, "max", limit->max+1000);
|
lua_pushtableinteger(L, "max", limit->max+1000);
|
||||||
lua_pushtableinteger(L, "offset", limit->offset);
|
lua_pushtableinteger(L, "offset", limit->offset);
|
||||||
@@ -1440,7 +1440,7 @@ static int luaModelSetOutput(lua_State *L)
|
|||||||
const char * key = luaL_checkstring(L, -2);
|
const char * key = luaL_checkstring(L, -2);
|
||||||
if (!strcmp(key, "name")) {
|
if (!strcmp(key, "name")) {
|
||||||
const char * name = luaL_checkstring(L, -1);
|
const char * name = luaL_checkstring(L, -1);
|
||||||
str2zchar(limit->name, name, sizeof(limit->name));
|
strncpy(limit->name, name, sizeof(limit->name));
|
||||||
}
|
}
|
||||||
else if (!strcmp(key, "min")) {
|
else if (!strcmp(key, "min")) {
|
||||||
limit->min = luaL_checkinteger(L, -1)+1000;
|
limit->min = luaL_checkinteger(L, -1)+1000;
|
||||||
@@ -1558,7 +1558,7 @@ static int luaModelGetSensor(lua_State *L)
|
|||||||
TelemetrySensor & sensor = g_model.telemetrySensors[idx];
|
TelemetrySensor & sensor = g_model.telemetrySensors[idx];
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_pushtableinteger(L, "type", sensor.type);
|
lua_pushtableinteger(L, "type", sensor.type);
|
||||||
lua_pushtablestring(L, "name", sensor.label);
|
lua_pushtablenstring(L, "name", sensor.label);
|
||||||
lua_pushtableinteger(L, "unit", sensor.unit);
|
lua_pushtableinteger(L, "unit", sensor.unit);
|
||||||
lua_pushtableinteger(L, "prec", sensor.prec);
|
lua_pushtableinteger(L, "prec", sensor.prec);
|
||||||
if (sensor.type == TELEM_TYPE_CUSTOM) {
|
if (sensor.type == TELEM_TYPE_CUSTOM) {
|
||||||
|
|||||||
@@ -62,7 +62,20 @@ void luaInitThemesAndWidgets();
|
|||||||
#define lua_pushtableboolean(L, k, v) (lua_pushstring(L, (k)), lua_pushboolean(L, (v)), lua_settable(L, -3))
|
#define lua_pushtableboolean(L, k, v) (lua_pushstring(L, (k)), lua_pushboolean(L, (v)), lua_settable(L, -3))
|
||||||
#define lua_pushtableinteger(L, k, v) (lua_pushstring(L, (k)), lua_pushinteger(L, (v)), lua_settable(L, -3))
|
#define lua_pushtableinteger(L, k, v) (lua_pushstring(L, (k)), lua_pushinteger(L, (v)), lua_settable(L, -3))
|
||||||
#define lua_pushtablenumber(L, k, v) (lua_pushstring(L, (k)), lua_pushnumber(L, (v)), lua_settable(L, -3))
|
#define lua_pushtablenumber(L, k, v) (lua_pushstring(L, (k)), lua_pushnumber(L, (v)), lua_settable(L, -3))
|
||||||
|
|
||||||
|
// size based string (possibly no null-termination)
|
||||||
|
#define __lua_strncpy(s) \
|
||||||
|
char tmp[sizeof(s) + 1]; \
|
||||||
|
strncpy(tmp, (s), sizeof(tmp) - 1); \
|
||||||
|
tmp[sizeof(s)] = '\0';
|
||||||
|
|
||||||
|
// size based string (possibly no null-termination)
|
||||||
|
#define lua_pushnstring(L, s) { __lua_strncpy(s); lua_pushstring(L, tmp); }
|
||||||
|
#define lua_pushtablenstring(L, k, v) { __lua_strncpy(v); lua_pushstring(L, (k)); lua_pushstring(L, tmp); lua_settable(L, -3); }
|
||||||
|
|
||||||
|
// null-terminated string
|
||||||
#define lua_pushtablestring(L, k, v) (lua_pushstring(L, (k)), lua_pushstring(L, (v)), lua_settable(L, -3))
|
#define lua_pushtablestring(L, k, v) (lua_pushstring(L, (k)), lua_pushstring(L, (v)), lua_settable(L, -3))
|
||||||
|
|
||||||
#define lua_registerlib(L, name, tab) (luaL_newmetatable(L, name), luaL_setfuncs(L, tab, 0), lua_setglobal(L, name))
|
#define lua_registerlib(L, name, tab) (luaL_newmetatable(L, name), luaL_setfuncs(L, tab, 0), lua_setglobal(L, name))
|
||||||
|
|
||||||
#define RUN_MIX_SCRIPT (1 << 0)
|
#define RUN_MIX_SCRIPT (1 << 0)
|
||||||
|
|||||||
@@ -621,10 +621,10 @@ void TelemetrySensor::init(const char * label, uint8_t unit, uint8_t prec)
|
|||||||
void TelemetrySensor::init(uint16_t id)
|
void TelemetrySensor::init(uint16_t id)
|
||||||
{
|
{
|
||||||
char label[TELEM_LABEL_LEN]; // 4
|
char label[TELEM_LABEL_LEN]; // 4
|
||||||
label[0] = hex2char((id & 0x0f00) >> 8);
|
label[0] = hex2char((id & 0xf000) >> 12);
|
||||||
label[1] = hex2char((id & 0x00f0) >> 4);
|
label[1] = hex2char((id & 0x0f00) >> 8);
|
||||||
label[2] = hex2char((id & 0x000f) >> 0);
|
label[2] = hex2char((id & 0x00f0) >> 4);
|
||||||
label[3] = '\0';
|
label[3] = hex2char((id & 0x000f) >> 0);
|
||||||
init(label);
|
init(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,18 +50,18 @@ TEST(Conversions, ConversionX9DPFrom23)
|
|||||||
EXPECT_EQ(FUNC_LOGS, g_eeGeneral.customFn[0].func);
|
EXPECT_EQ(FUNC_LOGS, g_eeGeneral.customFn[0].func);
|
||||||
EXPECT_EQ(20, g_eeGeneral.customFn[0].all.val);
|
EXPECT_EQ(20, g_eeGeneral.customFn[0].all.val);
|
||||||
|
|
||||||
EXPECT_STREQ("Tes", g_eeGeneral.switchNames[0]); // ZSTREQ
|
EXPECT_STRNEQ("Tes", g_eeGeneral.switchNames[0]); // ZSTREQ
|
||||||
EXPECT_EQ(SWITCH_3POS, SWITCH_CONFIG(0));
|
EXPECT_EQ(SWITCH_3POS, SWITCH_CONFIG(0));
|
||||||
|
|
||||||
EXPECT_STREQ("Test", g_model.header.name); // ZSTREQ
|
EXPECT_STRNEQ("Test", g_model.header.name); // ZSTREQ
|
||||||
EXPECT_EQ(TMRMODE_START, g_model.timers[0].mode); // new!
|
EXPECT_EQ(TMRMODE_START, g_model.timers[0].mode); // new!
|
||||||
EXPECT_EQ(SWSRC_SA0, g_model.timers[0].swtch); // new!
|
EXPECT_EQ(SWSRC_SA0, g_model.timers[0].swtch); // new!
|
||||||
EXPECT_EQ(80, g_model.mixData[0].weight);
|
EXPECT_EQ(80, g_model.mixData[0].weight);
|
||||||
EXPECT_EQ(-100, g_model.limitData[0].max); // 90.0
|
EXPECT_EQ(-100, g_model.limitData[0].max); // 90.0
|
||||||
EXPECT_EQ(80, g_model.expoData[0].weight);
|
EXPECT_EQ(80, g_model.expoData[0].weight);
|
||||||
EXPECT_EQ(10, g_model.flightModeData[0].gvars[0]);
|
EXPECT_EQ(10, g_model.flightModeData[0].gvars[0]);
|
||||||
EXPECT_STREQ("Tes", g_model.gvars[0].name); // ZSTREQ
|
EXPECT_STRNEQ("Tes", g_model.gvars[0].name); // ZSTREQ
|
||||||
EXPECT_STREQ("Test", g_model.flightModeData[0].name); // ZSTREQ
|
EXPECT_STRNEQ("Test", g_model.flightModeData[0].name); // ZSTREQ
|
||||||
|
|
||||||
#if defined(INTERNAL_MODULE_PXX2)
|
#if defined(INTERNAL_MODULE_PXX2)
|
||||||
EXPECT_EQ(MODULE_TYPE_ISRM_PXX2, g_model.moduleData[INTERNAL_MODULE].type);
|
EXPECT_EQ(MODULE_TYPE_ISRM_PXX2, g_model.moduleData[INTERNAL_MODULE].type);
|
||||||
@@ -73,13 +73,13 @@ TEST(Conversions, ConversionX9DPFrom23)
|
|||||||
EXPECT_EQ(MODULE_TYPE_R9M_PXX1, g_model.moduleData[EXTERNAL_MODULE].type);
|
EXPECT_EQ(MODULE_TYPE_R9M_PXX1, g_model.moduleData[EXTERNAL_MODULE].type);
|
||||||
EXPECT_EQ(MODULE_SUBTYPE_R9M_FCC, g_model.moduleData[EXTERNAL_MODULE].subType);
|
EXPECT_EQ(MODULE_SUBTYPE_R9M_FCC, g_model.moduleData[EXTERNAL_MODULE].subType);
|
||||||
|
|
||||||
EXPECT_STREQ("Rud", g_model.inputNames[0]); // ZSTREQ
|
EXPECT_STRNEQ("Rud", g_model.inputNames[0]); // ZSTREQ
|
||||||
EXPECT_STREQ("Tes", g_model.telemetrySensors[0].label); // ZSTREQ
|
EXPECT_STRNEQ("Tes", g_model.telemetrySensors[0].label); // ZSTREQ
|
||||||
EXPECT_EQ(10, g_model.telemetrySensors[0].id);
|
EXPECT_EQ(10, g_model.telemetrySensors[0].id);
|
||||||
EXPECT_EQ(10, g_model.telemetrySensors[0].frskyInstance.physID);
|
EXPECT_EQ(10, g_model.telemetrySensors[0].frskyInstance.physID);
|
||||||
EXPECT_EQ(MIXSRC_FIRST_TELEM, g_model.logicalSw[0].v1);
|
EXPECT_EQ(MIXSRC_FIRST_TELEM, g_model.logicalSw[0].v1);
|
||||||
|
|
||||||
EXPECT_STREQ("abc.wav", g_model.customFn[1].play.name);
|
EXPECT_STRNEQ("abc.wav", g_model.customFn[1].play.name);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -47,12 +47,12 @@ TEST(Lua, testSetModelInfo)
|
|||||||
luaExecStr("info.name = 'modelA'");
|
luaExecStr("info.name = 'modelA'");
|
||||||
luaExecStr("model.setInfo(info)");
|
luaExecStr("model.setInfo(info)");
|
||||||
// luaExecStr("print('model name: '..info.name..' id: '..info.id)");
|
// luaExecStr("print('model name: '..info.name..' id: '..info.id)");
|
||||||
EXPECT_ZSTREQ("modelA", g_model.header.name);
|
EXPECT_STRNEQ("modelA", g_model.header.name);
|
||||||
|
|
||||||
luaExecStr("info.name = 'Model 1'");
|
luaExecStr("info.name = 'Model 1'");
|
||||||
luaExecStr("model.setInfo(info)");
|
luaExecStr("model.setInfo(info)");
|
||||||
// luaExecStr("print('model name: '..info.name..' id: '..info.id)");
|
// luaExecStr("print('model name: '..info.name..' id: '..info.id)");
|
||||||
EXPECT_ZSTREQ("Model 1", g_model.header.name);
|
EXPECT_STRNEQ("Model 1", g_model.header.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Lua, testPanicProtection)
|
TEST(Lua, testPanicProtection)
|
||||||
@@ -112,7 +112,7 @@ TEST(Lua, testModelInputs)
|
|||||||
// add one line on Input4
|
// add one line on Input4
|
||||||
luaExecStr("model.insertInput(3, 0, {name='test1', source=MIXSRC_Thr, weight=56, offset=3, switch=2})");
|
luaExecStr("model.insertInput(3, 0, {name='test1', source=MIXSRC_Thr, weight=56, offset=3, switch=2})");
|
||||||
EXPECT_EQ(3, (int)g_model.expoData[0].chn);
|
EXPECT_EQ(3, (int)g_model.expoData[0].chn);
|
||||||
EXPECT_ZSTREQ("test1", g_model.expoData[0].name);
|
EXPECT_STRNEQ("test1", g_model.expoData[0].name);
|
||||||
EXPECT_EQ(MIXSRC_Thr, g_model.expoData[0].srcRaw);
|
EXPECT_EQ(MIXSRC_Thr, g_model.expoData[0].srcRaw);
|
||||||
EXPECT_EQ(56, g_model.expoData[0].weight);
|
EXPECT_EQ(56, g_model.expoData[0].weight);
|
||||||
EXPECT_EQ(3, g_model.expoData[0].offset);
|
EXPECT_EQ(3, g_model.expoData[0].offset);
|
||||||
@@ -121,14 +121,14 @@ TEST(Lua, testModelInputs)
|
|||||||
// add another one before existing line on Input4
|
// add another one before existing line on Input4
|
||||||
luaExecStr("model.insertInput(3, 0, {name='test2', source=MIXSRC_Rud, weight=-56})");
|
luaExecStr("model.insertInput(3, 0, {name='test2', source=MIXSRC_Rud, weight=-56})");
|
||||||
EXPECT_EQ(3, (int)g_model.expoData[0].chn);
|
EXPECT_EQ(3, (int)g_model.expoData[0].chn);
|
||||||
EXPECT_ZSTREQ("test2", g_model.expoData[0].name);
|
EXPECT_STRNEQ("test2", g_model.expoData[0].name);
|
||||||
EXPECT_EQ(MIXSRC_Rud, g_model.expoData[0].srcRaw);
|
EXPECT_EQ(MIXSRC_Rud, g_model.expoData[0].srcRaw);
|
||||||
EXPECT_EQ(-56, g_model.expoData[0].weight);
|
EXPECT_EQ(-56, g_model.expoData[0].weight);
|
||||||
EXPECT_EQ(0, g_model.expoData[0].offset);
|
EXPECT_EQ(0, g_model.expoData[0].offset);
|
||||||
EXPECT_EQ(0, g_model.expoData[0].swtch);
|
EXPECT_EQ(0, g_model.expoData[0].swtch);
|
||||||
|
|
||||||
EXPECT_EQ(3, (int)g_model.expoData[1].chn);
|
EXPECT_EQ(3, (int)g_model.expoData[1].chn);
|
||||||
EXPECT_ZSTREQ("test1", g_model.expoData[1].name);
|
EXPECT_STRNEQ("test1", g_model.expoData[1].name);
|
||||||
EXPECT_EQ(MIXSRC_Thr, g_model.expoData[1].srcRaw);
|
EXPECT_EQ(MIXSRC_Thr, g_model.expoData[1].srcRaw);
|
||||||
EXPECT_EQ(56, g_model.expoData[1].weight);
|
EXPECT_EQ(56, g_model.expoData[1].weight);
|
||||||
EXPECT_EQ(3, g_model.expoData[1].offset);
|
EXPECT_EQ(3, g_model.expoData[1].offset);
|
||||||
@@ -137,21 +137,21 @@ TEST(Lua, testModelInputs)
|
|||||||
// add another line after existing lines on Input4
|
// add another line after existing lines on Input4
|
||||||
luaExecStr("model.insertInput(3, model.getInputsCount(3), {name='test3', source=MIXSRC_Ail, weight=100})");
|
luaExecStr("model.insertInput(3, model.getInputsCount(3), {name='test3', source=MIXSRC_Ail, weight=100})");
|
||||||
EXPECT_EQ(3, (int)g_model.expoData[0].chn);
|
EXPECT_EQ(3, (int)g_model.expoData[0].chn);
|
||||||
EXPECT_ZSTREQ("test2", g_model.expoData[0].name);
|
EXPECT_STRNEQ("test2", g_model.expoData[0].name);
|
||||||
EXPECT_EQ(MIXSRC_Rud, g_model.expoData[0].srcRaw);
|
EXPECT_EQ(MIXSRC_Rud, g_model.expoData[0].srcRaw);
|
||||||
EXPECT_EQ(-56, g_model.expoData[0].weight);
|
EXPECT_EQ(-56, g_model.expoData[0].weight);
|
||||||
EXPECT_EQ(0, g_model.expoData[0].offset);
|
EXPECT_EQ(0, g_model.expoData[0].offset);
|
||||||
EXPECT_EQ(0, g_model.expoData[0].swtch);
|
EXPECT_EQ(0, g_model.expoData[0].swtch);
|
||||||
|
|
||||||
EXPECT_EQ(3, (int)g_model.expoData[1].chn);
|
EXPECT_EQ(3, (int)g_model.expoData[1].chn);
|
||||||
EXPECT_ZSTREQ("test1", g_model.expoData[1].name);
|
EXPECT_STRNEQ("test1", g_model.expoData[1].name);
|
||||||
EXPECT_EQ(MIXSRC_Thr, g_model.expoData[1].srcRaw);
|
EXPECT_EQ(MIXSRC_Thr, g_model.expoData[1].srcRaw);
|
||||||
EXPECT_EQ(56, g_model.expoData[1].weight);
|
EXPECT_EQ(56, g_model.expoData[1].weight);
|
||||||
EXPECT_EQ(3, g_model.expoData[1].offset);
|
EXPECT_EQ(3, g_model.expoData[1].offset);
|
||||||
EXPECT_EQ(2, g_model.expoData[1].swtch);
|
EXPECT_EQ(2, g_model.expoData[1].swtch);
|
||||||
|
|
||||||
EXPECT_EQ(3, (int)g_model.expoData[2].chn);
|
EXPECT_EQ(3, (int)g_model.expoData[2].chn);
|
||||||
EXPECT_ZSTREQ("test3", g_model.expoData[2].name);
|
EXPECT_STRNEQ("test3", g_model.expoData[2].name);
|
||||||
EXPECT_EQ(MIXSRC_Ail, g_model.expoData[2].srcRaw);
|
EXPECT_EQ(MIXSRC_Ail, g_model.expoData[2].srcRaw);
|
||||||
EXPECT_EQ(100, g_model.expoData[2].weight);
|
EXPECT_EQ(100, g_model.expoData[2].weight);
|
||||||
EXPECT_EQ(0, g_model.expoData[2].offset);
|
EXPECT_EQ(0, g_model.expoData[2].offset);
|
||||||
|
|||||||
Reference in New Issue
Block a user