[X9D] Switches warning screen
This commit is contained in:
+1
-1
@@ -116,7 +116,7 @@ const pm_char * bmpLoad(uint8_t *dest, const char *filename)
|
|||||||
return STR_INCOMPATIBLE;
|
return STR_INCOMPATIBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width > MODEL_BITMAP_WIDTH || height > MODEL_BITMAP_HEIGHT) {
|
if (width > MODEL_BITMAP_WIDTH || height > MODEL_BITMAP_HEIGHT) {
|
||||||
f_close(&bmpFile);
|
f_close(&bmpFile);
|
||||||
return STR_INCOMPATIBLE;
|
return STR_INCOMPATIBLE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -440,6 +440,7 @@ void menuMainView(uint8_t event)
|
|||||||
for (uint8_t i=0; i<8; i++) {
|
for (uint8_t i=0; i<8; i++) {
|
||||||
uint8_t sw;
|
uint8_t sw;
|
||||||
int16_t val;
|
int16_t val;
|
||||||
|
// TODO simplify this + reuse code in checkSwitches() + Menu MODELSETUP
|
||||||
switch(i) {
|
switch(i) {
|
||||||
case 5:
|
case 5:
|
||||||
sw = getValue(MIXSRC_SF-1) > 0 ? 3*i+2 : 3*i+1;
|
sw = getValue(MIXSRC_SF-1) > 0 ? 3*i+2 : 3*i+1;
|
||||||
|
|||||||
+13
-6
@@ -647,7 +647,7 @@ enum menuModelSetupItems {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(LCD212)
|
#if defined(LCD212)
|
||||||
#define MODEL_SETUP_2ND_COLUMN (DISPLAY_W-15*FW-MENUS_SCROLLBAR_WIDTH)
|
#define MODEL_SETUP_2ND_COLUMN (DISPLAY_W-17*FW-MENUS_SCROLLBAR_WIDTH)
|
||||||
#else
|
#else
|
||||||
#define MODEL_SETUP_2ND_COLUMN (DISPLAY_W-11*FW-MENUS_SCROLLBAR_WIDTH)
|
#define MODEL_SETUP_2ND_COLUMN (DISPLAY_W-11*FW-MENUS_SCROLLBAR_WIDTH)
|
||||||
#endif
|
#endif
|
||||||
@@ -779,18 +779,18 @@ void menuModelSetup(uint8_t event)
|
|||||||
case ITEM_MODEL_SWITCHES_WARNING:
|
case ITEM_MODEL_SWITCHES_WARNING:
|
||||||
{
|
{
|
||||||
lcd_putsLeft(y, STR_SWITCHWARNING);
|
lcd_putsLeft(y, STR_SWITCHWARNING);
|
||||||
uint8_t states = g_model.switchWarningStates;
|
swstate_t states = g_model.switchWarningStates;
|
||||||
char c = !(states & 1);
|
char c = !(states & 1);
|
||||||
menu_lcd_onoff(MODEL_SETUP_2ND_COLUMN, y, c, attr);
|
menu_lcd_onoff(MODEL_SETUP_2ND_COLUMN, y, c, attr);
|
||||||
if (attr) {
|
if (attr) {
|
||||||
s_editMode = 0;
|
s_editMode = 0;
|
||||||
switch(event) {
|
switch(event) {
|
||||||
case EVT_KEY_LONG(KEY_MENU):
|
case EVT_KEY_LONG(KEY_ENTER):
|
||||||
killEvents(event);
|
killEvents(event);
|
||||||
getMovedSwitch();
|
getMovedSwitch();
|
||||||
g_model.switchWarningStates = 0x01 + (switches_states << 1);
|
g_model.switchWarningStates = 0x01 + (switches_states << 1);
|
||||||
// no break
|
// no break
|
||||||
case EVT_KEY_BREAK(KEY_MENU):
|
case EVT_KEY_BREAK(KEY_ENTER):
|
||||||
case EVT_KEY_BREAK(KEY_LEFT):
|
case EVT_KEY_BREAK(KEY_LEFT):
|
||||||
case EVT_KEY_BREAK(KEY_RIGHT):
|
case EVT_KEY_BREAK(KEY_RIGHT):
|
||||||
g_model.switchWarningStates ^= 0x01;
|
g_model.switchWarningStates ^= 0x01;
|
||||||
@@ -800,9 +800,15 @@ void menuModelSetup(uint8_t event)
|
|||||||
}
|
}
|
||||||
if (c) {
|
if (c) {
|
||||||
states >>= 1;
|
states >>= 1;
|
||||||
for (uint8_t i=1; i<7; i++) {
|
for (uint8_t i=1; i<NUM_SWITCHES; i++) {
|
||||||
|
#if defined(PCBX9D)
|
||||||
|
c = "\300-\301"[states & 0x03];
|
||||||
|
lcd_putc(MODEL_SETUP_2ND_COLUMN+3+i*(2*FW), y, 'A'+i-1);
|
||||||
|
lcd_putc(MODEL_SETUP_2ND_COLUMN+3+i*(2*FW)+FWNUM, y, c);
|
||||||
|
states >>= 2;
|
||||||
|
#else
|
||||||
attr = 0;
|
attr = 0;
|
||||||
if (i == 4) {
|
if (IS_3POS(i-1)) {
|
||||||
c = '0'+(states & 0x03);
|
c = '0'+(states & 0x03);
|
||||||
states >>= 2;
|
states >>= 2;
|
||||||
}
|
}
|
||||||
@@ -813,6 +819,7 @@ void menuModelSetup(uint8_t event)
|
|||||||
states >>= 1;
|
states >>= 1;
|
||||||
}
|
}
|
||||||
lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+2*FW+i*FW, y, c, attr);
|
lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+2*FW+i*FW, y, c, attr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
+3
-1
@@ -819,8 +819,10 @@ enum Dsm2Variants {
|
|||||||
|
|
||||||
#if defined(PCBX9D) || defined(PCBACT)
|
#if defined(PCBX9D) || defined(PCBACT)
|
||||||
#define MODELDATA_EXTRA char bitmap[10]
|
#define MODELDATA_EXTRA char bitmap[10]
|
||||||
|
#define swstate_t uint16_t
|
||||||
#else
|
#else
|
||||||
#define MODELDATA_EXTRA
|
#define MODELDATA_EXTRA
|
||||||
|
#define swstate_t uint8_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PACK(typedef struct t_ModelData {
|
PACK(typedef struct t_ModelData {
|
||||||
@@ -853,7 +855,7 @@ PACK(typedef struct t_ModelData {
|
|||||||
uint8_t thrTraceSrc;
|
uint8_t thrTraceSrc;
|
||||||
uint8_t modelId;
|
uint8_t modelId;
|
||||||
|
|
||||||
uint8_t switchWarningStates;
|
swstate_t switchWarningStates;
|
||||||
|
|
||||||
MODEL_GVARS_DATA;
|
MODEL_GVARS_DATA;
|
||||||
|
|
||||||
|
|||||||
+33
-4
@@ -903,16 +903,34 @@ bool getSwitch(int8_t swtch, bool nc)
|
|||||||
return __getSwitch(swtch);
|
return __getSwitch(swtch);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t switches_states = 0;
|
swstate_t switches_states = 0;
|
||||||
int8_t getMovedSwitch()
|
int8_t getMovedSwitch()
|
||||||
{
|
{
|
||||||
static tmr10ms_t s_last_time = 0;
|
static tmr10ms_t s_last_time = 0;
|
||||||
|
|
||||||
int8_t result = 0;
|
int8_t result = 0;
|
||||||
|
|
||||||
|
#if defined(PCBX9D)
|
||||||
|
for (uint8_t i=0; i<NUM_SWITCHES; i++) {
|
||||||
|
swstate_t mask = (0x03 << (i*2));
|
||||||
|
uint8_t prev = (switches_states & mask) >> (i*2);
|
||||||
|
uint8_t next = (1024+getValue(MIXSRC_SA+i-1)) / 1024;
|
||||||
|
if (prev != next) {
|
||||||
|
switches_states = (switches_states & (~mask)) | (next << (i*2));
|
||||||
|
if (i<5)
|
||||||
|
result = 1+(3*i)+next;
|
||||||
|
else if (i==5)
|
||||||
|
result = 1+(3*5)+(next!=0);
|
||||||
|
else if (i==6)
|
||||||
|
result = 1+(3*5)+2+next;
|
||||||
|
else
|
||||||
|
result = 1+(3*5)+2+3+next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
for (uint8_t i=MAX_PSWITCH; i>0; i--) {
|
for (uint8_t i=MAX_PSWITCH; i>0; i--) {
|
||||||
bool prev;
|
bool prev;
|
||||||
uint8_t mask = 0;
|
swstate_t mask = 0;
|
||||||
if (i <= 3) {
|
if (i <= 3) {
|
||||||
mask = (1<<(i-1));
|
mask = (1<<(i-1));
|
||||||
prev = (switches_states & mask);
|
prev = (switches_states & mask);
|
||||||
@@ -934,6 +952,7 @@ int8_t getMovedSwitch()
|
|||||||
switches_states = (switches_states & 0xE7) | ((i-4) << 3);
|
switches_states = (switches_states & 0xE7) | ((i-4) << 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((tmr10ms_t)(get_tmr10ms() - s_last_time) > 10)
|
if ((tmr10ms_t)(get_tmr10ms() - s_last_time) > 10)
|
||||||
result = 0;
|
result = 0;
|
||||||
@@ -1305,8 +1324,8 @@ void checkAlarm() // added by Gohst
|
|||||||
|
|
||||||
void checkSwitches()
|
void checkSwitches()
|
||||||
{
|
{
|
||||||
uint8_t last_bad_switches = 0xff;
|
swstate_t last_bad_switches = 0xff;
|
||||||
uint8_t states = g_model.switchWarningStates;
|
swstate_t states = g_model.switchWarningStates;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
@@ -1321,6 +1340,15 @@ void checkSwitches()
|
|||||||
// first - display warning
|
// first - display warning
|
||||||
if (last_bad_switches != switches_states) {
|
if (last_bad_switches != switches_states) {
|
||||||
MESSAGE(STR_SWITCHWARN, NULL, STR_PRESSANYKEYTOSKIP, AU_SWITCH_ALERT);
|
MESSAGE(STR_SWITCHWARN, NULL, STR_PRESSANYKEYTOSKIP, AU_SWITCH_ALERT);
|
||||||
|
#if defined(PCBX9D)
|
||||||
|
for (uint8_t i=0; i<NUM_SWITCHES-1; i++) {
|
||||||
|
swstate_t mask = (0x03 << (1+i*2));
|
||||||
|
uint8_t attr = ((states & mask) == (switches_states & mask)) ? 0 : INVERS;
|
||||||
|
char c = "\300-\301"[(states & mask) >> (1+i*2)];
|
||||||
|
lcd_putcAtt(50+i*(2*FW+FW/2), 5*FH, 'A'+i, attr);
|
||||||
|
lcd_putcAtt(50+i*(2*FW+FW/2)+FW, 5*FH, c, attr);
|
||||||
|
}
|
||||||
|
#else
|
||||||
uint8_t x = 2;
|
uint8_t x = 2;
|
||||||
for (uint8_t i=1; i<8; i++) {
|
for (uint8_t i=1; i<8; i++) {
|
||||||
uint8_t attr = (states & (1 << i)) == (switches_states & (1 << i)) ? 0 : INVERS;
|
uint8_t attr = (states & (1 << i)) == (switches_states & (1 << i)) ? 0 : INVERS;
|
||||||
@@ -1328,6 +1356,7 @@ void checkSwitches()
|
|||||||
if (i == 4 && attr) i++;
|
if (i == 4 && attr) i++;
|
||||||
if (i != 4) x += 3*FW+FW/2;
|
if (i != 4) x += 3*FW+FW/2;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
lcdRefresh();
|
lcdRefresh();
|
||||||
last_bad_switches = switches_states;
|
last_bad_switches = switches_states;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -627,10 +627,14 @@ enum CswFunctions {
|
|||||||
#define NUM_STICKS 4
|
#define NUM_STICKS 4
|
||||||
|
|
||||||
#if defined(PCBX9D) || defined(PCBACT)
|
#if defined(PCBX9D) || defined(PCBACT)
|
||||||
|
#define NUM_SWITCHES 8
|
||||||
|
#define IS_3POS(sw) ((sw) != 5 && (sw) != 7)
|
||||||
#define MAX_PSWITCH (SW_SH2-SW_SA0+1)
|
#define MAX_PSWITCH (SW_SH2-SW_SA0+1)
|
||||||
#define NUM_POTS 4
|
#define NUM_POTS 4
|
||||||
#define NUM_SW_SRCRAW 8
|
#define NUM_SW_SRCRAW 8
|
||||||
#else
|
#else
|
||||||
|
#define NUM_SWITCHES 7
|
||||||
|
#define IS_3POS(sw) ((sw) == 3)
|
||||||
#define MAX_PSWITCH (SW_TRN-SW_THR+1) // 9 physical switches
|
#define MAX_PSWITCH (SW_TRN-SW_THR+1) // 9 physical switches
|
||||||
#define NUM_POTS 3
|
#define NUM_POTS 3
|
||||||
#define NUM_SW_SRCRAW 1
|
#define NUM_SW_SRCRAW 1
|
||||||
@@ -811,7 +815,7 @@ NOINLINE void per10ms();
|
|||||||
int16_t getValue(uint8_t i);
|
int16_t getValue(uint8_t i);
|
||||||
bool getSwitch(int8_t swtch, bool nc);
|
bool getSwitch(int8_t swtch, bool nc);
|
||||||
|
|
||||||
extern uint8_t switches_states;
|
extern swstate_t switches_states;
|
||||||
int8_t getMovedSwitch();
|
int8_t getMovedSwitch();
|
||||||
|
|
||||||
#ifdef FLIGHT_PHASES
|
#ifdef FLIGHT_PHASES
|
||||||
|
|||||||
@@ -292,13 +292,12 @@ void start_timer4()
|
|||||||
|
|
||||||
extern "C" void TC3_IRQHandler() //capture ppm in at 2MHz
|
extern "C" void TC3_IRQHandler() //capture ppm in at 2MHz
|
||||||
{
|
{
|
||||||
uint16_t capture ;
|
|
||||||
static uint16_t lastCapt ;
|
static uint16_t lastCapt ;
|
||||||
|
|
||||||
capture = TC1->TC_CHANNEL[0].TC_RA ;
|
uint16_t capture = TC1->TC_CHANNEL[0].TC_RA ;
|
||||||
(void) TC1->TC_CHANNEL[0].TC_SR ; // Acknowledgethe interrupt
|
(void) TC1->TC_CHANNEL[0].TC_SR ; // Acknowledge the interrupt
|
||||||
|
|
||||||
uint16_t val = (capture - lastCapt) / 2;
|
uint16_t val = ((uint16_t)(capture - lastCapt)) / 2;
|
||||||
|
|
||||||
// G: We process g_ppmIns immediately here, to make servo movement as smooth as possible
|
// G: We process g_ppmIns immediately here, to make servo movement as smooth as possible
|
||||||
// while under trainee control
|
// while under trainee control
|
||||||
|
|||||||
Reference in New Issue
Block a user