[X9D] Switches added

This commit is contained in:
bsongis
2012-11-22 19:17:26 +00:00
parent 31c2d69303
commit 03751a1c75
12 changed files with 123 additions and 18 deletions
+4 -2
View File
@@ -768,10 +768,11 @@ arm-stamp:
@echo "#define SVN_VERS \"open9x-r$(SVNREV)\"" >> stamp-open9x-arm.txt
@cat stamp-open9x-arm.txt
font.lbm: font_6x1.xbm translations/font_se.xbm translations/font_de.xbm translations/font_it.xbm translations/font_cz.xbm translations/font_fr.xbm translations/font_es.xbm
font.lbm: font_6x1.xbm font_extra_6x1.xbm translations/font_se.xbm translations/font_de.xbm translations/font_it.xbm translations/font_cz.xbm translations/font_fr.xbm translations/font_es.xbm
@echo
@echo "Convert font from xbm to lbm:"
$(IMG2LBM) $< $@ char
$(IMG2LBM) font_extra_6x1.xbm font_extra.lbm char
$(IMG2LBM) translations/font_se.xbm translations/font_se.lbm char
$(IMG2LBM) translations/font_de.xbm translations/font_de.lbm char
$(IMG2LBM) translations/font_it.xbm translations/font_it.lbm char
@@ -779,10 +780,11 @@ font.lbm: font_6x1.xbm translations/font_se.xbm translations/font_de.xbm transla
$(IMG2LBM) translations/font_fr.xbm translations/font_fr.lbm char
$(IMG2LBM) translations/font_es.xbm translations/font_es.lbm char
font_dblsize.lbm: font_dblsize.xbm translations/font_dblsize_se.xbm translations/font_dblsize_de.xbm translations/font_dblsize_it.xbm translations/font_dblsize_fr.xbm translations/font_dblsize_es.xbm
font_dblsize.lbm: font_dblsize.xbm font_extra_dblsize.xbm translations/font_dblsize_se.xbm translations/font_dblsize_de.xbm translations/font_dblsize_it.xbm translations/font_dblsize_fr.xbm translations/font_dblsize_es.xbm
@echo
@echo "Convert font from xbm to lbm:"
$(IMG2LBM) $< $@ dblsize
$(IMG2LBM) font_extra_dblsize.xbm font_extra_dblsize.lbm dblsize
$(IMG2LBM) translations/font_dblsize_se.xbm translations/font_dblsize_se.lbm dblsize
$(IMG2LBM) translations/font_dblsize_de.xbm translations/font_dblsize_de.lbm dblsize
$(IMG2LBM) translations/font_dblsize_it.xbm translations/font_dblsize_it.lbm dblsize
+2
View File
@@ -905,6 +905,7 @@ extern uint32_t keyState(EnumKeys enuk)
a = PIOA->PIO_PDSR ;
c = PIOC->PIO_PDSR ;
#if !defined(PCBX9D)
switch ((uint8_t) enuk) {
#ifdef REVB
case SW_ElevDR:
@@ -957,6 +958,7 @@ extern uint32_t keyState(EnumKeys enuk)
default:
break;
}
#endif
if (xxx) {
return 1;
+4 -2
View File
@@ -819,9 +819,11 @@ void menuGeneralDiagKeys(uint8_t event)
for(uint8_t i=0; i<9; i++) {
uint8_t y = i*FH; //+FH;
if(i>(SW_ID0-SW_BASE_DIAG)) y-=FH; //overwrite ID0
#if !defined(PCBX9D)
if(i>(SW_ID0-SW_BASE)) y-=FH; //overwrite ID0
putsSwitches(8*FW, y, i+1, 0); //ohne off,on
displayKeyState(11*FW+2, y, (EnumKeys)(SW_BASE_DIAG+i));
displayKeyState(11*FW+2, y, (EnumKeys)(SW_BASE+i));
#endif
if (i<8) {
y = i/2*FH+FH*4;
+6 -5
View File
@@ -33,9 +33,6 @@
#include "open9x.h"
#define font_5x8_x20_x7f (font)
#define font_10x16_x20_x7f (font_dblsize)
uint8_t displayBuf[DISPLAY_W*DISPLAY_H/8];
#define DISPLAY_END (displayBuf+sizeof(displayBuf))
#define ASSERT_IN_DISPLAY(p) assert((p) >= displayBuf && (p) < DISPLAY_END)
@@ -78,7 +75,11 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, uint8_t mode)
{
uint8_t *p = &displayBuf[ y / 8 * DISPLAY_W + x ];
const pm_uchar *q = &font_5x8_x20_x7f[(c-0x20)*5+4];
#if defined(PCBX9D)
const pm_uchar *q = (c < 0xC0) ? &font[(c-0x20)*5+4] : &font_extra[(c-0xC0)*5+4];
#else
const pm_uchar *q = &font[(c-0x20)*5+4];
#endif
bool inv = false;
if (mode & BLINK) {
@@ -96,7 +97,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, uint8_t mode)
if (mode & DBLSIZE) {
/* each letter consists of ten top bytes followed by
* by ten bottom bytes (20 bytes per * char) */
q = &font_10x16_x20_x7f[((uint16_t)c-0x20)*20];
q = &font_dblsize[((uint16_t)c-0x20)*20];
for (int8_t i=11; i>=0; i--) {
if (mode & CONDENSED && i<=1) break;
uint8_t b1=0, b2=0;
+8
View File
@@ -110,7 +110,11 @@ const pm_char * openLogs()
f_puts("WSHH Alt,", &g_oLogFile);
#endif
#if defined(PCBX9D)
// TODO
#else
f_puts("Rud,Ele,Thr,Ail,P1,P2,P3,THR,RUD,ELE,ID0,ID1,ID2,AIL,GEA,TRN\n", &g_oLogFile);
#endif
}
else {
result = f_lseek(&g_oLogFile, f_size(&g_oLogFile)); // append
@@ -191,6 +195,9 @@ void writeLogs()
}
#endif
#if defined(PCBX9D)
// TODO
#else
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) {
f_printf(&g_oLogFile, "%d,", calibratedStick[i]);
}
@@ -199,6 +206,7 @@ void writeLogs()
error_displayed = STR_SDCARD_ERROR;
s_global_warning = STR_SDCARD_ERROR;
}
#endif
}
}
else {
+18
View File
@@ -225,9 +225,16 @@ enum MixSources {
MIXSRC_Ele,
MIXSRC_Thr,
MIXSRC_Ail,
#if defined(PCBX9D)
MIXSRC_S1,
MIXSRC_S2,
MIXSRC_S3,
MIXSRC_S4,
#else
MIXSRC_P1,
MIXSRC_P2,
MIXSRC_P3,
#endif
#if defined(PCBSKY9X)
MIXSRC_REa,
#elif defined(PCBGRUVIN9X)
@@ -243,6 +250,16 @@ enum MixSources {
MIXSRC_TrimThr,
MIXSRC_TrimAil,
MIXSRC_MAX ,
#if defined(PCBX9D)
MIXSRC_SA,
MIXSRC_SB,
MIXSRC_SC,
MIXSRC_SD,
MIXSRC_SE,
MIXSRC_SF,
MIXSRC_SG,
MIXSRC_SH,
#else
MIXSRC_3POS,
MIXSRC_THR,
MIXSRC_RUD,
@@ -253,6 +270,7 @@ enum MixSources {
MIXSRC_AIL,
MIXSRC_GEA,
MIXSRC_TRN,
#endif
MIXSRC_SW1,
MIXSRC_SW9 = MIXSRC_SW1 + 8,
MIXSRC_SWA,
+9
View File
@@ -549,12 +549,17 @@ int16_t getValue(uint8_t i)
#endif
else if(i<MIXSRC_TrimAil) return calc1000toRESX((int16_t)8 * getTrimValue(s_perout_flight_phase, i-(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS)));
else if(i<MIXSRC_MAX) return 1024;
#if defined(PCBX9D)
// TODO
#else
else if(i<MIXSRC_3POS) return (keyState(SW_ID0) ? -1024 : (keyState(SW_ID1) ? 0 : 1024));
// here the switches are skipped
else if(i<MIXSRC_3POS+3)
#if defined(HELI)
return cyc_anas[i-MIXSRC_3POS];
#else
return 0;
#endif
#endif
else if(i<CSW_PPM_BASE+NUM_CAL_PPM) return (g_ppmIns[i-CSW_PPM_BASE] - g_eeGeneral.trainer.calib[i-CSW_PPM_BASE])*2;
else if(i<CSW_PPM_BASE+NUM_PPM) return g_ppmIns[i-CSW_PPM_BASE]*2;
@@ -2311,6 +2316,9 @@ void perOut(uint8_t mode, uint8_t tick10ms)
v = md->noExpo ? rawAnas[k] : anas[k]; //Switch is on. MAX=FULL=512 or value.
else if (k>=MIXSRC_CH1-1 && k<=MIXSRC_CH16-1 && k-MIXSRC_CH1+1<md->destCh) // if we've already calculated the value - take it instead
v = chans[k-MIXSRC_CH1+1] / 100;
#if defined(PCBX9D)
// TODO
#else
else if (k>=MIXSRC_THR-1 && k<=MIXSRC_SWC-1) {
v = getSwitch(k-MIXSRC_THR+1+1, 0) ? +1024 : -1024;
if (v<0 && !md->swtch)
@@ -2319,6 +2327,7 @@ void perOut(uint8_t mode, uint8_t tick10ms)
else {
v = getValue(k <= MIXSRC_3POS ? k : k-MAX_SWITCH);
}
#endif
}
//========== DELAYS ===============
+39 -6
View File
@@ -438,9 +438,35 @@ enum EnumKeys {
BTN_REa,
BTN_REb,
#endif
NUM_KEYS,
SW_BASE=NUM_KEYS,
//SW_NC,
//SW_ON,
SW_ThrCt,
#if defined(PCBX9D)
SW_SA=SW_BASE,
SW_SB0,
SW_SB1,
SW_SB2,
SW_SC0,
SW_SC1,
SW_SC2,
SW_SD0,
SW_SD1,
SW_SD2,
SW_SE0,
SW_SE1,
SW_SE2,
SW_SF0,
SW_SF1,
SW_SF2,
SW_SG0,
SW_SG1,
SW_SG2,
SW_SH,
#else
SW_ThrCt=SW_BASE,
SW_RuddDR,
SW_ElevDR,
SW_ID0,
@@ -449,7 +475,7 @@ enum EnumKeys {
SW_AileDR,
SW_Gear,
SW_Trainer,
NUM_KEYS = SW_ThrCt
#endif
};
#if defined(PCBX9D)
@@ -531,18 +557,25 @@ enum CswFunctions {
#define CS_VDIFF 3
#define CS_STATE(x) ((x)<CS_AND ? CS_VOFS : ((x)<CS_EQUAL ? CS_VBOOL : ((x)<CS_DIFFEGREATER ? CS_VCOMP : CS_VDIFF)))
#define SW_BASE SW_ThrCt
#define SW_BASE_DIAG SW_ThrCt
#define NUM_STICKS 4
#if defined(PCBX9D)
#define MAX_PSWITCH (SW_SH-SW_SA+1)
#define NUM_POTS 4
#else
#define MAX_PSWITCH (SW_Trainer-SW_ThrCt+1) // 9 physical switches
#define NUM_POTS 3
#endif
#define MAX_SWITCH (MAX_PSWITCH+NUM_CSW)
#define SWITCH_ON (1+MAX_SWITCH)
#define SWITCH_OFF (-SWITCH_ON)
#define NUM_STICKS 4
#define NUM_POTS 3
#define NUM_CYC 3
#if defined(PCBX9D)
#define CSW_PPM_BASE 24 // TODO garbage to compile ...
#else
#define CSW_PPM_BASE (MIXSRC_3POS+NUM_CYC) // because srcRaw is shifted +1!
#endif
#define NUM_CAL_PPM 4
#define NUM_PPM 8
#define CSW_CHOUT_BASE (CSW_PPM_BASE+NUM_PPM)
+5
View File
@@ -379,7 +379,12 @@ void setupPulsesDsm2(uint8_t chns)
break;
}
}
#if defined(PCBX9D)
// TODO
#else
if ((dsmDat[0] & BIND_BIT) && (!keyState(SW_Trainer))) dsmDat[0] &= ~BIND_BIT; // clear bind bit if trainer not pulled
#endif
// TODO find a way to do that, FUNC SWITCH: if ((!(dsmDat[0] & BIND_BIT)) && getSwitch(MAX_DRSWITCH-1, 0, 0)) dsmDat[0] |= RANGECHECK_BIT; // range check function
// else dsmDat[0] &= ~RANGECHECK_BIT;
dsmDat[1]=g_eeGeneral.currModel+1; //DSM2 Header second byte for model match
+11
View File
@@ -405,3 +405,14 @@ const pm_uchar font_dblsize[] PROGMEM = {
#include "font_dblsize_es.lbm"
#endif
};
#if defined(PCBX9D)
const pm_uchar font_extra[] PROGMEM = {
#include "font_extra.lbm"
};
const pm_uchar font_extra_dblsize[] PROGMEM = {
#include "font_extra_dblsize.lbm"
};
#endif
+5
View File
@@ -421,6 +421,11 @@ extern const pm_char STR_MODELS_EXT[];
extern const pm_uchar font[];
extern const pm_uchar font_dblsize[];
#if defined(PCBX9D)
extern const pm_uchar font_extra[];
extern const pm_uchar font_extra_dblsize[];
#endif
extern const pm_char STR_WARNING[];
extern const pm_char STR_EEPROMWARN[];
extern const pm_char STR_THROTTLEWARN[];
+12 -3
View File
@@ -199,14 +199,23 @@
#define TR_VRENCODERS "REa""REb"
#define LEN_VSWITCHES "\003"
#if defined(PCBSKY9X)
#if defined(PCBX9D)
#define TR_VSWITCHES "SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF-""SF\301""SG\300""SG-""SG\301""SH\301""CS1""CS2""CS3""CS4""CS5""CS6""CS7""CS8""CS9""CSA""CSB""CSC""CSD""CSE""CSF""CSG""CSH""CSI""CSJ""CSK""CSL""CSM""CSN""CSO""CSP""CSQ""CSR""CSS""CST""CSU""CSV""CSW"" ON"
#elif defined(PCBSKY9X)
#define TR_VSWITCHES "THR""RUD""ELE""ID0""ID1""ID2""AIL""GEA""TRN""CS1""CS2""CS3""CS4""CS5""CS6""CS7""CS8""CS9""CSA""CSB""CSC""CSD""CSE""CSF""CSG""CSH""CSI""CSJ""CSK""CSL""CSM""CSN""CSO""CSP""CSQ""CSR""CSS""CST""CSU""CSV""CSW"" ON"
#else
#define TR_VSWITCHES "THR""RUD""ELE""ID0""ID1""ID2""AIL""GEA""TRN""CS1""CS2""CS3""CS4""CS5""CS6""CS7""CS8""CS9""CSA""CSB""CSC"" ON"
#endif
#define LEN_VSRCRAW "\004"
#if defined(PCBSKY9X)
#if defined(PCBX9D)
#define TR_POTS_VSRCRAW "S1\0 ""S2\0 ""S3\0 ""S4\0 "
#else
#define TR_POTS_VSRCRAW "P1\0 ""P2\0 ""P3\0 "
#endif
#if defined(PCBX9D)
#define TR_ROTARY_ENCODERS_VSRCRAW
#elif defined(PCBSKY9X)
#define TR_ROTARY_ENCODERS_VSRCRAW "REa "
#elif defined(PCBGRUVIN9X) && defined(EXTRA_ROTARY_ENCODERS)
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd "
@@ -220,7 +229,7 @@
#else
#define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]"
#endif
#define TR_VSRCRAW "Rud\0""Ele\0""Thr\0""Ail\0""P1\0 ""P2\0 ""P3\0 " TR_ROTARY_ENCODERS_VSRCRAW "TrmR" "TrmE" "TrmT" "TrmA" "MAX ""3POS" TR_CYC_VSRCRAW
#define TR_VSRCRAW "Rud\0""Ele\0""Thr\0""Ail\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS_VSRCRAW "TrmR" "TrmE" "TrmT" "TrmA" "MAX ""3POS" TR_CYC_VSRCRAW
#define LEN_VTMRMODES "\003"
#define TR_VTMRMODES "OFF""ABS""THs""TH%""THt"