[MEGA2560/GRUVIN9X] Overflow in Custom Functions switch (no ON and One)

This commit is contained in:
bsongis
2015-03-03 20:14:23 +01:00
parent 4c0515ab91
commit 01cd86f6f6
20 changed files with 58 additions and 149 deletions
-13
View File
@@ -1297,19 +1297,6 @@ ifeq ($(IRPROTOS), YES)
CPPDEFS += -DIRPROTOS
endif
ifeq ($(3POS), POT1)
CPPDEFS += -DEXTRA_3POS=1
# EEPROM_VARIANT += ${3POS_VARIANT}
endif
ifeq ($(3POS), POT2)
CPPDEFS += -DEXTRA_3POS=2
# EEPROM_VARIANT += ${3POS_VARIANT}
endif
ifeq ($(3POS), POT3)
CPPDEFS += -DEXTRA_3POS=3
# EEPROM_VARIANT += ${3POS_VARIANT}
endif
#---------------- Compiler Options C++ ----------------
# -g*: generate debugging information
# -O*: optimization level
+1 -1
View File
@@ -665,7 +665,7 @@ void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
if (idx < MIXSRC_THR)
lcd_putsiAtt(x, y, STR_VSRCRAW, idx, att);
else if (idx < MIXSRC_SW1)
putsSwitches(x, y, idx-MIXSRC_THR+1+3*(1/*+EXTRA_3POS*/), att);
putsSwitches(x, y, idx-MIXSRC_THR+1+3*(1), att);
else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH)
putsSwitches(x, y, SWSRC_SW1+idx-MIXSRC_SW1, att);
else if (idx < MIXSRC_CH1)
-6
View File
@@ -150,12 +150,6 @@ enum EnumKeys {
SW_ID0=SW_BASE,
SW_ID1,
SW_ID2,
#if defined(EXTRA_3POS)
SW_ID3,
SW_ID4,
SW_ID5,
#endif
SW_THR,
SW_RUD,
SW_ELE,
-15
View File
@@ -313,10 +313,6 @@ getvalue_t getValue(mixsrc_t i)
#else
else if (i==MIXSRC_3POS) return (getSwitch(SW_ID0-SW_BASE+1) ? -1024 : (getSwitch(SW_ID1-SW_BASE+1) ? 0 : 1024));
// don't use switchState directly to give getSwitch possibility to hack values if needed for switch warning
#if defined(EXTRA_3POS)
else if (i==MIXSRC_3POS2) return (getSwitch(SW_ID3-SW_BASE+1) ? -1024 : (getSwitch(SW_ID4-SW_BASE+1) ? 0 : 1024));
// don't use switchState directly to give getSwitch possibility to hack values if needed for switch warning
#endif
else if (i<MIXSRC_SW1) return getSwitch(SWSRC_THR+i-MIXSRC_THR) ? 1024 : -1024;
#endif
else if (i<=MIXSRC_LAST_LOGICAL_SWITCH) return getSwitch(SWSRC_FIRST_LOGICAL_SWITCH+i-MIXSRC_FIRST_LOGICAL_SWITCH) ? 1024 : -1024;
@@ -453,17 +449,6 @@ void evalInputs(uint8_t mode)
v = -v;
}
#if defined(EXTRA_3POS)
if (i == POT1+EXTRA_3POS-1) {
if (v < -RESX/2)
v = -RESX;
else if (v > +RESX/2)
v = +RESX;
else
v = 0;
}
#endif
BeepANACenter mask = (BeepANACenter)1 << ch;
if (i < NUM_STICKS+NUM_POTS) {
+23 -6
View File
@@ -82,7 +82,7 @@
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
#endif
#if defined (CPUARM)
#if defined(CPUARM)
#define ARM_FIELD(x) x;
#define AVR_FIELD(x)
#else
@@ -602,6 +602,28 @@ PACK(typedef struct {
#define CFN_PARAM(p) ((p)->all.val)
#define CFN_RESET(p) ((p)->active=0, (p)->clear.val1=0, (p)->clear.val2=0)
#define CFN_GVAR_CST_MAX GVAR_LIMIT
#elif defined(CPUM2560)
PACK(typedef struct {
int8_t swtch;
uint8_t func;
uint8_t mode:2;
uint8_t param:4;
uint8_t active:1;
uint8_t spare:1;
uint8_t value;
}) CustomFunctionData;
#define CFN_SWITCH(p) ((p)->swtch)
#define CFN_FUNC(p) ((p)->func)
#define CFN_ACTIVE(p) ((p)->active)
#define CFN_CH_INDEX(p) ((p)->param)
#define CFN_TIMER_INDEX(p) ((p)->param)
#define CFN_GVAR_INDEX(p) ((p)->param)
#define CFN_PLAY_REPEAT(p) ((p)->param)
#define CFN_PLAY_REPEAT_MUL 10
#define CFN_GVAR_MODE(p) ((p)->mode)
#define CFN_PARAM(p) ((p)->value)
#define CFN_RESET(p) ((p)->active = 0, CFN_PARAM(p) = 0)
#define CFN_GVAR_CST_MAX 125
#else
PACK(typedef struct {
PACK(union {
@@ -1674,11 +1696,6 @@ enum SwitchSources {
SWSRC_ID0 = SWSRC_FIRST_SWITCH,
SWSRC_ID1,
SWSRC_ID2,
#if defined(EXTRA_3POS)
SWSRC_ID3,
SWSRC_ID4,
SWSRC_ID5,
#endif
SWSRC_THR,
SWSRC_RUD,
SWSRC_ELE,
@@ -222,20 +222,6 @@ bool switchState(EnumKeys enuk)
result = !(PINB & (1<<INP_B_ID2));
break;
#if 0
case SW_ID3:
result = (calibratedStick[POT1+EXTRA_3POS-1] < 0);
break;
case SW_ID4:
result = (calibratedStick[POT1+EXTRA_3POS-1] == 0);
break;
case SW_ID5:
result = (calibratedStick[POT1+EXTRA_3POS-1] > 0);
break;
#endif
case SW_GEA:
result = PING & (1<<INP_G_Gear);
break;
+1 -15
View File
@@ -144,20 +144,6 @@ bool switchState(EnumKeys enuk)
result = !(PINC & (1<<INP_C_ID2));
break;
/*#if 0
case SW_ID3:
result = (calibratedStick[POT1+EXTRA_3POS-1] < 0);
break;
case SW_ID4:
result = (calibratedStick[POT1+EXTRA_3POS-1] == 0);
break;
case SW_ID5:
result = (calibratedStick[POT1+EXTRA_3POS-1] > 0);
break;
#endif */
case SW_GEA:
result = !(PING & (1<<INP_G_Gear));
break;
@@ -246,4 +232,4 @@ ISR(INT3_vect) // Arduino2560 IO18 (portD pin3)
uint8_t input = (PIND & 0x0C);
if (input == 0 || input == 0x0C) incRotaryEncoder(1, +1);
}
-14
View File
@@ -187,20 +187,6 @@ bool switchState(EnumKeys enuk)
xxx = ~c & 0x00000800; // SW_IDL2 PC11
break;
#if 0
case SW_ID3:
result = (calibratedStick[POT1+EXTRA_3POS-1] < 0);
break;
case SW_ID4:
result = (calibratedStick[POT1+EXTRA_3POS-1] == 0);
break;
case SW_ID5:
result = (calibratedStick[POT1+EXTRA_3POS-1] > 0);
break;
#endif
case SW_GEA:
xxx = c & 0x00010000; // SW_GEAR PC16
break;
-14
View File
@@ -208,20 +208,6 @@ bool switchState(EnumKeys enuk)
result = !(PINE & (1<<INP_E_ID2));
break;
#if defined(EXTRA_3POS)
case SW_ID3:
result = (calibratedStick[POT1+EXTRA_3POS-1] < 0);
break;
case SW_ID4:
result = (calibratedStick[POT1+EXTRA_3POS-1] == 0);
break;
case SW_ID5:
result = (calibratedStick[POT1+EXTRA_3POS-1] > 0);
break;
#endif
case SW_GEA:
result = PINE & (1<<INP_E_Gear);
break;
-4
View File
@@ -431,10 +431,6 @@
#if defined(PCBTARANIS)
#define TR_POTS_VSRCRAW "S1\0 ""S2\0 ""S3\0 ""LS\0 ""RS\0 "
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SD\0 ""SE\0 ""SF\0 ""SG\0 ""SH\0 "
#elif defined(EXTRA_3POS)
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 "
#define TR_SW_VSRCRAW "3P1\0""3P2\0"
#define TR_9X_3POS_SWITCHES "ID0""ID1""ID2""ID3""ID4""ID5"
#else
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 ""P3\0 "
#define TR_SW_VSRCRAW "3POS"
-4
View File
@@ -438,10 +438,6 @@
#if defined(PCBTARANIS)
#define TR_POTS_VSRCRAW "S1\0 ""S2\0 ""S3\0 ""LS\0 ""RS\0 " //4 Potis S1,S2,Links,Rechts
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SD\0 ""SE\0 ""SF\0 ""SG\0 ""SH\0 "
#elif defined(EXTRA_3POS)
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 "
#define TR_SW_VSRCRAW "3P1\0""3P2\0"
#define TR_9X_3POS_SWITCHES "ID0""ID1""ID2""ID3""ID4""ID5"
#else
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 ""P3\0 "
#define TR_SW_VSRCRAW "3POS"
-4
View File
@@ -439,10 +439,6 @@
#elif defined(PCBTARANIS)
#define TR_POTS_VSRCRAW "S1\0 ""S2\0 ""S3\0 ""LS\0 ""RS\0 "
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SD\0 ""SE\0 ""SF\0 ""SG\0 ""SH\0 ""SI\0 ""SJ\0 ""SK\0 ""SL\0 ""SM\0 ""SN\0 "
#elif defined(EXTRA_3POS)
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 "
#define TR_SW_VSRCRAW "3P1\0""3P2\0"
#define TR_9X_3POS_SWITCHES "ID0""ID1""ID2""ID3""ID4""ID5"
#else
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 ""P3\0 "
#define TR_SW_VSRCRAW "3POS"
-4
View File
@@ -431,10 +431,6 @@
#if defined(PCBTARANIS)
#define TR_POTS_VSRCRAW "S1\0 ""S2\0 ""S3\0 ""LS\0 ""RS\0 "
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SD\0 ""SE\0 ""SF\0 ""SG\0 ""SH\0 "
#elif defined(EXTRA_3POS)
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 "
#define TR_SW_VSRCRAW "3P1\0""3P2\0"
#define TR_9X_3POS_SWITCHES "ID0""ID1""ID2""ID3""ID4""ID5"
#else
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 ""P3\0 "
#define TR_SW_VSRCRAW "3POS"
-4
View File
@@ -431,10 +431,6 @@
#if defined(PCBTARANIS)
#define TR_POTS_VSRCRAW "S1\0 ""S2\0 ""S3\0 ""LS\0 ""RS\0 "
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SD\0 ""SE\0 ""SF\0 ""SG\0 ""SH\0 "
#elif defined(EXTRA_3POS)
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 "
#define TR_SW_VSRCRAW "3P1\0""3P2\0"
#define TR_9X_3POS_SWITCHES "ID0""ID1""ID2""ID3""ID4""ID5"
#else
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 ""P3\0 "
#define TR_SW_VSRCRAW "3POS"
-4
View File
@@ -431,10 +431,6 @@
#if defined(PCBTARANIS)
#define TR_POTS_VSRCRAW "S1\0 ""S2\0 ""S3\0 ""LS\0 ""RS\0 "
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SD\0 ""SE\0 ""SF\0 ""SG\0 ""SH\0 "
#elif defined(EXTRA_3POS)
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 "
#define TR_SW_VSRCRAW "3P1\0""3P2\0"
#define TR_9X_3POS_SWITCHES "ID0""ID1""ID2""ID3""ID4""ID5"
#else
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 ""P3\0 "
#define TR_SW_VSRCRAW "3POS"
-4
View File
@@ -431,10 +431,6 @@
#if defined(PCBTARANIS)
#define TR_POTS_VSRCRAW "S1\0 ""S2\0 ""S3\0 ""LS\0 ""RS\0 "
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SD\0 ""SE\0 ""SF\0 ""SG\0 ""SH\0 "
#elif defined(EXTRA_3POS)
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 "
#define TR_SW_VSRCRAW "3P1\0""3P2\0"
#define TR_9X_3POS_SWITCHES "ID0""ID1""ID2""ID3""ID4""ID5"
#else
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 ""P3\0 "
#define TR_SW_VSRCRAW "3POS"
-4
View File
@@ -429,10 +429,6 @@
#if defined(PCBTARANIS)
#define TR_POTS_VSRCRAW "S1\0 ""S2\0 ""S3\0 ""LS\0 ""RS\0 "
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SD\0 ""SE\0 ""SF\0 ""SG\0 ""SH\0 "
#elif defined(EXTRA_3POS)
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 "
#define TR_SW_VSRCRAW "3P1\0""3P2\0"
#define TR_9X_3POS_SWITCHES "ID0""ID1""ID2""ID3""ID4""ID5"
#else
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 ""P3\0 "
#define TR_SW_VSRCRAW "3POS"
-4
View File
@@ -431,10 +431,6 @@
#if defined(PCBTARANIS)
#define TR_POTS_VSRCRAW "S1\0 ""S2\0 ""S3\0 ""LS\0 ""RS\0 "
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SD\0 ""SE\0 ""SF\0 ""SG\0 ""SH\0 "
#elif defined(EXTRA_3POS)
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 "
#define TR_SW_VSRCRAW "3P1\0""3P2\0"
#define TR_9X_3POS_SWITCHES "ID0""ID1""ID2""ID3""ID4""ID5"
#else
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 ""P3\0 "
#define TR_SW_VSRCRAW "3POS"
-4
View File
@@ -431,10 +431,6 @@
#if defined(PCBTARANIS)
#define TR_POTS_VSRCRAW "S1\0 ""S2\0 ""S3\0 ""LS\0 ""RS\0 "
#define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SD\0 ""SE\0 ""SF\0 ""SG\0 ""SH\0 "
#elif defined(EXTRA_3POS)
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 "
#define TR_SW_VSRCRAW "3P1\0""3P2\0"
#define TR_9X_3POS_SWITCHES "ID0""ID1""ID2""ID3""ID4""ID5"
#else
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 ""P3\0 "
#define TR_SW_VSRCRAW "3POS"