mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 00:35:18 +03:00
All references to "custom switches" renamed to "logical switches"
This commit is contained in:
parent
8c21462f74
commit
34e1a0ce86
11 changed files with 115 additions and 115 deletions
|
@ -222,7 +222,7 @@ PACK(typedef struct {
|
||||||
int16_t curves[16];
|
int16_t curves[16];
|
||||||
int8_t points[NUM_POINTS];
|
int8_t points[NUM_POINTS];
|
||||||
|
|
||||||
LogicalSwitchData_v215 customSw[NUM_LOGICAL_SWITCH];
|
LogicalSwitchData_v215 logicalSw[NUM_LOGICAL_SWITCH];
|
||||||
CustomFnData_v215 funcSw[32];
|
CustomFnData_v215 funcSw[32];
|
||||||
SwashRingData swashR;
|
SwashRingData swashR;
|
||||||
PhaseData_v215 phaseData[MAX_FLIGHT_MODES];
|
PhaseData_v215 phaseData[MAX_FLIGHT_MODES];
|
||||||
|
@ -658,16 +658,16 @@ void ConvertModel_215_to_216(ModelData &model)
|
||||||
g_model.points[i] = oldModel.points[i];
|
g_model.points[i] = oldModel.points[i];
|
||||||
}
|
}
|
||||||
for (uint8_t i=0; i<32; i++) {
|
for (uint8_t i=0; i<32; i++) {
|
||||||
LogicalSwitchData & sw = g_model.customSw[i];
|
LogicalSwitchData & sw = g_model.logicalSw[i];
|
||||||
sw.func = oldModel.customSw[i].func;
|
sw.func = oldModel.logicalSw[i].func;
|
||||||
if (sw.func >= LS_FUNC_VEQUAL) sw.func += 1;
|
if (sw.func >= LS_FUNC_VEQUAL) sw.func += 1;
|
||||||
if (sw.func >= LS_FUNC_RANGE) sw.func += 1;
|
if (sw.func >= LS_FUNC_RANGE) sw.func += 1;
|
||||||
if (sw.func >= LS_FUNC_STAY) sw.func += 1;
|
if (sw.func >= LS_FUNC_STAY) sw.func += 1;
|
||||||
sw.v1 = oldModel.customSw[i].v1;
|
sw.v1 = oldModel.logicalSw[i].v1;
|
||||||
sw.v2 = oldModel.customSw[i].v2;
|
sw.v2 = oldModel.logicalSw[i].v2;
|
||||||
sw.delay = oldModel.customSw[i].delay * 5;
|
sw.delay = oldModel.logicalSw[i].delay * 5;
|
||||||
sw.duration = oldModel.customSw[i].duration * 5;
|
sw.duration = oldModel.logicalSw[i].duration * 5;
|
||||||
sw.andsw = ConvertSwitch_215_to_216(oldModel.customSw[i].andsw);
|
sw.andsw = ConvertSwitch_215_to_216(oldModel.logicalSw[i].andsw);
|
||||||
uint8_t cstate = cswFamily(sw.func);
|
uint8_t cstate = cswFamily(sw.func);
|
||||||
if (cstate == LS_FAMILY_BOOL) {
|
if (cstate == LS_FAMILY_BOOL) {
|
||||||
sw.v1 = ConvertSwitch_215_to_216(sw.v1);
|
sw.v1 = ConvertSwitch_215_to_216(sw.v1);
|
||||||
|
|
|
@ -307,8 +307,8 @@ TEST(getSwitch, circularCSW)
|
||||||
{
|
{
|
||||||
MODEL_RESET();
|
MODEL_RESET();
|
||||||
MIXER_RESET();
|
MIXER_RESET();
|
||||||
g_model.customSw[0] = { SWSRC_SW1, SWSRC_SW1, LS_FUNC_OR };
|
g_model.logicalSw[0] = { SWSRC_SW1, SWSRC_SW1, LS_FUNC_OR };
|
||||||
g_model.customSw[1] = { SWSRC_SW1, SWSRC_SW1, LS_FUNC_AND };
|
g_model.logicalSw[1] = { SWSRC_SW1, SWSRC_SW1, LS_FUNC_AND };
|
||||||
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
|
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
|
||||||
EXPECT_EQ(getSwitch(-SWSRC_SW1), true);
|
EXPECT_EQ(getSwitch(-SWSRC_SW1), true);
|
||||||
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
|
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
|
||||||
|
@ -327,8 +327,8 @@ TEST(getSwitch, recursiveSW)
|
||||||
MODEL_RESET();
|
MODEL_RESET();
|
||||||
MIXER_RESET();
|
MIXER_RESET();
|
||||||
|
|
||||||
g_model.customSw[0] = { SWSRC_RUD, -SWSRC_SW2, LS_FUNC_OR };
|
g_model.logicalSw[0] = { SWSRC_RUD, -SWSRC_SW2, LS_FUNC_OR };
|
||||||
g_model.customSw[1] = { SWSRC_ELE, -SWSRC_SW1, LS_FUNC_OR };
|
g_model.logicalSw[1] = { SWSRC_ELE, -SWSRC_SW1, LS_FUNC_OR };
|
||||||
|
|
||||||
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
|
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
|
||||||
EXPECT_EQ(getSwitch(SWSRC_SW2), true);
|
EXPECT_EQ(getSwitch(SWSRC_SW2), true);
|
||||||
|
|
|
@ -4269,7 +4269,7 @@ void menuModelLogicalSwitchOne(uint8_t event)
|
||||||
{
|
{
|
||||||
TITLE(STR_MENULOGICALSWITCH);
|
TITLE(STR_MENULOGICALSWITCH);
|
||||||
|
|
||||||
LogicalSwitchData * cs = cswAddress(s_currIdx);
|
LogicalSwitchData * cs = lswAddress(s_currIdx);
|
||||||
uint8_t sw = SWSRC_SW1+s_currIdx;
|
uint8_t sw = SWSRC_SW1+s_currIdx;
|
||||||
putsSwitches(14*FW, 0, sw, (getSwitch(sw) ? BOLD : 0));
|
putsSwitches(14*FW, 0, sw, (getSwitch(sw) ? BOLD : 0));
|
||||||
|
|
||||||
|
@ -4343,12 +4343,12 @@ void menuModelLogicalSwitchOne(uint8_t event)
|
||||||
}
|
}
|
||||||
else if (cstate == LS_FAMILY_STAY) {
|
else if (cstate == LS_FAMILY_STAY) {
|
||||||
lcd_putc(CSWONE_2ND_COLUMN-4, y, '[');
|
lcd_putc(CSWONE_2ND_COLUMN-4, y, '[');
|
||||||
lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|(m_posHorz==0 ? attr : 0));
|
lcd_outdezAtt(CSWONE_2ND_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1|(m_posHorz==0 ? attr : 0));
|
||||||
lcd_putc(lcdLastPos, y, ':');
|
lcd_putc(lcdLastPos, y, ':');
|
||||||
if (cs->v3 == 0)
|
if (cs->v3 == 0)
|
||||||
lcd_putsAtt(lcdLastPos+3, y, "--", (m_posHorz==1 ? attr : 0));
|
lcd_putsAtt(lcdLastPos+3, y, "--", (m_posHorz==1 ? attr : 0));
|
||||||
else
|
else
|
||||||
lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(m_posHorz==1 ? attr : 0));
|
lcd_outdezAtt(lcdLastPos+3, y, lswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(m_posHorz==1 ? attr : 0));
|
||||||
lcd_putc(lcdLastPos, y, ']');
|
lcd_putc(lcdLastPos, y, ']');
|
||||||
if (s_editMode <= 0) continue;
|
if (s_editMode <= 0) continue;
|
||||||
if (attr && m_posHorz==1) {
|
if (attr && m_posHorz==1) {
|
||||||
|
@ -4365,7 +4365,7 @@ void menuModelLogicalSwitchOne(uint8_t event)
|
||||||
else {
|
else {
|
||||||
#if defined(FRSKY)
|
#if defined(FRSKY)
|
||||||
if (v1_val >= MIXSRC_FIRST_TELEM) {
|
if (v1_val >= MIXSRC_FIRST_TELEM) {
|
||||||
putsTelemetryChannel(CSWONE_2ND_COLUMN, y, v1_val - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), attr|LEFT);
|
putsTelemetryChannel(CSWONE_2ND_COLUMN, y, v1_val - MIXSRC_FIRST_TELEM, convertLswTelemValue(cs), attr|LEFT);
|
||||||
v2_max = maxTelemValue(v1_val - MIXSRC_FIRST_TELEM + 1);
|
v2_max = maxTelemValue(v1_val - MIXSRC_FIRST_TELEM + 1);
|
||||||
v2_min = minTelemValue(v1_val - MIXSRC_FIRST_TELEM + 1);
|
v2_min = minTelemValue(v1_val - MIXSRC_FIRST_TELEM + 1);
|
||||||
INCDEC_SET_FLAG(INCDEC_REP10 | NO_INCDEC_MARKS);
|
INCDEC_SET_FLAG(INCDEC_REP10 | NO_INCDEC_MARKS);
|
||||||
|
@ -4436,7 +4436,7 @@ void menuModelLogicalSwitches(uint8_t event)
|
||||||
for (uint8_t i=0; i<LCD_LINES-1; i++) {
|
for (uint8_t i=0; i<LCD_LINES-1; i++) {
|
||||||
y = 1 + (i+1)*FH;
|
y = 1 + (i+1)*FH;
|
||||||
k = i+s_pgOfs;
|
k = i+s_pgOfs;
|
||||||
LogicalSwitchData * cs = cswAddress(k);
|
LogicalSwitchData * cs = lswAddress(k);
|
||||||
|
|
||||||
// CSW name
|
// CSW name
|
||||||
uint8_t sw = SWSRC_SW1+k;
|
uint8_t sw = SWSRC_SW1+k;
|
||||||
|
@ -4461,12 +4461,12 @@ void menuModelLogicalSwitches(uint8_t event)
|
||||||
else if (cstate == LS_FAMILY_STAY) {
|
else if (cstate == LS_FAMILY_STAY) {
|
||||||
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0);
|
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0);
|
||||||
lcd_putc(CSW_3RD_COLUMN-4, y, '[');
|
lcd_putc(CSW_3RD_COLUMN-4, y, '[');
|
||||||
lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1);
|
lcd_outdezAtt(CSW_3RD_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1);
|
||||||
lcd_putc(lcdLastPos, y, ':');
|
lcd_putc(lcdLastPos, y, ':');
|
||||||
if (cs->v3 == 0)
|
if (cs->v3 == 0)
|
||||||
lcd_puts(lcdLastPos+3, y, "--");
|
lcd_puts(lcdLastPos+3, y, "--");
|
||||||
else
|
else
|
||||||
lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1);
|
lcd_outdezAtt(lcdLastPos+3, y, lswTimerValue(cs->v2+cs->v3), LEFT|PREC1);
|
||||||
lcd_putc(lcdLastPos-1, y, ']');
|
lcd_putc(lcdLastPos-1, y, ']');
|
||||||
}
|
}
|
||||||
else if (cstate == LS_FAMILY_TIMER) {
|
else if (cstate == LS_FAMILY_TIMER) {
|
||||||
|
@ -4477,7 +4477,7 @@ void menuModelLogicalSwitches(uint8_t event)
|
||||||
uint8_t v1 = cs->v1;
|
uint8_t v1 = cs->v1;
|
||||||
putsMixerSource(CSW_2ND_COLUMN, y, v1, 0);
|
putsMixerSource(CSW_2ND_COLUMN, y, v1, 0);
|
||||||
if (v1 >= MIXSRC_FIRST_TELEM) {
|
if (v1 >= MIXSRC_FIRST_TELEM) {
|
||||||
putsTelemetryChannel(CSW_3RD_COLUMN, y, v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), LEFT);
|
putsTelemetryChannel(CSW_3RD_COLUMN, y, v1 - MIXSRC_FIRST_TELEM, convertLswTelemValue(cs), LEFT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, LEFT);
|
lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2, LEFT);
|
||||||
|
@ -4512,7 +4512,7 @@ Clipboard clipboard;
|
||||||
void onLogicalSwitchesMenu(const char *result)
|
void onLogicalSwitchesMenu(const char *result)
|
||||||
{
|
{
|
||||||
int8_t sub = m_posVert-1;
|
int8_t sub = m_posVert-1;
|
||||||
LogicalSwitchData * cs = cswAddress(sub);
|
LogicalSwitchData * cs = lswAddress(sub);
|
||||||
|
|
||||||
if (result == STR_COPY) {
|
if (result == STR_COPY) {
|
||||||
clipboard.type = CLIPBOARD_TYPE_CUSTOM_SWITCH;
|
clipboard.type = CLIPBOARD_TYPE_CUSTOM_SWITCH;
|
||||||
|
@ -4549,7 +4549,7 @@ void menuModelLogicalSwitches(uint8_t event)
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
if (sub>=0 && horz<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) {
|
if (sub>=0 && horz<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) {
|
||||||
killEvents(event);
|
killEvents(event);
|
||||||
LogicalSwitchData * cs = cswAddress(sub);
|
LogicalSwitchData * cs = lswAddress(sub);
|
||||||
if (cs->func)
|
if (cs->func)
|
||||||
MENU_ADD_ITEM(STR_COPY);
|
MENU_ADD_ITEM(STR_COPY);
|
||||||
if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_SWITCH)
|
if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_SWITCH)
|
||||||
|
@ -4566,7 +4566,7 @@ void menuModelLogicalSwitches(uint8_t event)
|
||||||
uint8_t attr = (sub==k ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
uint8_t attr = (sub==k ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
||||||
uint8_t attr1 = (horz==1 ? attr : 0);
|
uint8_t attr1 = (horz==1 ? attr : 0);
|
||||||
uint8_t attr2 = (horz==2 ? attr : 0);
|
uint8_t attr2 = (horz==2 ? attr : 0);
|
||||||
LogicalSwitchData * cs = cswAddress(k);
|
LogicalSwitchData * cs = lswAddress(k);
|
||||||
|
|
||||||
// CSW name
|
// CSW name
|
||||||
uint8_t sw = SWSRC_SW1+k;
|
uint8_t sw = SWSRC_SW1+k;
|
||||||
|
@ -4597,12 +4597,12 @@ void menuModelLogicalSwitches(uint8_t event)
|
||||||
else if (cstate == LS_FAMILY_STAY) {
|
else if (cstate == LS_FAMILY_STAY) {
|
||||||
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1);
|
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1);
|
||||||
lcd_putc(CSW_3RD_COLUMN-4, y, '[');
|
lcd_putc(CSW_3RD_COLUMN-4, y, '[');
|
||||||
lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|attr2);
|
lcd_outdezAtt(CSW_3RD_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1|attr2);
|
||||||
lcd_putc(lcdLastPos, y, ':');
|
lcd_putc(lcdLastPos, y, ':');
|
||||||
if (cs->v3 == 0)
|
if (cs->v3 == 0)
|
||||||
lcd_putsAtt(lcdLastPos+3, y, "--", (horz==LS_FIELD_V3 ? attr : 0));
|
lcd_putsAtt(lcdLastPos+3, y, "--", (horz==LS_FIELD_V3 ? attr : 0));
|
||||||
else
|
else
|
||||||
lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(horz==LS_FIELD_V3 ? attr : 0));
|
lcd_outdezAtt(lcdLastPos+3, y, lswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(horz==LS_FIELD_V3 ? attr : 0));
|
||||||
lcd_putc(lcdLastPos, y, ']');
|
lcd_putc(lcdLastPos, y, ']');
|
||||||
v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1;
|
v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1;
|
||||||
v2_min=-129; v2_max = 122;
|
v2_min=-129; v2_max = 122;
|
||||||
|
@ -4627,8 +4627,8 @@ void menuModelLogicalSwitches(uint8_t event)
|
||||||
INCDEC_ENABLE_CHECK(isSourceAvailable);
|
INCDEC_ENABLE_CHECK(isSourceAvailable);
|
||||||
}
|
}
|
||||||
else if (cstate == LS_FAMILY_TIMER) {
|
else if (cstate == LS_FAMILY_TIMER) {
|
||||||
lcd_outdezAtt(CSW_2ND_COLUMN, y, cswTimerValue(cs->v1), LEFT|PREC1|attr1);
|
lcd_outdezAtt(CSW_2ND_COLUMN, y, lswTimerValue(cs->v1), LEFT|PREC1|attr1);
|
||||||
lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|attr2);
|
lcd_outdezAtt(CSW_3RD_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1|attr2);
|
||||||
v1_min = v2_min = -128;
|
v1_min = v2_min = -128;
|
||||||
v1_max = v2_max = 122;
|
v1_max = v2_max = 122;
|
||||||
INCDEC_SET_FLAG(0);
|
INCDEC_SET_FLAG(0);
|
||||||
|
@ -4649,7 +4649,7 @@ void menuModelLogicalSwitches(uint8_t event)
|
||||||
}
|
}
|
||||||
#if defined(FRSKY)
|
#if defined(FRSKY)
|
||||||
if (v1_val >= MIXSRC_FIRST_TELEM) {
|
if (v1_val >= MIXSRC_FIRST_TELEM) {
|
||||||
putsTelemetryChannel(CSW_3RD_COLUMN, y, v1_val - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), LEFT|attr2);
|
putsTelemetryChannel(CSW_3RD_COLUMN, y, v1_val - MIXSRC_FIRST_TELEM, convertLswTelemValue(cs), LEFT|attr2);
|
||||||
v2_max = maxTelemValue(v1_val - MIXSRC_FIRST_TELEM + 1);
|
v2_max = maxTelemValue(v1_val - MIXSRC_FIRST_TELEM + 1);
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
v2_min = minTelemValue(v1_val - MIXSRC_FIRST_TELEM + 1);
|
v2_min = minTelemValue(v1_val - MIXSRC_FIRST_TELEM + 1);
|
||||||
|
@ -4680,7 +4680,7 @@ void menuModelLogicalSwitches(uint8_t event)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (v1_val >= MIXSRC_FIRST_TELEM) {
|
if (v1_val >= MIXSRC_FIRST_TELEM) {
|
||||||
putsTelemetryChannel(CSW_3RD_COLUMN, y, v1_val - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), LEFT|attr2);
|
putsTelemetryChannel(CSW_3RD_COLUMN, y, v1_val - MIXSRC_FIRST_TELEM, convertLswTelemValue(cs), LEFT|attr2);
|
||||||
v2_min = -128; v2_max = 127;
|
v2_min = -128; v2_max = 127;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1421,7 +1421,7 @@ bool isSourceAvailable(int source)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source>=MIXSRC_SW1 && source<=MIXSRC_LAST_LOGICAL_SWITCH) {
|
if (source>=MIXSRC_SW1 && source<=MIXSRC_LAST_LOGICAL_SWITCH) {
|
||||||
LogicalSwitchData * cs = cswAddress(source-MIXSRC_SW1);
|
LogicalSwitchData * cs = lswAddress(source-MIXSRC_SW1);
|
||||||
return (cs->func != LS_FUNC_NONE);
|
return (cs->func != LS_FUNC_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1526,7 +1526,7 @@ bool isSwitchAvailable(int swtch)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (swtch >= SWSRC_FIRST_LOGICAL_SWITCH && swtch <= SWSRC_LAST_LOGICAL_SWITCH) {
|
if (swtch >= SWSRC_FIRST_LOGICAL_SWITCH && swtch <= SWSRC_LAST_LOGICAL_SWITCH) {
|
||||||
LogicalSwitchData * cs = cswAddress(swtch-SWSRC_FIRST_LOGICAL_SWITCH);
|
LogicalSwitchData * cs = lswAddress(swtch-SWSRC_FIRST_LOGICAL_SWITCH);
|
||||||
return (cs->func != LS_FUNC_NONE);
|
return (cs->func != LS_FUNC_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -715,7 +715,7 @@ void menuMainView(uint8_t event)
|
||||||
div_t qr = div(sw, 10);
|
div_t qr = div(sw, 10);
|
||||||
uint8_t y = 13 + 11 * qr.quot;
|
uint8_t y = 13 + 11 * qr.quot;
|
||||||
uint8_t x = TRIM_RH_X - TRIM_LEN + qr.rem*5 + (qr.rem >= 5 ? 3 : 0);
|
uint8_t x = TRIM_RH_X - TRIM_LEN + qr.rem*5 + (qr.rem >= 5 ? 3 : 0);
|
||||||
LogicalSwitchData * cs = cswAddress(sw);
|
LogicalSwitchData * cs = lswAddress(sw);
|
||||||
if (cs->func == LS_FUNC_NONE) {
|
if (cs->func == LS_FUNC_NONE) {
|
||||||
lcd_hline(x, y+6, 4);
|
lcd_hline(x, y+6, 4);
|
||||||
lcd_hline(x, y+7, 4);
|
lcd_hline(x, y+7, 4);
|
||||||
|
|
|
@ -570,7 +570,7 @@ static int luaModelGetLogicalSwitch(lua_State *L)
|
||||||
{
|
{
|
||||||
int idx = luaL_checkunsigned(L, 1);
|
int idx = luaL_checkunsigned(L, 1);
|
||||||
if (idx < NUM_LOGICAL_SWITCH) {
|
if (idx < NUM_LOGICAL_SWITCH) {
|
||||||
LogicalSwitchData * sw = cswAddress(idx);
|
LogicalSwitchData * sw = lswAddress(idx);
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_pushtablenumber(L, "function", sw->func);
|
lua_pushtablenumber(L, "function", sw->func);
|
||||||
lua_pushtablenumber(L, "v1", sw->v1);
|
lua_pushtablenumber(L, "v1", sw->v1);
|
||||||
|
@ -590,7 +590,7 @@ static int luaModelSetLogicalSwitch(lua_State *L)
|
||||||
{
|
{
|
||||||
int idx = luaL_checkunsigned(L, 1);
|
int idx = luaL_checkunsigned(L, 1);
|
||||||
if (idx < NUM_LOGICAL_SWITCH) {
|
if (idx < NUM_LOGICAL_SWITCH) {
|
||||||
LogicalSwitchData * sw = cswAddress(idx);
|
LogicalSwitchData * sw = lswAddress(idx);
|
||||||
luaL_checktype(L, -1, LUA_TTABLE);
|
luaL_checktype(L, -1, LUA_TTABLE);
|
||||||
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
|
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
|
||||||
luaL_checktype(L, -2, LUA_TSTRING); // key is string
|
luaL_checktype(L, -2, LUA_TSTRING); // key is string
|
||||||
|
|
|
@ -1694,7 +1694,7 @@ PACK(typedef struct t_ModelData {
|
||||||
CURVDATA curves[MAX_CURVES];
|
CURVDATA curves[MAX_CURVES];
|
||||||
int8_t points[NUM_POINTS];
|
int8_t points[NUM_POINTS];
|
||||||
|
|
||||||
LogicalSwitchData customSw[NUM_LOGICAL_SWITCH];
|
LogicalSwitchData logicalSw[NUM_LOGICAL_SWITCH];
|
||||||
CustomFnData funcSw[NUM_CFN];
|
CustomFnData funcSw[NUM_CFN];
|
||||||
SwashRingData swashR;
|
SwashRingData swashR;
|
||||||
PhaseData phaseData[MAX_FLIGHT_MODES];
|
PhaseData phaseData[MAX_FLIGHT_MODES];
|
||||||
|
|
|
@ -1519,7 +1519,7 @@ void flightReset()
|
||||||
#if defined(FRSKY)
|
#if defined(FRSKY)
|
||||||
telemetryReset();
|
telemetryReset();
|
||||||
#endif
|
#endif
|
||||||
logicalSwitchesReset();
|
lswReset();
|
||||||
|
|
||||||
s_last_switch_value = 0;
|
s_last_switch_value = 0;
|
||||||
s_mixer_first_run_done = false;
|
s_mixer_first_run_done = false;
|
||||||
|
@ -2220,7 +2220,7 @@ void doMixerCalculations()
|
||||||
s_cnt_100ms -= 10;
|
s_cnt_100ms -= 10;
|
||||||
s_cnt_1s += 1;
|
s_cnt_1s += 1;
|
||||||
|
|
||||||
evalLogicalSwitchTimers();
|
lswTimerTick();
|
||||||
|
|
||||||
if (s_cnt_1s >= 10) { // 1sec
|
if (s_cnt_1s >= 10) { // 1sec
|
||||||
s_cnt_1s -= 10;
|
s_cnt_1s -= 10;
|
||||||
|
|
|
@ -693,8 +693,8 @@ NOINLINE void per10ms();
|
||||||
|
|
||||||
getvalue_t getValue(uint8_t i);
|
getvalue_t getValue(uint8_t i);
|
||||||
bool getSwitch(int8_t swtch);
|
bool getSwitch(int8_t swtch);
|
||||||
void evalLogicalSwitchTimers();
|
void lswTimerTick();
|
||||||
void logicalSwitchesReset();
|
void lswReset();
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
void getSwitchesPosition(bool startup);
|
void getSwitchesPosition(bool startup);
|
||||||
|
@ -1106,7 +1106,7 @@ ExpoData *expoAddress(uint8_t idx);
|
||||||
MixData *mixAddress(uint8_t idx);
|
MixData *mixAddress(uint8_t idx);
|
||||||
LimitData *limitAddress(uint8_t idx);
|
LimitData *limitAddress(uint8_t idx);
|
||||||
int8_t *curveAddress(uint8_t idx);
|
int8_t *curveAddress(uint8_t idx);
|
||||||
LogicalSwitchData *cswAddress(uint8_t idx);
|
LogicalSwitchData *lswAddress(uint8_t idx);
|
||||||
|
|
||||||
#if !defined(PCBTARANIS)
|
#if !defined(PCBTARANIS)
|
||||||
struct CurveInfo {
|
struct CurveInfo {
|
||||||
|
@ -1199,7 +1199,7 @@ enum CswFunctionFamilies {
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t cswFamily(uint8_t func);
|
uint8_t cswFamily(uint8_t func);
|
||||||
int16_t cswTimerValue(delayval_t val);
|
int16_t lswTimerValue(delayval_t val);
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
#define MASK_CFN_TYPE uint32_t // current max = 32 function switches
|
#define MASK_CFN_TYPE uint32_t // current max = 32 function switches
|
||||||
|
@ -1552,7 +1552,7 @@ ls_telemetry_value_t max8bitsTelemValue(uint8_t channel);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
getvalue_t convert8bitsTelemValue(uint8_t channel, ls_telemetry_value_t value);
|
getvalue_t convert8bitsTelemValue(uint8_t channel, ls_telemetry_value_t value);
|
||||||
getvalue_t convertCswTelemValue(LogicalSwitchData * cs);
|
getvalue_t convertLswTelemValue(LogicalSwitchData * cs);
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
#define convertTelemValue(channel, value) convert16bitsTelemValue(channel, value)
|
#define convertTelemValue(channel, value) convert16bitsTelemValue(channel, value)
|
||||||
|
|
|
@ -47,9 +47,9 @@ volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_used = 0;
|
||||||
volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_value = 0;
|
volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_value = 0;
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
uint32_t cswDelays[NUM_LOGICAL_SWITCH];
|
uint32_t lswDelays[NUM_LOGICAL_SWITCH];
|
||||||
uint32_t cswDurations[NUM_LOGICAL_SWITCH];
|
uint32_t lswDurations[NUM_LOGICAL_SWITCH];
|
||||||
uint8_t cswStates[NUM_LOGICAL_SWITCH];
|
uint8_t lswStates[NUM_LOGICAL_SWITCH];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
|
@ -157,7 +157,7 @@ void getSwitchesPosition(bool startup)
|
||||||
#define SWITCH_POSITION(idx) switchState((EnumKeys)(SW_BASE+(idx)))
|
#define SWITCH_POSITION(idx) switchState((EnumKeys)(SW_BASE+(idx)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int16_t csLastValue[NUM_LOGICAL_SWITCH];
|
int16_t lsLastValue[NUM_LOGICAL_SWITCH];
|
||||||
#define CS_LAST_VALUE_INIT -32768
|
#define CS_LAST_VALUE_INIT -32768
|
||||||
|
|
||||||
/* recursive function. stack as of today (16/03/2012) grows by 8bytes at each call, which is ok! */
|
/* recursive function. stack as of today (16/03/2012) grows by 8bytes at each call, which is ok! */
|
||||||
|
@ -229,23 +229,23 @@ bool getSwitch(int8_t swtch)
|
||||||
else {
|
else {
|
||||||
s_last_switch_used |= mask;
|
s_last_switch_used |= mask;
|
||||||
|
|
||||||
LogicalSwitchData * cs = cswAddress(cs_idx);
|
LogicalSwitchData * ls = lswAddress(cs_idx);
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
int8_t s = cs->andsw;
|
int8_t s = ls->andsw;
|
||||||
#else
|
#else
|
||||||
uint8_t s = cs->andsw;
|
uint8_t s = ls->andsw;
|
||||||
if (s > SWSRC_LAST_SWITCH) {
|
if (s > SWSRC_LAST_SWITCH) {
|
||||||
s += SWSRC_SW1-SWSRC_LAST_SWITCH-1;
|
s += SWSRC_SW1-SWSRC_LAST_SWITCH-1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (cs->func == LS_FUNC_NONE || (s && !getSwitch(s))) {
|
if (ls->func == LS_FUNC_NONE || (s && !getSwitch(s))) {
|
||||||
csLastValue[cs_idx] = CS_LAST_VALUE_INIT;
|
lsLastValue[cs_idx] = CS_LAST_VALUE_INIT;
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
else if ((s=cswFamily(cs->func)) == LS_FAMILY_BOOL) {
|
else if ((s=cswFamily(ls->func)) == LS_FAMILY_BOOL) {
|
||||||
bool res1 = getSwitch(cs->v1);
|
bool res1 = getSwitch(ls->v1);
|
||||||
bool res2 = getSwitch(cs->v2);
|
bool res2 = getSwitch(ls->v2);
|
||||||
switch (cs->func) {
|
switch (ls->func) {
|
||||||
case LS_FUNC_AND:
|
case LS_FUNC_AND:
|
||||||
result = (res1 && res2);
|
result = (res1 && res2);
|
||||||
break;
|
break;
|
||||||
|
@ -259,23 +259,23 @@ bool getSwitch(int8_t swtch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (s == LS_FAMILY_TIMER) {
|
else if (s == LS_FAMILY_TIMER) {
|
||||||
result = (csLastValue[cs_idx] <= 0);
|
result = (lsLastValue[cs_idx] <= 0);
|
||||||
}
|
}
|
||||||
else if (s == LS_FAMILY_STICKY) {
|
else if (s == LS_FAMILY_STICKY) {
|
||||||
result = (csLastValue[cs_idx] & (1<<0));
|
result = (lsLastValue[cs_idx] & (1<<0));
|
||||||
}
|
}
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
else if (s == LS_FAMILY_STAY) {
|
else if (s == LS_FAMILY_STAY) {
|
||||||
result = (csLastValue[cs_idx] & (1<<0));
|
result = (lsLastValue[cs_idx] & (1<<0));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
getvalue_t x = getValue(cs->v1);
|
getvalue_t x = getValue(ls->v1);
|
||||||
getvalue_t y;
|
getvalue_t y;
|
||||||
if (s == LS_FAMILY_COMP) {
|
if (s == LS_FAMILY_COMP) {
|
||||||
y = getValue(cs->v2);
|
y = getValue(ls->v2);
|
||||||
|
|
||||||
switch (cs->func) {
|
switch (ls->func) {
|
||||||
case LS_FUNC_EQUAL:
|
case LS_FUNC_EQUAL:
|
||||||
result = (x==y);
|
result = (x==y);
|
||||||
break;
|
break;
|
||||||
|
@ -288,44 +288,44 @@ bool getSwitch(int8_t swtch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uint8_t v1 = cs->v1;
|
uint8_t v1 = ls->v1;
|
||||||
#if defined(FRSKY)
|
#if defined(FRSKY)
|
||||||
// Telemetry
|
// Telemetry
|
||||||
if (v1 >= MIXSRC_FIRST_TELEM) {
|
if (v1 >= MIXSRC_FIRST_TELEM) {
|
||||||
if ((!TELEMETRY_STREAMING() && v1 >= MIXSRC_FIRST_TELEM+TELEM_FIRST_STREAMED_VALUE-1) || IS_FAI_FORBIDDEN(v1-1))
|
if ((!TELEMETRY_STREAMING() && v1 >= MIXSRC_FIRST_TELEM+TELEM_FIRST_STREAMED_VALUE-1) || IS_FAI_FORBIDDEN(v1-1))
|
||||||
return swtch > 0 ? false : true;
|
return swtch > 0 ? false : true;
|
||||||
|
|
||||||
y = convertCswTelemValue(cs);
|
y = convertLswTelemValue(ls);
|
||||||
|
|
||||||
#if defined(FRSKY_HUB) && defined(GAUGES)
|
#if defined(FRSKY_HUB) && defined(GAUGES)
|
||||||
if (s == LS_FAMILY_OFS) {
|
if (s == LS_FAMILY_OFS) {
|
||||||
uint8_t idx = v1-MIXSRC_FIRST_TELEM+1-TELEM_ALT;
|
uint8_t idx = v1-MIXSRC_FIRST_TELEM+1-TELEM_ALT;
|
||||||
if (idx < THLD_MAX) {
|
if (idx < THLD_MAX) {
|
||||||
// Fill the threshold array
|
// Fill the threshold array
|
||||||
barsThresholds[idx] = 128 + cs->v2;
|
barsThresholds[idx] = 128 + ls->v2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (v1 >= MIXSRC_GVAR1) {
|
else if (v1 >= MIXSRC_GVAR1) {
|
||||||
y = cs->v2;
|
y = ls->v2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
y = calc100toRESX(cs->v2);
|
y = calc100toRESX(ls->v2);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (v1 >= MIXSRC_FIRST_TELEM) {
|
if (v1 >= MIXSRC_FIRST_TELEM) {
|
||||||
y = (int16_t)3 * (128+cs->v2); // it's a Timer
|
y = (int16_t)3 * (128+ls->v2); // it's a Timer
|
||||||
}
|
}
|
||||||
else if (v1 >= MIXSRC_GVAR1) {
|
else if (v1 >= MIXSRC_GVAR1) {
|
||||||
y = cs->v2; // it's a GVAR
|
y = ls->v2; // it's a GVAR
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
y = calc100toRESX(cs->v2);
|
y = calc100toRESX(ls->v2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (cs->func) {
|
switch (ls->func) {
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
case LS_FUNC_VEQUAL:
|
case LS_FUNC_VEQUAL:
|
||||||
result = (x==y);
|
result = (x==y);
|
||||||
|
@ -353,15 +353,15 @@ bool getSwitch(int8_t swtch)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (csLastValue[cs_idx] == CS_LAST_VALUE_INIT)
|
if (lsLastValue[cs_idx] == CS_LAST_VALUE_INIT)
|
||||||
csLastValue[cs_idx] = x;
|
lsLastValue[cs_idx] = x;
|
||||||
int16_t diff = x - csLastValue[cs_idx];
|
int16_t diff = x - lsLastValue[cs_idx];
|
||||||
if (cs->func == LS_FUNC_DIFFEGREATER)
|
if (ls->func == LS_FUNC_DIFFEGREATER)
|
||||||
result = (y >= 0 ? (diff >= y) : (diff <= y));
|
result = (y >= 0 ? (diff >= y) : (diff <= y));
|
||||||
else
|
else
|
||||||
result = (abs(diff) >= y);
|
result = (abs(diff) >= y);
|
||||||
if (result)
|
if (result)
|
||||||
csLastValue[cs_idx] = x;
|
lsLastValue[cs_idx] = x;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -369,25 +369,25 @@ bool getSwitch(int8_t swtch)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
if (cs->delay) {
|
if (ls->delay) {
|
||||||
if (result) {
|
if (result) {
|
||||||
if (cswDelays[cs_idx] > get_tmr10ms())
|
if (lswDelays[cs_idx] > get_tmr10ms())
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cswDelays[cs_idx] = get_tmr10ms() + (cs->delay*10);
|
lswDelays[cs_idx] = get_tmr10ms() + (ls->delay*10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cs->duration) {
|
if (ls->duration) {
|
||||||
if (result && !cswStates[cs_idx]) {
|
if (result && !lswStates[cs_idx]) {
|
||||||
cswDurations[cs_idx] = get_tmr10ms() + (cs->duration*10);
|
lswDurations[cs_idx] = get_tmr10ms() + (ls->duration*10);
|
||||||
}
|
}
|
||||||
|
|
||||||
cswStates[cs_idx] = result;
|
lswStates[cs_idx] = result;
|
||||||
result = false;
|
result = false;
|
||||||
|
|
||||||
if (cswDurations[cs_idx] > get_tmr10ms()) {
|
if (lswDurations[cs_idx] > get_tmr10ms()) {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -599,31 +599,31 @@ void checkSwitches()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void evalLogicalSwitchTimers() {
|
void lswTimerTick() {
|
||||||
for (uint8_t i=0; i<NUM_LOGICAL_SWITCH; i++) {
|
for (uint8_t i=0; i<NUM_LOGICAL_SWITCH; i++) {
|
||||||
LogicalSwitchData * cs = cswAddress(i);
|
LogicalSwitchData * ls = lswAddress(i);
|
||||||
if (cs->func == LS_FUNC_TIMER) {
|
if (ls->func == LS_FUNC_TIMER) {
|
||||||
int16_t *lastValue = &csLastValue[i];
|
int16_t *lastValue = &lsLastValue[i];
|
||||||
if (*lastValue == 0 || *lastValue == CS_LAST_VALUE_INIT) {
|
if (*lastValue == 0 || *lastValue == CS_LAST_VALUE_INIT) {
|
||||||
*lastValue = -cswTimerValue(cs->v1);
|
*lastValue = -lswTimerValue(ls->v1);
|
||||||
}
|
}
|
||||||
else if (*lastValue < 0) {
|
else if (*lastValue < 0) {
|
||||||
if (++(*lastValue) == 0)
|
if (++(*lastValue) == 0)
|
||||||
*lastValue = cswTimerValue(cs->v2);
|
*lastValue = lswTimerValue(ls->v2);
|
||||||
}
|
}
|
||||||
else { // if (*lastValue > 0)
|
else { // if (*lastValue > 0)
|
||||||
*lastValue -= 1;
|
*lastValue -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cs->func == LS_FUNC_STICKY) {
|
else if (ls->func == LS_FUNC_STICKY) {
|
||||||
PACK(typedef struct {
|
PACK(typedef struct {
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
uint8_t last;
|
uint8_t last;
|
||||||
}) cs_sticky_struct;
|
}) ls_sticky_struct;
|
||||||
cs_sticky_struct & lastValue = (cs_sticky_struct &)csLastValue[i];
|
ls_sticky_struct & lastValue = (ls_sticky_struct &)lsLastValue[i];
|
||||||
bool before = lastValue.last & 0x01;
|
bool before = lastValue.last & 0x01;
|
||||||
if (lastValue.state) {
|
if (lastValue.state) {
|
||||||
bool now = getSwitch(cs->v2);
|
bool now = getSwitch(ls->v2);
|
||||||
if (now != before) {
|
if (now != before) {
|
||||||
lastValue.last ^= 1;
|
lastValue.last ^= 1;
|
||||||
if (!before) {
|
if (!before) {
|
||||||
|
@ -632,7 +632,7 @@ void evalLogicalSwitchTimers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bool now = getSwitch(cs->v1);
|
bool now = getSwitch(ls->v1);
|
||||||
if (before != now) {
|
if (before != now) {
|
||||||
lastValue.last ^= 1;
|
lastValue.last ^= 1;
|
||||||
if (!before) {
|
if (!before) {
|
||||||
|
@ -642,23 +642,23 @@ void evalLogicalSwitchTimers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//#if defined(CPUARM)
|
//#if defined(CPUARM)
|
||||||
else if (cs->func == LS_FUNC_STAY) {
|
else if (ls->func == LS_FUNC_STAY) {
|
||||||
PACK(typedef struct {
|
PACK(typedef struct {
|
||||||
uint16_t state:1;
|
uint16_t state:1;
|
||||||
uint16_t duration:15;
|
uint16_t duration:15;
|
||||||
}) cs_stay_struct;
|
}) ls_stay_struct;
|
||||||
|
|
||||||
cs_stay_struct & lastValue = (cs_stay_struct &)csLastValue[i];
|
ls_stay_struct & lastValue = (ls_stay_struct &)lsLastValue[i];
|
||||||
lastValue.state = false;
|
lastValue.state = false;
|
||||||
bool state = getSwitch(cs->v1);
|
bool state = getSwitch(ls->v1);
|
||||||
if (state) {
|
if (state) {
|
||||||
if (cs->v3 == 0 && lastValue.duration == cswTimerValue(cs->v2))
|
if (ls->v3 == 0 && lastValue.duration == lswTimerValue(ls->v2))
|
||||||
lastValue.state = true;
|
lastValue.state = true;
|
||||||
if (lastValue.duration < 1000)
|
if (lastValue.duration < 1000)
|
||||||
lastValue.duration++;
|
lastValue.duration++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (lastValue.duration > cswTimerValue(cs->v2) && lastValue.duration <= cswTimerValue(cs->v2+cs->v3))
|
if (lastValue.duration > lswTimerValue(ls->v2) && lastValue.duration <= lswTimerValue(ls->v2+ls->v3))
|
||||||
lastValue.state = true;
|
lastValue.state = true;
|
||||||
lastValue.duration = 0;
|
lastValue.duration = 0;
|
||||||
}
|
}
|
||||||
|
@ -667,9 +667,9 @@ void evalLogicalSwitchTimers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogicalSwitchData *cswAddress(uint8_t idx)
|
LogicalSwitchData *lswAddress(uint8_t idx)
|
||||||
{
|
{
|
||||||
return &g_model.customSw[idx];
|
return &g_model.logicalSw[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t cswFamily(uint8_t func)
|
uint8_t cswFamily(uint8_t func)
|
||||||
|
@ -690,27 +690,27 @@ uint8_t cswFamily(uint8_t func)
|
||||||
return LS_FAMILY_TIMER+func-LS_FUNC_TIMER;
|
return LS_FAMILY_TIMER+func-LS_FUNC_TIMER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t cswTimerValue(delayval_t val)
|
int16_t lswTimerValue(delayval_t val)
|
||||||
{
|
{
|
||||||
return (val < -109 ? 129+val : (val < 7 ? (113+val)*5 : (53+val)*10));
|
return (val < -109 ? 129+val : (val < 7 ? (113+val)*5 : (53+val)*10));
|
||||||
}
|
}
|
||||||
|
|
||||||
void logicalSwitchesReset() {
|
void lswReset() {
|
||||||
for (uint8_t i=0; i<NUM_LOGICAL_SWITCH; i++) {
|
for (uint8_t i=0; i<NUM_LOGICAL_SWITCH; i++) {
|
||||||
csLastValue[i] = CS_LAST_VALUE_INIT;
|
lsLastValue[i] = CS_LAST_VALUE_INIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getvalue_t convertCswTelemValue(LogicalSwitchData * cs)
|
getvalue_t convertLswTelemValue(LogicalSwitchData * ls)
|
||||||
{
|
{
|
||||||
getvalue_t val;
|
getvalue_t val;
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
val = convert16bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, cs->v2);
|
val = convert16bitsTelemValue(ls->v1 - MIXSRC_FIRST_TELEM + 1, ls->v2);
|
||||||
#else
|
#else
|
||||||
if (cswFamily(cs->func)==LS_FAMILY_OFS)
|
if (cswFamily(ls->func)==LS_FAMILY_OFS)
|
||||||
val = convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2);
|
val = convert8bitsTelemValue(ls->v1 - MIXSRC_FIRST_TELEM + 1, 128+ls->v2);
|
||||||
else
|
else
|
||||||
val = convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2) - convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128);
|
val = convert8bitsTelemValue(ls->v1 - MIXSRC_FIRST_TELEM + 1, 128+ls->v2) - convert8bitsTelemValue(ls->v1 - MIXSRC_FIRST_TELEM + 1, 128);
|
||||||
#endif
|
#endif
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,9 +149,9 @@ void setCurve(uint8_t c, const pm_int8_t ar[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSwitch(uint8_t idx, uint8_t func, int8_t v1, int8_t v2)
|
void setLogicalSwitch(uint8_t idx, uint8_t func, int8_t v1, int8_t v2)
|
||||||
{
|
{
|
||||||
LogicalSwitchData *cs = cswAddress(idx-1);
|
LogicalSwitchData *cs = lswAddress(idx-1);
|
||||||
cs->func = func;
|
cs->func = func;
|
||||||
cs->v1 = v1;
|
cs->v1 = v1;
|
||||||
cs->v2 = v2;
|
cs->v2 = v2;
|
||||||
|
@ -200,8 +200,8 @@ void applyTemplate(uint8_t idx)
|
||||||
md=setDest(13, MIXSRC_CH14); // md->weight= 100; done by setDest anyway
|
md=setDest(13, MIXSRC_CH14); // md->weight= 100; done by setDest anyway
|
||||||
md=setDest(13, MIXSRC_MAX); mixSetWeight(md, -100); md->swtch=SWSRC_SWB; md->mltpx=MLTPX_REP;
|
md=setDest(13, MIXSRC_MAX); mixSetWeight(md, -100); md->swtch=SWSRC_SWB; md->mltpx=MLTPX_REP;
|
||||||
md=setDest(13, MIXSRC_MAX); /* md->weight= 100;*/ md->swtch=SWSRC_THR; md->mltpx=MLTPX_REP;
|
md=setDest(13, MIXSRC_MAX); /* md->weight= 100;*/ md->swtch=SWSRC_THR; md->mltpx=MLTPX_REP;
|
||||||
setSwitch(11, LS_FUNC_VNEG, STK_THR, -99);
|
setLogicalSwitch(11, LS_FUNC_VNEG, STK_THR, -99);
|
||||||
setSwitch(12, LS_FUNC_VPOS, MIXSRC_CH14, 0);
|
setLogicalSwitch(12, LS_FUNC_VPOS, MIXSRC_CH14, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// V-Tail
|
// V-Tail
|
||||||
|
@ -285,7 +285,7 @@ void applyTemplate(uint8_t idx)
|
||||||
// Servo Test
|
// Servo Test
|
||||||
case TMPL_SERVO_TEST:
|
case TMPL_SERVO_TEST:
|
||||||
md=setDest(NUM_CHNOUT-1, MIXSRC_SW1, true); md->weight=110; md->mltpx=MLTPX_ADD; md->delayUp = 6; md->delayDown = 6; md->speedUp = 8; md->speedDown = 8;
|
md=setDest(NUM_CHNOUT-1, MIXSRC_SW1, true); md->weight=110; md->mltpx=MLTPX_ADD; md->delayUp = 6; md->delayDown = 6; md->speedUp = 8; md->speedDown = 8;
|
||||||
setSwitch(1, LS_FUNC_VNEG, MIXSRC_LAST_CH, 0);
|
setLogicalSwitch(1, LS_FUNC_VNEG, MIXSRC_LAST_CH, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue