mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 00:35:18 +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:
parent
d5b386d5db
commit
abd4de973b
18 changed files with 200 additions and 137 deletions
|
@ -105,7 +105,7 @@ EEPROM_PROGRESS_BAR = NO
|
|||
|
||||
# Enable extra rotary encoders (V4 board only)
|
||||
# Values = YES, NO
|
||||
MOD_EXTRA_ROTARY_ENCODERS = NO
|
||||
EXTRA_ROTARY_ENCODERS = NO
|
||||
|
||||
# DEBUG mode
|
||||
DEBUG = NO
|
||||
|
@ -321,8 +321,8 @@ ifeq ($(PCB), V4)
|
|||
CPPDEFS += -DSOMO
|
||||
endif
|
||||
|
||||
ifeq ($(MOD_EXTRA_ROTARY_ENCODERS), YES)
|
||||
CPPDEFS += -DMOD_EXTRA_ROTARY_ENCODERS
|
||||
ifeq ($(EXTRA_ROTARY_ENCODERS), YES)
|
||||
CPPDEFS += -DEXTRA_ROTARY_ENCODERS
|
||||
MODS:=${MODS}X
|
||||
endif
|
||||
|
||||
|
|
|
@ -960,8 +960,6 @@ void read_9_adc()
|
|||
register uint32_t y;
|
||||
register uint32_t x;
|
||||
|
||||
// PMC->PMC_PCER0 |= 0x20000000L ; // Enable peripheral clock to ADC
|
||||
|
||||
padc = ADC;
|
||||
y = padc->ADC_ISR; // Clear EOC flags
|
||||
for (y = NUMBER_ANALOG+1; --y > 0;) {
|
||||
|
@ -993,44 +991,22 @@ void read_9_adc()
|
|||
if ( Temperature > maxTemperature ) {
|
||||
maxTemperature = Temperature ;
|
||||
}
|
||||
|
||||
// Power save
|
||||
// PMC->PMC_PCER0 &= ~0x20000000L ; // Disable peripheral clock to ADC
|
||||
}
|
||||
|
||||
void readKeysAndTrims()
|
||||
{
|
||||
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 in = ~read_keys();
|
||||
for (i = 1; i < 7; i++) {
|
||||
//INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
|
||||
keys[enuk].input(in & (1 << i), (EnumKeys) 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();
|
||||
|
||||
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);
|
||||
++enuk;
|
||||
}
|
||||
|
|
|
@ -108,20 +108,20 @@ inline void board_init()
|
|||
OCR4A = 0x7d;
|
||||
TCCR4B = (1 << WGM42) | (3<<CS40); // CTC OCR1A, 16MHz / 64 (4us ticks)
|
||||
|
||||
#ifdef MOD_EXTRA_ROTARY_ENCODERS
|
||||
#ifdef EXTRA_ROTARY_ENCODERS
|
||||
//configure uart2 here
|
||||
DDRH &= ~(1 << 0);
|
||||
PORTH &= ~(1 << 0);
|
||||
#define MOD_EXTRA_ROTARY_ENCODERS_USART_BAUD 9600UL
|
||||
UBRR2 = F_CPU/(16*MOD_EXTRA_ROTARY_ENCODERS_USART_BAUD)-1;
|
||||
#define EXTRA_ROTARY_ENCODERS_USART_BAUD 9600UL
|
||||
UBRR2 = F_CPU/(16*EXTRA_ROTARY_ENCODERS_USART_BAUD)-1;
|
||||
//9 bit mode
|
||||
UCSR2C = (1<<USBS2)|(3<<UCSZ20);
|
||||
UCSR2B = (1<<RXEN2)|(0<<TXEN2)|(1<<UCSZ22);
|
||||
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 vpot_mod_state = 0;
|
||||
|
@ -155,7 +155,7 @@ ISR(USART2_RX_vect)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif //MOD_EXTRA_ROTARY_ENCODERS
|
||||
#endif //EXTRA_ROTARY_ENCODERS
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -257,8 +257,8 @@ void readKeysAndTrims()
|
|||
|
||||
uint8_t enuk = KEY_MENU;
|
||||
|
||||
keys[BTN_RE1].input(~PIND & 0x20, BTN_RE1);
|
||||
keys[BTN_RE2].input(~PIND & 0x10, BTN_RE2);
|
||||
keys[BTN_REa].input(~PIND & 0x20, BTN_REa);
|
||||
keys[BTN_REb].input(~PIND & 0x10, BTN_REb);
|
||||
|
||||
uint8_t tin = ~PINL;
|
||||
uint8_t in;
|
||||
|
|
|
@ -110,7 +110,7 @@ bool keyState(EnumKeys enuk)
|
|||
break;
|
||||
|
||||
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;
|
||||
|
||||
case SW_ID2:
|
||||
|
|
|
@ -44,21 +44,7 @@ uint16_t s_eeDirtyTime10ms;
|
|||
#endif
|
||||
|
||||
RlcFile theFile; //used for any file operation
|
||||
|
||||
#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;
|
||||
EeFs eeFs;
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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!
|
||||
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)
|
||||
|
@ -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)
|
||||
{
|
||||
eeWriteBlockCmp(buf, blk*BS+ofs+1, len);
|
||||
eeWriteBlockCmp(buf, blk*BS+ofs+1+BLOCKS_OFFSET, len);
|
||||
}
|
||||
|
||||
static void EeFsFlushFreelist()
|
||||
|
@ -183,7 +169,9 @@ uint16_t EeFsGetFree()
|
|||
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;
|
||||
while( EeFsGetLink(i)) i = EeFsGetLink(i);
|
||||
EeFsSetLink(i,eeFs.freeList);
|
||||
|
@ -196,12 +184,12 @@ int8_t EeFsck()
|
|||
s_sync_write = true;
|
||||
|
||||
uint8_t *bufp = reusableBuffer.eefs_buffer;
|
||||
memset(bufp,0,BLOCKS);
|
||||
memset(bufp, 0, BLOCKS);
|
||||
uint8_t blk ;
|
||||
int8_t ret=0;
|
||||
int8_t ret = 0;
|
||||
|
||||
for(uint8_t i = 0; i <= MAXFILES; i++){
|
||||
uint8_t *startP = i==MAXFILES ? &eeFs.freeList : &eeFs.files[i].startBlk;
|
||||
for(uint8_t i = 0; i <= MAXFILES; i++) {
|
||||
uint8_t *startP = (i==MAXFILES ? &eeFs.freeList : &eeFs.files[i].startBlk);
|
||||
uint8_t lastBlk = 0;
|
||||
blk = *startP;
|
||||
while (blk) {
|
||||
|
@ -247,7 +235,7 @@ void EeFsFormat()
|
|||
eeFs.mySize = sizeof(eeFs);
|
||||
eeFs.freeList = 0;
|
||||
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);
|
||||
eeFs.freeList = FIRSTBLK;
|
||||
EeFsFlush();
|
||||
|
@ -257,11 +245,17 @@ void EeFsFormat()
|
|||
|
||||
bool EeFsOpen() // TODO inline?
|
||||
{
|
||||
eeprom_read_block(&eeFs,0,sizeof(eeFs));
|
||||
eeprom_read_block(&eeFs, 0, sizeof(eeFs));
|
||||
|
||||
#ifdef SIMU
|
||||
if(eeFs.version != EEFS_VERS) perror("bad eeFs.version\n");
|
||||
if(eeFs.mySize != sizeof(eeFs)) perror("bad eeFs.mySize\n");
|
||||
if (eeFs.version != EEFS_VERS) {
|
||||
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
|
||||
|
||||
return eeFs.version == EEFS_VERS && eeFs.mySize == sizeof(eeFs);
|
||||
|
|
|
@ -46,13 +46,31 @@ extern uint16_t s_eeDirtyTime10ms;
|
|||
// bs=32 64 blocks verlust link: 64 16files:16*16 256 sum 320
|
||||
//
|
||||
#if defined(PCBV4)
|
||||
// 4096 - 16 bytes to give 255 blocks, since we can't address 256 block in an 8-bit register
|
||||
#define EESIZE 4080
|
||||
#define EESIZE 4096
|
||||
#define EEFS_VERS 5
|
||||
#define MAXFILES 36
|
||||
#else
|
||||
#define EESIZE 2048
|
||||
#define EESIZE 2048
|
||||
#define EEFS_VERS 4
|
||||
#define MAXFILES 20
|
||||
#endif
|
||||
|
||||
#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_MODEL 2
|
||||
|
||||
|
@ -60,11 +78,19 @@ extern uint16_t s_eeDirtyTime10ms;
|
|||
#define FILE_GENERAL 0
|
||||
/// convert model number 0..MAX_MODELS-1 int fileId
|
||||
#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 FIRSTBLK (RESV/BS)
|
||||
#define BLOCKS (EESIZE/BS)
|
||||
#define RESV sizeof(EeFs) //reserv for eeprom header with directory (eeFs)
|
||||
|
||||
#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();
|
||||
int8_t EeFsck();
|
||||
|
|
|
@ -618,7 +618,7 @@ void menuProcDiagKeys(uint8_t event)
|
|||
for(uint8_t i=0; i<2; i++) {
|
||||
uint8_t y = i*FH + FH;
|
||||
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
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ void menuMainView(uint8_t event)
|
|||
killEvents(KEY_DOWN);
|
||||
break;
|
||||
#ifdef NAVIGATION_RE1
|
||||
case EVT_KEY_LONG(BTN_RE1):
|
||||
case EVT_KEY_LONG(BTN_REa):
|
||||
killEvents(event);
|
||||
if (s_inflight_value && !s_warning) {
|
||||
s_warning = s_inflight_label;
|
||||
|
@ -171,7 +171,7 @@ void menuMainView(uint8_t event)
|
|||
break;
|
||||
}
|
||||
// no break
|
||||
case EVT_KEY_BREAK(BTN_RE1):
|
||||
case EVT_KEY_BREAK(BTN_REa):
|
||||
s_warning = NULL;
|
||||
break;
|
||||
#endif
|
||||
|
@ -289,10 +289,10 @@ void menuMainView(uint8_t event)
|
|||
for (uint8_t i=0; i<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);
|
||||
#if defined(PCBV4) && defined(MOD_EXTRA_ROTARY_ENCODERS)
|
||||
#if defined(PCBV4) && defined(EXTRA_ROTARY_ENCODERS)
|
||||
#define V_BAR_W 4
|
||||
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
|
||||
V_BAR(SCREEN_WIDTH/2-V_BAR_W*3+5+V_BAR_W*i, SCREEN_HEIGHT-8, len)
|
||||
#else
|
||||
|
@ -304,11 +304,11 @@ void menuMainView(uint8_t event)
|
|||
for (uint8_t i=0; i<NUM_ROTARY_ENCODERS; i++) {
|
||||
int16_t val = getRotaryEncoder(i);
|
||||
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)
|
||||
#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)
|
||||
#endif //MOD_EXTRA_ROTARY_ENCODERS
|
||||
#endif //EXTRA_ROTARY_ENCODERS
|
||||
}
|
||||
#endif //PCBV4
|
||||
for (uint8_t i=0; i<12; i++) {
|
||||
|
|
|
@ -180,12 +180,12 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa
|
|||
|
||||
#ifdef NAVIGATION_RE1
|
||||
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();
|
||||
killEvents(event);
|
||||
return false;
|
||||
}
|
||||
if (event == EVT_KEY_BREAK(BTN_RE1)) {
|
||||
if (event == EVT_KEY_BREAK(BTN_REa)) {
|
||||
if (s_editMode > 0 && (maxcol & ZCHAR)) {
|
||||
if (m_posHorz < maxcol-ZCHAR) {
|
||||
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);
|
||||
|
||||
if (event == EVT_KEY_LONG(BTN_RE1)) {
|
||||
if (event == EVT_KEY_LONG(BTN_REa)) {
|
||||
if (value == s_inflight_value) {
|
||||
s_inflight_value = NULL;
|
||||
}
|
||||
|
|
|
@ -82,8 +82,8 @@ void menuProcDebug(uint8_t event);
|
|||
#if defined(NAVIGATION_RE1)
|
||||
extern int8_t scrollRE;
|
||||
extern int16_t p1valdiff;
|
||||
#define IS_RE1_EVT_TYPE(event, type) (event==type(BTN_RE1))
|
||||
#define IS_RE1_EVT(event) ((event&0x0f)==BTN_RE1)
|
||||
#define IS_RE1_EVT_TYPE(event, type) (event==type(BTN_REa))
|
||||
#define IS_RE1_EVT(event) ((event&0x0f)==BTN_REa)
|
||||
#else
|
||||
#define IS_RE1_EVT_TYPE(event, type) (0)
|
||||
#define IS_RE1_EVT(event) (0)
|
||||
|
|
|
@ -190,10 +190,10 @@ void menuProcModelSelect(uint8_t event)
|
|||
}
|
||||
break;
|
||||
#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;
|
||||
break;
|
||||
case EVT_KEY_LONG(BTN_RE1):
|
||||
case EVT_KEY_LONG(BTN_REa):
|
||||
#endif
|
||||
case EVT_KEY_LONG(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++;
|
||||
break;
|
||||
#ifdef NAVIGATION_RE1
|
||||
case EVT_KEY_LONG(BTN_RE1):
|
||||
case EVT_KEY_LONG(BTN_REa):
|
||||
if (v==0) {
|
||||
s_editMode = 0;
|
||||
killEvents(BTN_RE1);
|
||||
killEvents(BTN_REa);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
@ -714,7 +714,7 @@ void menuProcPhasesAll(uint8_t event)
|
|||
switch (event) {
|
||||
case EVT_KEY_FIRST(KEY_MENU):
|
||||
#ifdef NAVIGATION_RE1
|
||||
case EVT_KEY_BREAK(BTN_RE1):
|
||||
case EVT_KEY_BREAK(BTN_REa):
|
||||
#endif
|
||||
if (sub == MAX_PHASES) {
|
||||
s_editMode = 0;
|
||||
|
@ -734,24 +734,24 @@ void menuProcPhasesAll(uint8_t event)
|
|||
uint8_t y=(i+1)*FH;
|
||||
att = i==sub ? INVERS : 0;
|
||||
PhaseData *p = phaseaddress(i);
|
||||
#if defined(MOD_EXTRA_ROTARY_ENCODERS)
|
||||
#if defined(EXTRA_ROTARY_ENCODERS)
|
||||
// lcd_outdezNAtt(0, y, i, att|LEFT, 1);
|
||||
putsFlightPhase(0, y, i+1, att|CONDENSED);
|
||||
#else //MOD_EXTRA_ROTARY_ENCODERS
|
||||
#else //EXTRA_ROTARY_ENCODERS
|
||||
putsFlightPhase(0, y, i+1, att);
|
||||
#endif //MOD_EXTRA_ROTARY_ENCODERS
|
||||
#endif //EXTRA_ROTARY_ENCODERS
|
||||
#if defined PCBV4
|
||||
#if defined(MOD_EXTRA_ROTARY_ENCODERS)
|
||||
#if defined(EXTRA_ROTARY_ENCODERS)
|
||||
#define NAME_OFS (-4-12)
|
||||
#define SWITCH_OFS (-FW/2-2-13)
|
||||
#define TRIMS_OFS (-FW/2-4-15)
|
||||
#define ROTARY_ENC_OFS (0)
|
||||
#else //!MOD_EXTRA_ROTARY_ENCODERS
|
||||
#else //!EXTRA_ROTARY_ENCODERS
|
||||
#define NAME_OFS (-4)
|
||||
#define SWITCH_OFS (-FW/2-2)
|
||||
#define TRIMS_OFS (-FW/2-4)
|
||||
#define ROTARY_ENC_OFS (2)
|
||||
#endif //MOD_EXTRA_ROTARY_ENCODERS
|
||||
#endif //EXTRA_ROTARY_ENCODERS
|
||||
#else
|
||||
#define NAME_OFS 0
|
||||
#define SWITCH_OFS (FW/2)
|
||||
|
@ -902,7 +902,7 @@ void menuProcCurveOne(uint8_t event)
|
|||
break;
|
||||
case EVT_KEY_FIRST(KEY_MENU):
|
||||
#ifdef NAVIGATION_RE1
|
||||
case EVT_KEY_BREAK(BTN_RE1):
|
||||
case EVT_KEY_BREAK(BTN_REa):
|
||||
#endif
|
||||
if (s_editMode<=0) {
|
||||
switch (m_posHorz) {
|
||||
|
@ -1505,8 +1505,8 @@ void menuProcExpoMix(uint8_t expo, uint8_t _event_)
|
|||
}
|
||||
// no break
|
||||
#ifdef NAVIGATION_RE1
|
||||
case EVT_KEY_BREAK(BTN_RE1):
|
||||
case EVT_KEY_LONG(BTN_RE1):
|
||||
case EVT_KEY_BREAK(BTN_REa):
|
||||
case EVT_KEY_LONG(BTN_REa):
|
||||
if (sub == 0)
|
||||
break;
|
||||
#endif
|
||||
|
@ -1696,13 +1696,13 @@ void menuProcLimits(uint8_t event)
|
|||
case 1:
|
||||
lcd_outdezAtt(12*FW+1, y, (int8_t)(ld->min-100), attr | INFLIGHT(ld->min));
|
||||
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;
|
||||
case 2:
|
||||
lcd_outdezAtt(16*FW, y, (int8_t)(ld->max+100), attr | INFLIGHT(ld->max));
|
||||
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;
|
||||
case 3:
|
||||
|
@ -1732,7 +1732,7 @@ void menuProcCurvesAll(uint8_t event)
|
|||
case EVT_KEY_FIRST(KEY_RIGHT):
|
||||
case EVT_KEY_FIRST(KEY_MENU):
|
||||
#ifdef NAVIGATION_RE1
|
||||
case EVT_KEY_BREAK(BTN_RE1):
|
||||
case EVT_KEY_BREAK(BTN_REa):
|
||||
#endif
|
||||
if (sub >= 0) {
|
||||
s_curveChan = sub;
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#define BEEP_VAL ( (g_eeGeneral.warnOpts & WARN_BVAL_BIT) >>3 )
|
||||
|
||||
#if defined(PCBV4)
|
||||
#define EEPROM_VER 206
|
||||
#define EEPROM_VER 207
|
||||
#else
|
||||
#define EEPROM_VER 205
|
||||
#endif
|
||||
|
@ -174,8 +174,13 @@ enum MixSources {
|
|||
MIXSRC_P2,
|
||||
MIXSRC_P3,
|
||||
#if defined(PCBV4)
|
||||
MIXSRC_RE1,
|
||||
MIXSRC_RE2,
|
||||
MIXSRC_REa,
|
||||
MIXSRC_REb,
|
||||
#if defined(EXTRA_ROTARY_ENCODERS)
|
||||
MIXSRC_REc,
|
||||
MIXSRC_REd,
|
||||
MIXSRC_REe,
|
||||
#endif
|
||||
#endif
|
||||
MIXSRC_MAX ,
|
||||
MIXSRC_3POS,
|
||||
|
@ -387,11 +392,11 @@ PACK(typedef struct t_SwashRingData { // Swash Ring data
|
|||
#define TRIM_MIN (-TRIM_MAX)
|
||||
|
||||
#if defined(PCBV4)
|
||||
#if defined(MOD_EXTRA_ROTARY_ENCODERS)
|
||||
#if defined(EXTRA_ROTARY_ENCODERS)
|
||||
#define NUM_EXTRA_ROTARY_ENCODERS 3
|
||||
#else //MOD_EXTRA_ROTARY_ENCODERS
|
||||
#else //EXTRA_ROTARY_ENCODERS
|
||||
#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 ROTARY_ENCODER_MAX 1024
|
||||
#define ROTARY_ENCODER_ARRAY int16_t rotaryEncoders[NUM_ROTARY_ENCODERS];
|
||||
|
@ -414,6 +419,8 @@ PACK(typedef struct t_PhaseData {
|
|||
|
||||
#if defined(PCBARM)
|
||||
#define MAX_MODELS 60
|
||||
#elif defined(PCBV4)
|
||||
#define MAX_MODELS 30
|
||||
#else
|
||||
#define MAX_MODELS 16
|
||||
#endif
|
||||
|
|
|
@ -294,8 +294,8 @@ enum EnumKeys {
|
|||
TRM_RH_DWN ,
|
||||
TRM_RH_UP ,
|
||||
#ifdef PCBV4
|
||||
BTN_RE1,
|
||||
BTN_RE2,
|
||||
BTN_REa,
|
||||
BTN_REb,
|
||||
#endif
|
||||
//SW_NC ,
|
||||
//SW_ON ,
|
||||
|
@ -309,7 +309,6 @@ enum EnumKeys {
|
|||
SW_Gear ,
|
||||
SW_Trainer,
|
||||
NUM_KEYS = SW_ThrCt
|
||||
|
||||
};
|
||||
|
||||
class Key
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#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;
|
||||
uint16_t dummyport16;
|
||||
const char *eepromFile = NULL;
|
||||
|
@ -60,13 +60,37 @@ void setSwitch(int8_t swtch)
|
|||
{
|
||||
switch (swtch) {
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
|
@ -205,6 +229,7 @@ void eeprom_read_block (void *pointer_ram,
|
|||
size_t size)
|
||||
{
|
||||
if (fp) {
|
||||
memset(pointer_ram, 0, size);
|
||||
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");
|
||||
}
|
||||
|
|
58
src/simu.cpp
58
src/simu.cpp
|
@ -302,21 +302,26 @@ void Open9xSim::refreshDiplay()
|
|||
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)
|
||||
PIOC->PIO_PDSR = 0xFDFFFFFF;
|
||||
PIOB->PIO_PDSR = 0xFFFFFFFF;
|
||||
PIOA->PIO_PDSR = 0xFFFFFFFF;
|
||||
PIOC->PIO_PDSR |= ERSKY9X_DOWN_MASK | ERSKY9X_UP_MASK | ERSKY9X_RIGHT_MASK | ERSKY9X_LEFT_MASK ;
|
||||
ERSKY9X_EXIT_PIO->PIO_PDSR |= ERSKY9X_EXIT_MASK;
|
||||
PIOB->PIO_PDSR |= ERSKY9X_MENU_MASK;
|
||||
// PIOA->PIO_PDSR = 0xFFFFFFFF;
|
||||
Temperature = 1000;
|
||||
maxTemperature = 1500;
|
||||
#elif defined(PCBV4)
|
||||
pinl &= ~ 0x3f;
|
||||
#else
|
||||
pinb &= ~ 0x7e;
|
||||
#endif
|
||||
for(unsigned i=0; i<DIM(keys1);i+=5) {
|
||||
if (getApp()->getKeyState(keys1[i])) {
|
||||
pinb |= (1<<keys1[i+1]);
|
||||
pinl |= (1<<keys1[i+2]);
|
||||
#if defined(PCBARM)
|
||||
((Pio*)keys1[i+3])->PIO_PDSR &= ~(keys1[i+4]);
|
||||
#elif defined(PCBV4)
|
||||
pinl |= (1<<keys1[i+2]);
|
||||
#else
|
||||
pinb |= (1<<keys1[i+1]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -329,14 +334,22 @@ void Open9xSim::refreshDiplay()
|
|||
#else
|
||||
static FXuint keys2[]={KEY_F8, KEY_F7, KEY_F4, KEY_F3, KEY_F6, KEY_F5, KEY_F1, KEY_F2 };
|
||||
#endif
|
||||
#ifdef PCBV4
|
||||
#if defined(PCBARM)
|
||||
PIOA->PIO_PDSR &= ~(0x00800000 | 0x01000000 | 0x00000002 | 0x00000001 );
|
||||
#elif defined(PCBV4)
|
||||
pinj = 0;
|
||||
#else
|
||||
pind = 0;
|
||||
#endif
|
||||
for(unsigned i=0; i<DIM(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);
|
||||
#else
|
||||
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 {
|
||||
FXuint key;
|
||||
volatile unsigned char& pin;
|
||||
unsigned char shift;
|
||||
unsigned char value;
|
||||
};
|
||||
#endif
|
||||
|
||||
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)
|
||||
{ KEY_1, pinc, INP_C_ThrCt, 0 },
|
||||
{ KEY_6, pinc, INP_C_AileDR, 0 },
|
||||
|
@ -361,15 +391,20 @@ void Open9xSim::refreshDiplay()
|
|||
#endif
|
||||
{ KEY_2, ping, INP_G_RuddDR, 0 },
|
||||
{ KEY_3, pine, INP_E_ElevDR, 0 },
|
||||
//KEY_4, ping, INP_G_ID1, 0,
|
||||
//KEY_5, pine, INP_E_ID2, 0,
|
||||
//KEY_4, ping, INP_G_ID1, 0,
|
||||
//KEY_5, pine, INP_E_ID2, 0,
|
||||
{ KEY_7, pine, INP_E_Gear, 0 },
|
||||
{ KEY_8, pine, INP_E_Trainer, 0 } };
|
||||
#endif
|
||||
|
||||
for(unsigned i=0; i<DIM(keys3); i++){
|
||||
bool ks = getApp()->getKeyState(keys3[i].key);
|
||||
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);
|
||||
#endif
|
||||
keys3[i].value = ks;
|
||||
}
|
||||
}
|
||||
|
@ -388,6 +423,7 @@ void Open9xSim::refreshDiplay()
|
|||
if(ks && id<2) id++;
|
||||
k5st = ks;
|
||||
}
|
||||
|
||||
switch(id){
|
||||
case 0: setSwitch(DSW_ID0); break;
|
||||
case 1: setSwitch(DSW_ID1); break;
|
||||
|
|
|
@ -34,11 +34,11 @@
|
|||
|
||||
#define LEN_RETA123 "\001"
|
||||
#if defined(PCBV4)
|
||||
#if defined(MOD_EXTRA_ROTARY_ENCODERS)
|
||||
#if defined(EXTRA_ROTARY_ENCODERS)
|
||||
#define TR_RETA123 "RETA123abcde"
|
||||
#else //MOD_EXTRA_ROTARY_ENCODERS
|
||||
#else //EXTRA_ROTARY_ENCODERS
|
||||
#define TR_RETA123 "RETA123ab"
|
||||
#endif //MOD_EXTRA_ROTARY_ENCODERS
|
||||
#endif //EXTRA_ROTARY_ENCODERS
|
||||
#else
|
||||
#define TR_RETA123 "RETA123"
|
||||
#endif
|
||||
|
@ -151,7 +151,7 @@
|
|||
|
||||
#define LEN_VSRCRAW "\004"
|
||||
#if defined(PCBV4)
|
||||
#if defined(MOD_EXTRA_ROTARY_ENCODERS)
|
||||
#if defined(EXTRA_ROTARY_ENCODERS)
|
||||
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe "
|
||||
#else
|
||||
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb "
|
||||
|
|
|
@ -34,11 +34,11 @@
|
|||
|
||||
#define LEN_RETA123 "\001"
|
||||
#if defined(PCBV4)
|
||||
#if defined(MOD_EXTRA_ROTARY_ENCODERS)
|
||||
#if defined(EXTRA_ROTARY_ENCODERS)
|
||||
#define TR_RETA123 "RETA123abcde"
|
||||
#else //MOD_EXTRA_ROTARY_ENCODERS
|
||||
#else //EXTRA_ROTARY_ENCODERS
|
||||
#define TR_RETA123 "RETA123ab"
|
||||
#endif //MOD_EXTRA_ROTARY_ENCODERS
|
||||
#endif //EXTRA_ROTARY_ENCODERS
|
||||
#else
|
||||
#define TR_RETA123 "RETA123"
|
||||
#endif
|
||||
|
@ -152,7 +152,7 @@
|
|||
|
||||
#define LEN_VSRCRAW "\004"
|
||||
#if defined(PCBV4)
|
||||
#if defined(MOD_EXTRA_ROTARY_ENCODERS)
|
||||
#if defined(EXTRA_ROTARY_ENCODERS)
|
||||
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe "
|
||||
#else
|
||||
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb "
|
||||
|
|
|
@ -34,11 +34,11 @@
|
|||
|
||||
#define LEN_RETA123 "\001"
|
||||
#if defined(PCBV4)
|
||||
#if defined(MOD_EXTRA_ROTARY_ENCODERS)
|
||||
#if defined(EXTRA_ROTARY_ENCODERS)
|
||||
#define TR_RETA123 "RETA123abcde"
|
||||
#else //MOD_EXTRA_ROTARY_ENCODERS
|
||||
#else //EXTRA_ROTARY_ENCODERS
|
||||
#define TR_RETA123 "RETA123ab"
|
||||
#endif //MOD_EXTRA_ROTARY_ENCODERS
|
||||
#endif //EXTRA_ROTARY_ENCODERS
|
||||
#else
|
||||
#define TR_RETA123 "RETA123"
|
||||
#endif
|
||||
|
@ -151,7 +151,7 @@
|
|||
|
||||
#define LEN_VSRCRAW "\004"
|
||||
#if defined(PCBV4)
|
||||
#if defined(MOD_EXTRA_ROTARY_ENCODERS)
|
||||
#if defined(EXTRA_ROTARY_ENCODERS)
|
||||
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd ""REe "
|
||||
#else
|
||||
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue