1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-21 15:25:17 +03:00

Makefile option renamed (EXTRA_ROTARY_ENCODERS)

Fixed a bug with option EXTRA_ROTARY_ENCODERS: mixes shifted after REb
30 models when open9x / gruvin9x board
LIMITS min and max range fixed
This commit is contained in:
bsongis 2012-04-15 22:34:39 +00:00
parent d5b386d5db
commit abd4de973b
18 changed files with 200 additions and 137 deletions

View file

@ -105,7 +105,7 @@ EEPROM_PROGRESS_BAR = NO
# Enable extra rotary encoders (V4 board only) # Enable extra rotary encoders (V4 board only)
# Values = YES, NO # Values = YES, NO
MOD_EXTRA_ROTARY_ENCODERS = NO EXTRA_ROTARY_ENCODERS = NO
# DEBUG mode # DEBUG mode
DEBUG = NO DEBUG = NO
@ -321,8 +321,8 @@ ifeq ($(PCB), V4)
CPPDEFS += -DSOMO CPPDEFS += -DSOMO
endif endif
ifeq ($(MOD_EXTRA_ROTARY_ENCODERS), YES) ifeq ($(EXTRA_ROTARY_ENCODERS), YES)
CPPDEFS += -DMOD_EXTRA_ROTARY_ENCODERS CPPDEFS += -DEXTRA_ROTARY_ENCODERS
MODS:=${MODS}X MODS:=${MODS}X
endif endif

View file

@ -960,8 +960,6 @@ void read_9_adc()
register uint32_t y; register uint32_t y;
register uint32_t x; register uint32_t x;
// PMC->PMC_PCER0 |= 0x20000000L ; // Enable peripheral clock to ADC
padc = ADC; padc = ADC;
y = padc->ADC_ISR; // Clear EOC flags y = padc->ADC_ISR; // Clear EOC flags
for (y = NUMBER_ANALOG+1; --y > 0;) { for (y = NUMBER_ANALOG+1; --y > 0;) {
@ -993,44 +991,22 @@ void read_9_adc()
if ( Temperature > maxTemperature ) { if ( Temperature > maxTemperature ) {
maxTemperature = Temperature ; maxTemperature = Temperature ;
} }
// Power save
// PMC->PMC_PCER0 &= ~0x20000000L ; // Disable peripheral clock to ADC
} }
void readKeysAndTrims() void readKeysAndTrims()
{ {
register uint32_t i; register uint32_t i;
/* Fix pulldown resistor on RF-POWER
if (PIOC->PIO_ODSR & 0x00080000) {
PIOC->PIO_CODR = 0x00200000L; // Set bit C19 OFF
}
else {
PIOC->PIO_SODR = 0x00200000L; // Set bit C19 ON
} */
uint8_t enuk = KEY_MENU; uint8_t enuk = KEY_MENU;
uint8_t in = ~read_keys(); uint8_t in = ~read_keys();
for (i = 1; i < 7; i++) { for (i = 1; i < 7; i++) {
//INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
keys[enuk].input(in & (1 << i), (EnumKeys) enuk); keys[enuk].input(in & (1 << i), (EnumKeys) enuk);
++enuk; ++enuk;
} }
// static const uint8_t crossTrim[]={
// 1<<INP_D_TRM_LH_DWN,
// 1<<INP_D_TRM_LH_UP,
// 1<<INP_D_TRM_LV_DWN,
// 1<<INP_D_TRM_LV_UP,
// 1<<INP_D_TRM_RV_DWN,
// 1<<INP_D_TRM_RV_UP,
// 1<<INP_D_TRM_RH_DWN,
// 1<<INP_D_TRM_RH_UP
// };
in = read_trims(); in = read_trims();
for (i = 1; i < 256; i <<= 1) { for (i = 1; i < 256; i <<= 1) {
// INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7
keys[enuk].input(in & i, (EnumKeys) enuk); keys[enuk].input(in & i, (EnumKeys) enuk);
++enuk; ++enuk;
} }

View file

@ -108,20 +108,20 @@ inline void board_init()
OCR4A = 0x7d; OCR4A = 0x7d;
TCCR4B = (1 << WGM42) | (3<<CS40); // CTC OCR1A, 16MHz / 64 (4us ticks) TCCR4B = (1 << WGM42) | (3<<CS40); // CTC OCR1A, 16MHz / 64 (4us ticks)
#ifdef MOD_EXTRA_ROTARY_ENCODERS #ifdef EXTRA_ROTARY_ENCODERS
//configure uart2 here //configure uart2 here
DDRH &= ~(1 << 0); DDRH &= ~(1 << 0);
PORTH &= ~(1 << 0); PORTH &= ~(1 << 0);
#define MOD_EXTRA_ROTARY_ENCODERS_USART_BAUD 9600UL #define EXTRA_ROTARY_ENCODERS_USART_BAUD 9600UL
UBRR2 = F_CPU/(16*MOD_EXTRA_ROTARY_ENCODERS_USART_BAUD)-1; UBRR2 = F_CPU/(16*EXTRA_ROTARY_ENCODERS_USART_BAUD)-1;
//9 bit mode //9 bit mode
UCSR2C = (1<<USBS2)|(3<<UCSZ20); UCSR2C = (1<<USBS2)|(3<<UCSZ20);
UCSR2B = (1<<RXEN2)|(0<<TXEN2)|(1<<UCSZ22); UCSR2B = (1<<RXEN2)|(0<<TXEN2)|(1<<UCSZ22);
UCSR2B |= 1 << RXCIE2; //enable interrupt on rx UCSR2B |= 1 << RXCIE2; //enable interrupt on rx
#endif //MOD_EXTRA_ROTARY_ENCODERS #endif //EXTRA_ROTARY_ENCODERS
} }
#if defined(MOD_EXTRA_ROTARY_ENCODERS) #if defined(EXTRA_ROTARY_ENCODERS)
uint8_t vpotToChange = 0; uint8_t vpotToChange = 0;
uint8_t vpot_mod_state = 0; uint8_t vpot_mod_state = 0;
@ -155,7 +155,7 @@ ISR(USART2_RX_vect)
} }
} }
} }
#endif //MOD_EXTRA_ROTARY_ENCODERS #endif //EXTRA_ROTARY_ENCODERS
#endif #endif
@ -257,8 +257,8 @@ void readKeysAndTrims()
uint8_t enuk = KEY_MENU; uint8_t enuk = KEY_MENU;
keys[BTN_RE1].input(~PIND & 0x20, BTN_RE1); keys[BTN_REa].input(~PIND & 0x20, BTN_REa);
keys[BTN_RE2].input(~PIND & 0x10, BTN_RE2); keys[BTN_REb].input(~PIND & 0x10, BTN_REb);
uint8_t tin = ~PINL; uint8_t tin = ~PINL;
uint8_t in; uint8_t in;

View file

@ -110,7 +110,7 @@ bool keyState(EnumKeys enuk)
break; break;
case SW_ID1: case SW_ID1:
result = (PING & (1<<INP_G_ID1))&& (PINE & (1<<INP_E_ID2)); result = (PING & (1<<INP_G_ID1)) && (PINE & (1<<INP_E_ID2));
break; break;
case SW_ID2: case SW_ID2:

View file

@ -44,21 +44,7 @@ uint16_t s_eeDirtyTime10ms;
#endif #endif
RlcFile theFile; //used for any file operation RlcFile theFile; //used for any file operation
EeFs eeFs;
#define EEFS_VERS 4
PACK(struct DirEnt{
uint8_t startBlk;
uint16_t size:12;
uint16_t typ:4;
});
#define MAXFILES (1+MAX_MODELS+3)
PACK(struct EeFs{
uint8_t version;
uint8_t mySize;
uint8_t freeList;
uint8_t bs;
DirEnt files[MAXFILES];
}) eeFs;
void eeDirty(uint8_t msk) void eeDirty(uint8_t msk)
{ {
@ -131,7 +117,7 @@ void eeWriteBlockCmp(const void *i_pointer_ram, uint16_t i_pointer_eeprom, size_
static uint8_t EeFsRead(uint8_t blk, uint8_t ofs) static uint8_t EeFsRead(uint8_t blk, uint8_t ofs)
{ {
uint8_t ret; uint8_t ret;
eeprom_read_block(&ret, (const void*)(blk*BS+ofs), 1); eeprom_read_block(&ret, (const void*)(blk*BS+ofs+BLOCKS_OFFSET), 1);
return ret; return ret;
} }
@ -144,7 +130,7 @@ static void EeFsSetLink(uint8_t blk, uint8_t val)
{ {
static uint8_t s_link; // we write asynchronously, then nothing on the stack! static uint8_t s_link; // we write asynchronously, then nothing on the stack!
s_link = val; s_link = val;
eeWriteBlockCmp(&s_link, (blk*BS), 1); eeWriteBlockCmp(&s_link, (blk*BS)+BLOCKS_OFFSET, 1);
} }
static uint8_t EeFsGetDat(uint8_t blk,uint8_t ofs) static uint8_t EeFsGetDat(uint8_t blk,uint8_t ofs)
@ -154,7 +140,7 @@ static uint8_t EeFsGetDat(uint8_t blk,uint8_t ofs)
static void EeFsSetDat(uint8_t blk,uint8_t ofs,uint8_t*buf,uint8_t len) static void EeFsSetDat(uint8_t blk,uint8_t ofs,uint8_t*buf,uint8_t len)
{ {
eeWriteBlockCmp(buf, blk*BS+ofs+1, len); eeWriteBlockCmp(buf, blk*BS+ofs+1+BLOCKS_OFFSET, len);
} }
static void EeFsFlushFreelist() static void EeFsFlushFreelist()
@ -183,7 +169,9 @@ uint16_t EeFsGetFree()
return ret; return ret;
} }
static void EeFsFree(uint8_t blk){///free one or more blocks /// free one or more blocks
static void EeFsFree(uint8_t blk)
{
uint8_t i = blk; uint8_t i = blk;
while( EeFsGetLink(i)) i = EeFsGetLink(i); while( EeFsGetLink(i)) i = EeFsGetLink(i);
EeFsSetLink(i,eeFs.freeList); EeFsSetLink(i,eeFs.freeList);
@ -196,12 +184,12 @@ int8_t EeFsck()
s_sync_write = true; s_sync_write = true;
uint8_t *bufp = reusableBuffer.eefs_buffer; uint8_t *bufp = reusableBuffer.eefs_buffer;
memset(bufp,0,BLOCKS); memset(bufp, 0, BLOCKS);
uint8_t blk ; uint8_t blk ;
int8_t ret=0; int8_t ret = 0;
for(uint8_t i = 0; i <= MAXFILES; i++){ for(uint8_t i = 0; i <= MAXFILES; i++) {
uint8_t *startP = i==MAXFILES ? &eeFs.freeList : &eeFs.files[i].startBlk; uint8_t *startP = (i==MAXFILES ? &eeFs.freeList : &eeFs.files[i].startBlk);
uint8_t lastBlk = 0; uint8_t lastBlk = 0;
blk = *startP; blk = *startP;
while (blk) { while (blk) {
@ -247,7 +235,7 @@ void EeFsFormat()
eeFs.mySize = sizeof(eeFs); eeFs.mySize = sizeof(eeFs);
eeFs.freeList = 0; eeFs.freeList = 0;
eeFs.bs = BS; eeFs.bs = BS;
for(uint8_t i = FIRSTBLK; i < BLOCKS; i++) EeFsSetLink(i,i+1); for(uint8_t i = FIRSTBLK; i < BLOCKS-1; i++) EeFsSetLink(i,i+1);
EeFsSetLink(BLOCKS-1, 0); EeFsSetLink(BLOCKS-1, 0);
eeFs.freeList = FIRSTBLK; eeFs.freeList = FIRSTBLK;
EeFsFlush(); EeFsFlush();
@ -257,11 +245,17 @@ void EeFsFormat()
bool EeFsOpen() // TODO inline? bool EeFsOpen() // TODO inline?
{ {
eeprom_read_block(&eeFs,0,sizeof(eeFs)); eeprom_read_block(&eeFs, 0, sizeof(eeFs));
#ifdef SIMU #ifdef SIMU
if(eeFs.version != EEFS_VERS) perror("bad eeFs.version\n"); if (eeFs.version != EEFS_VERS) {
if(eeFs.mySize != sizeof(eeFs)) perror("bad eeFs.mySize\n"); printf("bad eeFs.version (%d instead of %d)\n", eeFs.version, EEFS_VERS);
fflush(stdout);
}
if (eeFs.mySize != sizeof(eeFs)) {
printf("bad eeFs.mySize (%d instead of %d)\n", eeFs.mySize, sizeof(eeFs));
fflush(stdout);
}
#endif #endif
return eeFs.version == EEFS_VERS && eeFs.mySize == sizeof(eeFs); return eeFs.version == EEFS_VERS && eeFs.mySize == sizeof(eeFs);

View file

@ -46,13 +46,31 @@ extern uint16_t s_eeDirtyTime10ms;
// bs=32 64 blocks verlust link: 64 16files:16*16 256 sum 320 // bs=32 64 blocks verlust link: 64 16files:16*16 256 sum 320
// //
#if defined(PCBV4) #if defined(PCBV4)
// 4096 - 16 bytes to give 255 blocks, since we can't address 256 block in an 8-bit register #define EESIZE 4096
#define EESIZE 4080 #define EEFS_VERS 5
#define MAXFILES 36
#else #else
#define EESIZE 2048 #define EESIZE 2048
#define EEFS_VERS 4
#define MAXFILES 20
#endif #endif
#define BS 16 #define BS 16
PACK(struct DirEnt{
uint8_t startBlk;
uint16_t size:12;
uint16_t typ:4;
});
PACK(struct EeFs{
uint8_t version;
uint8_t mySize;
uint8_t freeList;
uint8_t bs;
DirEnt files[MAXFILES];
});
#define FILE_TYP_GENERAL 1 #define FILE_TYP_GENERAL 1
#define FILE_TYP_MODEL 2 #define FILE_TYP_MODEL 2
@ -60,11 +78,19 @@ extern uint16_t s_eeDirtyTime10ms;
#define FILE_GENERAL 0 #define FILE_GENERAL 0
/// convert model number 0..MAX_MODELS-1 int fileId /// convert model number 0..MAX_MODELS-1 int fileId
#define FILE_MODEL(n) (1+(n)) #define FILE_MODEL(n) (1+(n))
#define FILE_TMP (1+16) #define FILE_TMP (1+MAX_MODELS)
#define RESV 64 //reserv for eeprom header with directory (eeFs) #define RESV sizeof(EeFs) //reserv for eeprom header with directory (eeFs)
#define FIRSTBLK (RESV/BS)
#define BLOCKS (EESIZE/BS) #if defined(PCBV4)
#define FIRSTBLK 1
#define BLOCKS (1+(EESIZE-RESV)/BS)
#define BLOCKS_OFFSET (RESV-BS)
#else
#define FIRSTBLK (RESV/BS)
#define BLOCKS (EESIZE/BS)
#define BLOCKS_OFFSET 0
#endif
bool EeFsOpen(); bool EeFsOpen();
int8_t EeFsck(); int8_t EeFsck();

View file

@ -618,7 +618,7 @@ void menuProcDiagKeys(uint8_t event)
for(uint8_t i=0; i<2; i++) { for(uint8_t i=0; i<2; i++) {
uint8_t y = i*FH + FH; uint8_t y = i*FH + FH;
lcd_putsiAtt(14*FW, y, STR_RE1RE2, i, 0); lcd_putsiAtt(14*FW, y, STR_RE1RE2, i, 0);
lcd_outdezNAtt(18*FW, y, g_rotenc[i], LEFT|(keyState((EnumKeys)(BTN_RE1+i)) ? INVERS : 0)); lcd_outdezNAtt(18*FW, y, g_rotenc[i], LEFT|(keyState((EnumKeys)(BTN_REa+i)) ? INVERS : 0));
} }
#endif #endif

View file

@ -163,7 +163,7 @@ void menuMainView(uint8_t event)
killEvents(KEY_DOWN); killEvents(KEY_DOWN);
break; break;
#ifdef NAVIGATION_RE1 #ifdef NAVIGATION_RE1
case EVT_KEY_LONG(BTN_RE1): case EVT_KEY_LONG(BTN_REa):
killEvents(event); killEvents(event);
if (s_inflight_value && !s_warning) { if (s_inflight_value && !s_warning) {
s_warning = s_inflight_label; s_warning = s_inflight_label;
@ -171,7 +171,7 @@ void menuMainView(uint8_t event)
break; break;
} }
// no break // no break
case EVT_KEY_BREAK(BTN_RE1): case EVT_KEY_BREAK(BTN_REa):
s_warning = NULL; s_warning = NULL;
break; break;
#endif #endif
@ -289,10 +289,10 @@ void menuMainView(uint8_t event)
for (uint8_t i=0; i<8; i++) { for (uint8_t i=0; i<8; i++) {
int16_t val = g_chans512[8+i]; int16_t val = g_chans512[8+i];
int8_t len = limit((int16_t)0, (int16_t)(((val+1024) * BAR_HEIGHT) / 2048), (int16_t)BAR_HEIGHT); int8_t len = limit((int16_t)0, (int16_t)(((val+1024) * BAR_HEIGHT) / 2048), (int16_t)BAR_HEIGHT);
#if defined(PCBV4) && defined(MOD_EXTRA_ROTARY_ENCODERS) #if defined(PCBV4) && defined(EXTRA_ROTARY_ENCODERS)
#define V_BAR_W 4 #define V_BAR_W 4
V_BAR(SCREEN_WIDTH/2-V_BAR_W*1+1+V_BAR_W*i, SCREEN_HEIGHT-8, len) V_BAR(SCREEN_WIDTH/2-V_BAR_W*1+1+V_BAR_W*i, SCREEN_HEIGHT-8, len)
#elif defined(PCBV4) //MOD_EXTRA_ROTARY_ENCODERS #elif defined(PCBV4) //EXTRA_ROTARY_ENCODERS
#define V_BAR_W 5 #define V_BAR_W 5
V_BAR(SCREEN_WIDTH/2-V_BAR_W*3+5+V_BAR_W*i, SCREEN_HEIGHT-8, len) V_BAR(SCREEN_WIDTH/2-V_BAR_W*3+5+V_BAR_W*i, SCREEN_HEIGHT-8, len)
#else #else
@ -304,11 +304,11 @@ void menuMainView(uint8_t event)
for (uint8_t i=0; i<NUM_ROTARY_ENCODERS; i++) { for (uint8_t i=0; i<NUM_ROTARY_ENCODERS; i++) {
int16_t val = getRotaryEncoder(i); int16_t val = getRotaryEncoder(i);
int8_t len = limit((int16_t)0, (int16_t)(((val+1024) * BAR_HEIGHT) / 2048), (int16_t)BAR_HEIGHT); int8_t len = limit((int16_t)0, (int16_t)(((val+1024) * BAR_HEIGHT) / 2048), (int16_t)BAR_HEIGHT);
#if defined(MOD_EXTRA_ROTARY_ENCODERS) #if defined(EXTRA_ROTARY_ENCODERS)
V_BAR(SCREEN_WIDTH/2-V_BAR_W*7+1+V_BAR_W*i, SCREEN_HEIGHT-8, len) V_BAR(SCREEN_WIDTH/2-V_BAR_W*7+1+V_BAR_W*i, SCREEN_HEIGHT-8, len)
#else //MOD_EXTRA_ROTARY_ENCODERS #else //EXTRA_ROTARY_ENCODERS
V_BAR(SCREEN_WIDTH/2-V_BAR_W*6+5+V_BAR_W*i, SCREEN_HEIGHT-8, len) V_BAR(SCREEN_WIDTH/2-V_BAR_W*6+5+V_BAR_W*i, SCREEN_HEIGHT-8, len)
#endif //MOD_EXTRA_ROTARY_ENCODERS #endif //EXTRA_ROTARY_ENCODERS
} }
#endif //PCBV4 #endif //PCBV4
for (uint8_t i=0; i<12; i++) { for (uint8_t i=0; i<12; i++) {

View file

@ -180,12 +180,12 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa
#ifdef NAVIGATION_RE1 #ifdef NAVIGATION_RE1
check_rotary_encoder(); check_rotary_encoder();
if (m_posVert < 0 && (event==EVT_KEY_FIRST(BTN_RE1) || event==EVT_KEY_FIRST(KEY_MENU))) { if (m_posVert < 0 && (event==EVT_KEY_FIRST(BTN_REa) || event==EVT_KEY_FIRST(KEY_MENU))) {
popMenu(); popMenu();
killEvents(event); killEvents(event);
return false; return false;
} }
if (event == EVT_KEY_BREAK(BTN_RE1)) { if (event == EVT_KEY_BREAK(BTN_REa)) {
if (s_editMode > 0 && (maxcol & ZCHAR)) { if (s_editMode > 0 && (maxcol & ZCHAR)) {
if (m_posHorz < maxcol-ZCHAR) { if (m_posHorz < maxcol-ZCHAR) {
m_posHorz++; m_posHorz++;
@ -579,7 +579,7 @@ void checkInFlightIncDecModel(uint8_t event, int8_t *value, int8_t i_min, int8_t
{ {
*value = (((uint8_t)(*value)) & ((1 << bitshift) - 1)) + ((i_shift + checkIncDecModel(event, (((uint8_t)(*value)) >> bitshift)-i_shift, i_min, i_max)) << bitshift); *value = (((uint8_t)(*value)) & ((1 << bitshift) - 1)) + ((i_shift + checkIncDecModel(event, (((uint8_t)(*value)) >> bitshift)-i_shift, i_min, i_max)) << bitshift);
if (event == EVT_KEY_LONG(BTN_RE1)) { if (event == EVT_KEY_LONG(BTN_REa)) {
if (value == s_inflight_value) { if (value == s_inflight_value) {
s_inflight_value = NULL; s_inflight_value = NULL;
} }

View file

@ -82,8 +82,8 @@ void menuProcDebug(uint8_t event);
#if defined(NAVIGATION_RE1) #if defined(NAVIGATION_RE1)
extern int8_t scrollRE; extern int8_t scrollRE;
extern int16_t p1valdiff; extern int16_t p1valdiff;
#define IS_RE1_EVT_TYPE(event, type) (event==type(BTN_RE1)) #define IS_RE1_EVT_TYPE(event, type) (event==type(BTN_REa))
#define IS_RE1_EVT(event) ((event&0x0f)==BTN_RE1) #define IS_RE1_EVT(event) ((event&0x0f)==BTN_REa)
#else #else
#define IS_RE1_EVT_TYPE(event, type) (0) #define IS_RE1_EVT_TYPE(event, type) (0)
#define IS_RE1_EVT(event) (0) #define IS_RE1_EVT(event) (0)

View file

@ -190,10 +190,10 @@ void menuProcModelSelect(uint8_t event)
} }
break; break;
#ifdef NAVIGATION_RE1 #ifdef NAVIGATION_RE1
case EVT_KEY_BREAK(BTN_RE1): case EVT_KEY_BREAK(BTN_REa):
s_editMode = (s_editMode == 0 && sub == g_eeGeneral.currModel) ? -1 : 0; s_editMode = (s_editMode == 0 && sub == g_eeGeneral.currModel) ? -1 : 0;
break; break;
case EVT_KEY_LONG(BTN_RE1): case EVT_KEY_LONG(BTN_REa):
#endif #endif
case EVT_KEY_LONG(KEY_MENU): case EVT_KEY_LONG(KEY_MENU):
case EVT_KEY_BREAK(KEY_MENU): case EVT_KEY_BREAK(KEY_MENU):
@ -406,10 +406,10 @@ void EditName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, boo
if (next<size-1) next++; if (next<size-1) next++;
break; break;
#ifdef NAVIGATION_RE1 #ifdef NAVIGATION_RE1
case EVT_KEY_LONG(BTN_RE1): case EVT_KEY_LONG(BTN_REa):
if (v==0) { if (v==0) {
s_editMode = 0; s_editMode = 0;
killEvents(BTN_RE1); killEvents(BTN_REa);
break; break;
} }
#endif #endif
@ -714,7 +714,7 @@ void menuProcPhasesAll(uint8_t event)
switch (event) { switch (event) {
case EVT_KEY_FIRST(KEY_MENU): case EVT_KEY_FIRST(KEY_MENU):
#ifdef NAVIGATION_RE1 #ifdef NAVIGATION_RE1
case EVT_KEY_BREAK(BTN_RE1): case EVT_KEY_BREAK(BTN_REa):
#endif #endif
if (sub == MAX_PHASES) { if (sub == MAX_PHASES) {
s_editMode = 0; s_editMode = 0;
@ -734,24 +734,24 @@ void menuProcPhasesAll(uint8_t event)
uint8_t y=(i+1)*FH; uint8_t y=(i+1)*FH;
att = i==sub ? INVERS : 0; att = i==sub ? INVERS : 0;
PhaseData *p = phaseaddress(i); PhaseData *p = phaseaddress(i);
#if defined(MOD_EXTRA_ROTARY_ENCODERS) #if defined(EXTRA_ROTARY_ENCODERS)
// lcd_outdezNAtt(0, y, i, att|LEFT, 1); // lcd_outdezNAtt(0, y, i, att|LEFT, 1);
putsFlightPhase(0, y, i+1, att|CONDENSED); putsFlightPhase(0, y, i+1, att|CONDENSED);
#else //MOD_EXTRA_ROTARY_ENCODERS #else //EXTRA_ROTARY_ENCODERS
putsFlightPhase(0, y, i+1, att); putsFlightPhase(0, y, i+1, att);
#endif //MOD_EXTRA_ROTARY_ENCODERS #endif //EXTRA_ROTARY_ENCODERS
#if defined PCBV4 #if defined PCBV4
#if defined(MOD_EXTRA_ROTARY_ENCODERS) #if defined(EXTRA_ROTARY_ENCODERS)
#define NAME_OFS (-4-12) #define NAME_OFS (-4-12)
#define SWITCH_OFS (-FW/2-2-13) #define SWITCH_OFS (-FW/2-2-13)
#define TRIMS_OFS (-FW/2-4-15) #define TRIMS_OFS (-FW/2-4-15)
#define ROTARY_ENC_OFS (0) #define ROTARY_ENC_OFS (0)
#else //!MOD_EXTRA_ROTARY_ENCODERS #else //!EXTRA_ROTARY_ENCODERS
#define NAME_OFS (-4) #define NAME_OFS (-4)
#define SWITCH_OFS (-FW/2-2) #define SWITCH_OFS (-FW/2-2)
#define TRIMS_OFS (-FW/2-4) #define TRIMS_OFS (-FW/2-4)
#define ROTARY_ENC_OFS (2) #define ROTARY_ENC_OFS (2)
#endif //MOD_EXTRA_ROTARY_ENCODERS #endif //EXTRA_ROTARY_ENCODERS
#else #else
#define NAME_OFS 0 #define NAME_OFS 0
#define SWITCH_OFS (FW/2) #define SWITCH_OFS (FW/2)
@ -902,7 +902,7 @@ void menuProcCurveOne(uint8_t event)
break; break;
case EVT_KEY_FIRST(KEY_MENU): case EVT_KEY_FIRST(KEY_MENU):
#ifdef NAVIGATION_RE1 #ifdef NAVIGATION_RE1
case EVT_KEY_BREAK(BTN_RE1): case EVT_KEY_BREAK(BTN_REa):
#endif #endif
if (s_editMode<=0) { if (s_editMode<=0) {
switch (m_posHorz) { switch (m_posHorz) {
@ -1505,8 +1505,8 @@ void menuProcExpoMix(uint8_t expo, uint8_t _event_)
} }
// no break // no break
#ifdef NAVIGATION_RE1 #ifdef NAVIGATION_RE1
case EVT_KEY_BREAK(BTN_RE1): case EVT_KEY_BREAK(BTN_REa):
case EVT_KEY_LONG(BTN_RE1): case EVT_KEY_LONG(BTN_REa):
if (sub == 0) if (sub == 0)
break; break;
#endif #endif
@ -1696,13 +1696,13 @@ void menuProcLimits(uint8_t event)
case 1: case 1:
lcd_outdezAtt(12*FW+1, y, (int8_t)(ld->min-100), attr | INFLIGHT(ld->min)); lcd_outdezAtt(12*FW+1, y, (int8_t)(ld->min-100), attr | INFLIGHT(ld->min));
if (active) { if (active) {
CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->min, -limit, limit, +100, STR_MINLIMIT); CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->min, -limit, 25, +100, STR_MINLIMIT);
} }
break; break;
case 2: case 2:
lcd_outdezAtt(16*FW, y, (int8_t)(ld->max+100), attr | INFLIGHT(ld->max)); lcd_outdezAtt(16*FW, y, (int8_t)(ld->max+100), attr | INFLIGHT(ld->max));
if (active) { if (active) {
CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->max, -limit, limit, -100, STR_MAXLIMIT); CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->max, -25, limit, -100, STR_MAXLIMIT);
} }
break; break;
case 3: case 3:
@ -1732,7 +1732,7 @@ void menuProcCurvesAll(uint8_t event)
case EVT_KEY_FIRST(KEY_RIGHT): case EVT_KEY_FIRST(KEY_RIGHT):
case EVT_KEY_FIRST(KEY_MENU): case EVT_KEY_FIRST(KEY_MENU):
#ifdef NAVIGATION_RE1 #ifdef NAVIGATION_RE1
case EVT_KEY_BREAK(BTN_RE1): case EVT_KEY_BREAK(BTN_REa):
#endif #endif
if (sub >= 0) { if (sub >= 0) {
s_curveChan = sub; s_curveChan = sub;

View file

@ -49,7 +49,7 @@
#define BEEP_VAL ( (g_eeGeneral.warnOpts & WARN_BVAL_BIT) >>3 ) #define BEEP_VAL ( (g_eeGeneral.warnOpts & WARN_BVAL_BIT) >>3 )
#if defined(PCBV4) #if defined(PCBV4)
#define EEPROM_VER 206 #define EEPROM_VER 207
#else #else
#define EEPROM_VER 205 #define EEPROM_VER 205
#endif #endif
@ -174,8 +174,13 @@ enum MixSources {
MIXSRC_P2, MIXSRC_P2,
MIXSRC_P3, MIXSRC_P3,
#if defined(PCBV4) #if defined(PCBV4)
MIXSRC_RE1, MIXSRC_REa,
MIXSRC_RE2, MIXSRC_REb,
#if defined(EXTRA_ROTARY_ENCODERS)
MIXSRC_REc,
MIXSRC_REd,
MIXSRC_REe,
#endif
#endif #endif
MIXSRC_MAX , MIXSRC_MAX ,
MIXSRC_3POS, MIXSRC_3POS,
@ -387,11 +392,11 @@ PACK(typedef struct t_SwashRingData { // Swash Ring data
#define TRIM_MIN (-TRIM_MAX) #define TRIM_MIN (-TRIM_MAX)
#if defined(PCBV4) #if defined(PCBV4)
#if defined(MOD_EXTRA_ROTARY_ENCODERS) #if defined(EXTRA_ROTARY_ENCODERS)
#define NUM_EXTRA_ROTARY_ENCODERS 3 #define NUM_EXTRA_ROTARY_ENCODERS 3
#else //MOD_EXTRA_ROTARY_ENCODERS #else //EXTRA_ROTARY_ENCODERS
#define NUM_EXTRA_ROTARY_ENCODERS 0 #define NUM_EXTRA_ROTARY_ENCODERS 0
#endif //MOD_EXTRA_ROTARY_ENCODERS #endif //EXTRA_ROTARY_ENCODERS
#define NUM_ROTARY_ENCODERS (2+NUM_EXTRA_ROTARY_ENCODERS) #define NUM_ROTARY_ENCODERS (2+NUM_EXTRA_ROTARY_ENCODERS)
#define ROTARY_ENCODER_MAX 1024 #define ROTARY_ENCODER_MAX 1024
#define ROTARY_ENCODER_ARRAY int16_t rotaryEncoders[NUM_ROTARY_ENCODERS]; #define ROTARY_ENCODER_ARRAY int16_t rotaryEncoders[NUM_ROTARY_ENCODERS];
@ -414,6 +419,8 @@ PACK(typedef struct t_PhaseData {
#if defined(PCBARM) #if defined(PCBARM)
#define MAX_MODELS 60 #define MAX_MODELS 60
#elif defined(PCBV4)
#define MAX_MODELS 30
#else #else
#define MAX_MODELS 16 #define MAX_MODELS 16
#endif #endif

View file

@ -294,8 +294,8 @@ enum EnumKeys {
TRM_RH_DWN , TRM_RH_DWN ,
TRM_RH_UP , TRM_RH_UP ,
#ifdef PCBV4 #ifdef PCBV4
BTN_RE1, BTN_REa,
BTN_RE2, BTN_REb,
#endif #endif
//SW_NC , //SW_NC ,
//SW_ON , //SW_ON ,
@ -309,7 +309,6 @@ enum EnumKeys {
SW_Gear , SW_Gear ,
SW_Trainer, SW_Trainer,
NUM_KEYS = SW_ThrCt NUM_KEYS = SW_ThrCt
}; };
class Key class Key

View file

@ -33,7 +33,7 @@
#include "open9x.h" #include "open9x.h"
volatile uint8_t pinb=0, pinc=0xff, pind, pine=0xff, ping=0xff, pinh=0xff, pinj=0xff, pinl=0; volatile uint8_t pinb=0xff, pinc=0xff, pind, pine=0xff, ping=0xff, pinh=0xff, pinj=0xff, pinl=0;
uint8_t portb, portc, porth=0, dummyport; uint8_t portb, portc, porth=0, dummyport;
uint16_t dummyport16; uint16_t dummyport16;
const char *eepromFile = NULL; const char *eepromFile = NULL;
@ -60,13 +60,37 @@ void setSwitch(int8_t swtch)
{ {
switch (swtch) { switch (swtch) {
case DSW_ID0: case DSW_ID0:
ping |= (1<<INP_G_ID1); pine &= ~(1<<INP_E_ID2); #if defined(PCBARM)
PIOC->PIO_PDSR &= ~0x00004000;
#elif defined(PCBV4)
ping |= (1<<INP_G_ID1);
pinb &= ~(1<<INP_B_ID2);
#else
ping |= (1<<INP_G_ID1);
pine &= ~(1<<INP_E_ID2);
#endif
break; break;
case DSW_ID1: case DSW_ID1:
ping &= ~(1<<INP_G_ID1); pine &= ~(1<<INP_E_ID2); #if defined(PCBARM)
PIOC->PIO_PDSR |= 0x00004800;
#elif defined(PCBV4)
ping &= ~(1<<INP_G_ID1);
pinb &= ~(1<<INP_B_ID2);
#else
ping &= ~(1<<INP_G_ID1);
pine &= ~(1<<INP_E_ID2);
#endif
break; break;
case DSW_ID2: case DSW_ID2:
ping &= ~(1<<INP_G_ID1); pine |= (1<<INP_E_ID2); #if defined(PCBARM)
PIOC->PIO_PDSR &= ~0x00000800;
#elif defined(PCBV4)
ping &= ~(1<<INP_G_ID1);
pinb |= (1<<INP_B_ID2);
#else
ping &= ~(1<<INP_G_ID1);
pine |= (1<<INP_E_ID2);
#endif
break; break;
default: default:
break; break;
@ -205,6 +229,7 @@ void eeprom_read_block (void *pointer_ram,
size_t size) size_t size)
{ {
if (fp) { if (fp) {
memset(pointer_ram, 0, size);
if (fseek(fp, (long) pointer_eeprom, SEEK_SET)==-1) perror("error in seek"); if (fseek(fp, (long) pointer_eeprom, SEEK_SET)==-1) perror("error in seek");
if (fread(pointer_ram, size, 1, fp) <= 0) perror("error in read"); if (fread(pointer_ram, size, 1, fp) <= 0) perror("error in read");
} }

View file

@ -302,21 +302,26 @@ void Open9xSim::refreshDiplay()
KEY_Left, INP_B_KEY_LFT, INP_P_KEY_LFT, (uint64_t)PIOC, ERSKY9X_LEFT_MASK, KEY_Left, INP_B_KEY_LFT, INP_P_KEY_LFT, (uint64_t)PIOC, ERSKY9X_LEFT_MASK,
}; };
pinb &= ~ 0x7e;
pinl &= ~ 0x3f; // for v4
#if defined(PCBARM) #if defined(PCBARM)
PIOC->PIO_PDSR = 0xFDFFFFFF; PIOC->PIO_PDSR |= ERSKY9X_DOWN_MASK | ERSKY9X_UP_MASK | ERSKY9X_RIGHT_MASK | ERSKY9X_LEFT_MASK ;
PIOB->PIO_PDSR = 0xFFFFFFFF; ERSKY9X_EXIT_PIO->PIO_PDSR |= ERSKY9X_EXIT_MASK;
PIOA->PIO_PDSR = 0xFFFFFFFF; PIOB->PIO_PDSR |= ERSKY9X_MENU_MASK;
// PIOA->PIO_PDSR = 0xFFFFFFFF;
Temperature = 1000; Temperature = 1000;
maxTemperature = 1500; maxTemperature = 1500;
#elif defined(PCBV4)
pinl &= ~ 0x3f;
#else
pinb &= ~ 0x7e;
#endif #endif
for(unsigned i=0; i<DIM(keys1);i+=5) { for(unsigned i=0; i<DIM(keys1);i+=5) {
if (getApp()->getKeyState(keys1[i])) { if (getApp()->getKeyState(keys1[i])) {
pinb |= (1<<keys1[i+1]);
pinl |= (1<<keys1[i+2]);
#if defined(PCBARM) #if defined(PCBARM)
((Pio*)keys1[i+3])->PIO_PDSR &= ~(keys1[i+4]); ((Pio*)keys1[i+3])->PIO_PDSR &= ~(keys1[i+4]);
#elif defined(PCBV4)
pinl |= (1<<keys1[i+2]);
#else
pinb |= (1<<keys1[i+1]);
#endif #endif
} }
} }
@ -329,14 +334,22 @@ void Open9xSim::refreshDiplay()
#else #else
static FXuint keys2[]={KEY_F8, KEY_F7, KEY_F4, KEY_F3, KEY_F6, KEY_F5, KEY_F1, KEY_F2 }; static FXuint keys2[]={KEY_F8, KEY_F7, KEY_F4, KEY_F3, KEY_F6, KEY_F5, KEY_F1, KEY_F2 };
#endif #endif
#ifdef PCBV4 #if defined(PCBARM)
PIOA->PIO_PDSR &= ~(0x00800000 | 0x01000000 | 0x00000002 | 0x00000001 );
#elif defined(PCBV4)
pinj = 0; pinj = 0;
#else #else
pind = 0; pind = 0;
#endif #endif
for(unsigned i=0; i<DIM(keys2);i++){ for(unsigned i=0; i<DIM(keys2);i++){
if(getApp()->getKeyState(keys2[i])) { if(getApp()->getKeyState(keys2[i])) {
#ifdef PCBV4 #if defined(PCBARM)
switch(i) {
case 0:
PIOA->PIO_PDSR |= 0x00800000;
break;
}
#elif defined(PCBV4)
pinj |= (1<<i); pinj |= (1<<i);
#else #else
pind |= (1<<i); pind |= (1<<i);
@ -344,14 +357,31 @@ void Open9xSim::refreshDiplay()
} }
} }
#if defined(PCBARM)
struct SwitchKey {
FXuint key;
volatile uint32_t & pin;
uint32_t shift;
uint32_t value;
};
#else
struct SwitchKey { struct SwitchKey {
FXuint key; FXuint key;
volatile unsigned char& pin; volatile unsigned char& pin;
unsigned char shift; unsigned char shift;
unsigned char value; unsigned char value;
}; };
#endif
static SwitchKey keys3[] = { static SwitchKey keys3[] = {
#if defined(PCBARM)
{ KEY_1, PIOC->PIO_PDSR, 0x00100000, 0 },
{ KEY_6, PIOA->PIO_PDSR, 0x00000004, 0 },
{ KEY_2, PIOA->PIO_PDSR, 0x00008000, 0 },
{ KEY_3, PIOC->PIO_PDSR, 0x80000000, 0 },
{ KEY_7, PIOC->PIO_PDSR, 0x00010000, 0 },
{ KEY_8, PIOC->PIO_PDSR, 0x00000100, 0 } };
#else
#if defined(PCBV4) || defined(JETI) || defined(FRSKY) || defined(NMEA) || defined(ARDUPILOT) #if defined(PCBV4) || defined(JETI) || defined(FRSKY) || defined(NMEA) || defined(ARDUPILOT)
{ KEY_1, pinc, INP_C_ThrCt, 0 }, { KEY_1, pinc, INP_C_ThrCt, 0 },
{ KEY_6, pinc, INP_C_AileDR, 0 }, { KEY_6, pinc, INP_C_AileDR, 0 },
@ -361,15 +391,20 @@ void Open9xSim::refreshDiplay()
#endif #endif
{ KEY_2, ping, INP_G_RuddDR, 0 }, { KEY_2, ping, INP_G_RuddDR, 0 },
{ KEY_3, pine, INP_E_ElevDR, 0 }, { KEY_3, pine, INP_E_ElevDR, 0 },
//KEY_4, ping, INP_G_ID1, 0, //KEY_4, ping, INP_G_ID1, 0,
//KEY_5, pine, INP_E_ID2, 0, //KEY_5, pine, INP_E_ID2, 0,
{ KEY_7, pine, INP_E_Gear, 0 }, { KEY_7, pine, INP_E_Gear, 0 },
{ KEY_8, pine, INP_E_Trainer, 0 } }; { KEY_8, pine, INP_E_Trainer, 0 } };
#endif
for(unsigned i=0; i<DIM(keys3); i++){ for(unsigned i=0; i<DIM(keys3); i++){
bool ks = getApp()->getKeyState(keys3[i].key); bool ks = getApp()->getKeyState(keys3[i].key);
if (ks != keys3[i].value) { if (ks != keys3[i].value) {
#if defined(PCBARM)
if (ks) keys3[i].pin ^= (keys3[i].shift);
#else
if (ks) keys3[i].pin ^= (1<<keys3[i].shift); if (ks) keys3[i].pin ^= (1<<keys3[i].shift);
#endif
keys3[i].value = ks; keys3[i].value = ks;
} }
} }
@ -388,6 +423,7 @@ void Open9xSim::refreshDiplay()
if(ks && id<2) id++; if(ks && id<2) id++;
k5st = ks; k5st = ks;
} }
switch(id){ switch(id){
case 0: setSwitch(DSW_ID0); break; case 0: setSwitch(DSW_ID0); break;
case 1: setSwitch(DSW_ID1); break; case 1: setSwitch(DSW_ID1); break;

View file

@ -34,11 +34,11 @@
#define LEN_RETA123 "\001" #define LEN_RETA123 "\001"
#if defined(PCBV4) #if defined(PCBV4)
#if defined(MOD_EXTRA_ROTARY_ENCODERS) #if defined(EXTRA_ROTARY_ENCODERS)
#define TR_RETA123 "RETA123abcde" #define TR_RETA123 "RETA123abcde"
#else //MOD_EXTRA_ROTARY_ENCODERS #else //EXTRA_ROTARY_ENCODERS
#define TR_RETA123 "RETA123ab" #define TR_RETA123 "RETA123ab"
#endif //MOD_EXTRA_ROTARY_ENCODERS #endif //EXTRA_ROTARY_ENCODERS
#else #else
#define TR_RETA123 "RETA123" #define TR_RETA123 "RETA123"
#endif #endif
@ -151,7 +151,7 @@
#define LEN_VSRCRAW "\004" #define LEN_VSRCRAW "\004"
#if defined(PCBV4) #if defined(PCBV4)
#if defined(MOD_EXTRA_ROTARY_ENCODERS) #if defined(EXTRA_ROTARY_ENCODERS)
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe " #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe "
#else #else
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb "

View file

@ -34,11 +34,11 @@
#define LEN_RETA123 "\001" #define LEN_RETA123 "\001"
#if defined(PCBV4) #if defined(PCBV4)
#if defined(MOD_EXTRA_ROTARY_ENCODERS) #if defined(EXTRA_ROTARY_ENCODERS)
#define TR_RETA123 "RETA123abcde" #define TR_RETA123 "RETA123abcde"
#else //MOD_EXTRA_ROTARY_ENCODERS #else //EXTRA_ROTARY_ENCODERS
#define TR_RETA123 "RETA123ab" #define TR_RETA123 "RETA123ab"
#endif //MOD_EXTRA_ROTARY_ENCODERS #endif //EXTRA_ROTARY_ENCODERS
#else #else
#define TR_RETA123 "RETA123" #define TR_RETA123 "RETA123"
#endif #endif
@ -152,7 +152,7 @@
#define LEN_VSRCRAW "\004" #define LEN_VSRCRAW "\004"
#if defined(PCBV4) #if defined(PCBV4)
#if defined(MOD_EXTRA_ROTARY_ENCODERS) #if defined(EXTRA_ROTARY_ENCODERS)
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe " #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe "
#else #else
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb "

View file

@ -34,11 +34,11 @@
#define LEN_RETA123 "\001" #define LEN_RETA123 "\001"
#if defined(PCBV4) #if defined(PCBV4)
#if defined(MOD_EXTRA_ROTARY_ENCODERS) #if defined(EXTRA_ROTARY_ENCODERS)
#define TR_RETA123 "RETA123abcde" #define TR_RETA123 "RETA123abcde"
#else //MOD_EXTRA_ROTARY_ENCODERS #else //EXTRA_ROTARY_ENCODERS
#define TR_RETA123 "RETA123ab" #define TR_RETA123 "RETA123ab"
#endif //MOD_EXTRA_ROTARY_ENCODERS #endif //EXTRA_ROTARY_ENCODERS
#else #else
#define TR_RETA123 "RETA123" #define TR_RETA123 "RETA123"
#endif #endif
@ -151,7 +151,7 @@
#define LEN_VSRCRAW "\004" #define LEN_VSRCRAW "\004"
#if defined(PCBV4) #if defined(PCBV4)
#if defined(MOD_EXTRA_ROTARY_ENCODERS) #if defined(EXTRA_ROTARY_ENCODERS)
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe " #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe "
#else #else
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " #define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb "