Switches warning: limited display to first 6 wrong switches

getMovedSwitch(): was not working on 9XE (too many switches, uint64_t needed)
simu: mapped UP and DOWN keyboard keys
This commit is contained in:
Damjan Adamic
2014-12-27 15:41:03 +01:00
parent f69e6c174e
commit d6cc03bef6
4 changed files with 27 additions and 17 deletions
+4
View File
@@ -391,7 +391,11 @@ PACK(typedef struct {
#define IS_TRAINER_EXTERNAL_MODULE() (g_model.trainerMode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || g_model.trainerMode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE)
#define MODELDATA_BITMAP char bitmap[LEN_BITMAP_NAME];
#define MODELDATA_EXTRA uint8_t externalModule; uint8_t trainerMode; ModuleData moduleData[NUM_MODULES+1]; char curveNames[MAX_CURVES][6]; ScriptData scriptsData[MAX_SCRIPTS]; char inputNames[MAX_INPUTS][LEN_INPUT_NAME]; uint8_t nPotsToWarn; int8_t potPosition[NUM_POTS];
#if defined(REV9E)
#define swarnstate_t uint64_t
#else
#define swarnstate_t uint32_t
#endif
#define swarnenable_t uint16_t
#elif defined(PCBSKY9X)
enum ModuleIndex {
+13 -11
View File
@@ -589,11 +589,11 @@ int8_t getMovedSwitch()
#if defined(PCBTARANIS)
for (int i=0; i<NUM_SWITCHES; i++) {
if (SWITCH_EXISTS(i)) {
swarnstate_t mask = (0x03 << (i*2));
swarnstate_t mask = ((swarnstate_t)0x03 << (i*2));
uint8_t prev = (switches_states & mask) >> (i*2);
uint8_t next = (1024+getValue(MIXSRC_SA+i)) / 1024;
if (prev != next) {
switches_states = (switches_states & (~mask)) | (next << (i*2));
switches_states = (switches_states & (~mask)) | ((swarnstate_t)next << (i*2));
if (i<5)
result = 1+(3*i)+next;
else if (i==5)
@@ -660,7 +660,7 @@ void checkSwitches()
#if defined(PCBTARANIS)
for (int i=0; i<NUM_SWITCHES; i++) {
if (SWITCH_WARNING_ALLOWED(i) && !(g_model.switchWarningEnable & (1<<i))) {
swarnstate_t mask = (0x03 << (i*2));
swarnstate_t mask = ((swarnstate_t)0x03 << (i*2));
if (!((states & mask) == (switches_states & mask))) {
warn = true;
}
@@ -710,18 +710,20 @@ void checkSwitches()
if ((last_bad_switches != switches_states) || (last_bad_pots != bad_pots)) {
MESSAGE(STR_SWITCHWARN, NULL, STR_PRESSANYKEYTOSKIP, ((last_bad_switches == 0xff) || (last_bad_pots == 0xff)) ? AU_SWITCH_ALERT : AU_NONE);
int x = 60, y = 4*FH+3;
int numWarnings = 0;
for (int i=0; i<NUM_SWITCHES; ++i) {
if (SWITCH_WARNING_ALLOWED(i) && !(g_model.switchWarningEnable & (1<<i))) {
swarnstate_t mask = (0x03 << (i*2));
swarnstate_t mask = ((swarnstate_t)0x03 << (i*2));
uint8_t attr = ((states & mask) == (switches_states & mask)) ? 0 : INVERS;
if (attr) {
char c = "\300-\301"[(states & mask) >> (i*2)];
putsMixerSource(x, y, MIXSRC_FIRST_SWITCH+i, attr);
lcd_putcAtt(lcdNextPos, y, c, attr);
x = lcdNextPos + 3;
if (x >= LCD_W - 4*FW && y == 4*FH+3) {
y = 6*FH-2;
x = 60;
if (++numWarnings < 7) {
char c = "\300-\301"[(states & mask) >> (i*2)];
putsMixerSource(x, y, MIXSRC_FIRST_SWITCH+i, attr);
lcd_putcAtt(lcdNextPos, y, c, attr);
x = lcdNextPos + 3;
}
else if (numWarnings == 7) {
lcd_putsAtt(x, y, "...", 0);
}
}
}
+8 -4
View File
@@ -17,12 +17,16 @@
#define GPIO_BUTTON_MENU GPIOD->IDR
#define GPIO_BUTTON_EXIT GPIOD->IDR
#define GPIO_BUTTON_PAGE GPIOD->IDR
#define PIN_BUTTON_PLUS GPIO_Pin_10 // PE.10
#define PIN_BUTTON_MINUS GPIO_Pin_11 // PE.11
#if defined(REV9E)
#if defined(SIMU)
#define PIN_BUTTON_PLUS GPIO_Pin_5 // This is for SIMU: reuse rotary encoder pins to map UP and DOWN keyboard keys
#define PIN_BUTTON_MINUS GPIO_Pin_6 // This is for SIMU: reuse rotary encoder pins to map UP and DOWN keyboard keys
#endif
#define GPIO_BUTTON_ENTER GPIOF->IDR
#define PIN_BUTTON_ENTER GPIO_Pin_0 // PF.00
#else
#define PIN_BUTTON_PLUS GPIO_Pin_10 // PE.10
#define PIN_BUTTON_MINUS GPIO_Pin_11 // PE.11
#define GPIO_BUTTON_ENTER GPIOE->IDR
#define PIN_BUTTON_ENTER GPIO_Pin_12 // PE.12
#endif
@@ -258,13 +262,13 @@
#define PIN_PORTA 0x0000
#define PIN_PORTB 0x0100
#define PIN_PORTC 0x0200
#define PIN_PORTD 0x0300
#define PIN_PORTD 0x0300
#define PIN_PORTE 0x0400
#define PIN_PER_1 0x0010
#define PIN_PER_2 0x0020
#define PIN_PER_3 0x0030
#define PIN_PER_5 0x0050
#define PIN_PER_6 0x0060
#define PIN_PER_6 0x0060
#define PIN_PER_8 0x0080
// #define PIN_OS2 0x0000
#define PIN_OS25 0x2000
+2 -2
View File
@@ -143,7 +143,7 @@ void readKeysAndTrims()
++enuk;
}
#if defined(REV9E)
#if defined(REV9E) && !defined(SIMU)
static rotenc_t rePreviousValue;
rotenc_t reNewValue = (x9de_rotenc / 2);
int8_t scrollRE = reNewValue - rePreviousValue;
@@ -321,7 +321,7 @@ void keysInit()
| PIN_TRIM_LV_DN | PIN_TRIM_LV_UP
| PIN_SW_A_L | PIN_SW_D_L | PIN_SW_F | PIN_SW_C_L | PIN_SW_D_H | PIN_SW_H;
#elif defined(REV9E)
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L
GPIO_InitStructure.GPIO_Pin = PIN_TRIM_LH_R | PIN_TRIM_LH_L
| PIN_SW_F_H | PIN_SW_A_L | PIN_SW_B_H | PIN_SW_B_L | PIN_SW_C_H | PIN_SW_D_H | PIN_SW_D_L | PIN_SW_G_H | PIN_SW_G_L | PIN_SW_L_L | PIN_SW_Q_H | PIN_SW_Q_L;
#elif defined(REVPLUS)
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L