diff --git a/src/general_menus.cpp b/src/general_menus.cpp index 8440e7577..c6007cb30 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -115,7 +115,6 @@ enum menuGeneralSetupItems { ITEM_SETUP_MEMORY_WARNING, ITEM_SETUP_ALARM_WARNING, IF_ROTARY_ENCODERS(ITEM_SETUP_RE_NAVIGATION) - ITEM_SETUP_FILTER_ADC, ITEM_SETUP_THROTTLE_REVERSED, ITEM_SETUP_BEEP_LABEL, ITEM_SETUP_MINUTE_BEEP, @@ -144,7 +143,7 @@ void menuGeneralSetup(uint8_t event) } #endif - MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) (uint8_t)-1, 0, 0, IF_AUDIO(0) IF_VOICE(0) IF_HAPTIC((uint8_t)-1) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) IF_PCBSKY9X(0) 0, (uint8_t)-1, 0, IF_PCBSKY9X(0) IF_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) 0, 0, (uint8_t)-1, 0, 0, (uint8_t)-1, 0, 0, 0, IF_SPLASH(0) IF_FRSKY(0) IF_FRSKY(0) 0, (uint8_t)-1, IF_PCBX9D(0) 1/*to force edit mode*/}); + MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) (uint8_t)-1, 0, 0, IF_AUDIO(0) IF_VOICE(0) IF_HAPTIC((uint8_t)-1) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) IF_PCBSKY9X(0) 0, (uint8_t)-1, 0, IF_PCBSKY9X(0) IF_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) 0, (uint8_t)-1, 0, 0, (uint8_t)-1, 0, 0, 0, IF_SPLASH(0) IF_FRSKY(0) IF_FRSKY(0) 0, (uint8_t)-1, IF_PCBX9D(0) 1/*to force edit mode*/}); uint8_t sub = m_posVert - 1; @@ -368,10 +367,6 @@ void menuGeneralSetup(uint8_t event) break; #endif - case ITEM_SETUP_FILTER_ADC: - g_eeGeneral.filterInput = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_FILTERADC, STR_VFILTERADC, g_eeGeneral.filterInput, 0, 1, attr, event); - break; - case ITEM_SETUP_BEEP_LABEL: lcd_putsLeft(y, STR_BEEP_LABEL); break; diff --git a/src/menus.cpp b/src/menus.cpp index f17081773..54c0ce001 100644 --- a/src/menus.cpp +++ b/src/menus.cpp @@ -203,7 +203,7 @@ bool check_submenu_simple(check_event_t event, uint8_t maxrow) #if defined(PCBX9D) void check_rotary_encoder(uint8_t & event) { - if (event==EVT_KEY_REPT(KEY_LEFT) || event==EVT_KEY_BREAK(KEY_LEFT)) { + if (event==EVT_KEY_REPT(KEY_LEFT) || event==EVT_KEY_FIRST(KEY_LEFT)) { scrollRE = -1; } else if (event==EVT_KEY_REPT(KEY_RIGHT) || event==EVT_KEY_FIRST(KEY_RIGHT)) { diff --git a/src/menus.h b/src/menus.h index 988a739d4..1cc38314b 100644 --- a/src/menus.h +++ b/src/menus.h @@ -95,7 +95,12 @@ void menuModelCustomFunctions(uint8_t event); void menuStatisticsView(uint8_t event); void menuStatisticsDebug(uint8_t event); -#if defined(ROTARY_ENCODERS) +#if defined(PCBX9D) +extern int8_t scrollRE; +extern int16_t p1valdiff; +#define IS_RE_NAVIGATION_EVT_TYPE(event, type) (event==type(KEY_ENTER)) +#define IS_RE_NAVIGATION_EVT(event) ((event&EVT_KEY_MASK)==KEY_ENTER) +#elif defined(ROTARY_ENCODERS) extern int8_t scrollRE; extern int16_t p1valdiff; #define IS_RE_NAVIGATION_EVT_TYPE(event, type) (g_eeGeneral.reNavigation && event==type(BTN_REa + g_eeGeneral.reNavigation - 1)) diff --git a/src/model_menus.cpp b/src/model_menus.cpp index d2b1ad6a6..eeb2923e2 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -247,7 +247,9 @@ void menuModelSelect(uint8_t event) int8_t oldSub = m_posVert; if (!check_submenu_simple(_event_, MAX_MODELS-1)) return; -#if defined(ROTARY_ENCODERS) +#if defined(PCBX9D) + if (m_posVert < 0) m_posVert = MAX_MODELS-1; +#elif defined(ROTARY_ENCODERS) if (m_posVert < 0) m_posVert = 0; #endif if (s_editMode > 0) s_editMode = 0; @@ -310,6 +312,12 @@ void menuModelSelect(uint8_t event) #endif case EVT_KEY_LONG(KEY_ENTER): case EVT_KEY_BREAK(KEY_ENTER): +#if defined(PCBX9D) + if (s_editMode < 0) { + s_editMode = 0; + break; + } +#endif s_editMode = 0; if (s_copyMode && (s_copyTgtOfs || s_copySrcRow>=0)) { displayPopup(s_copyMode==COPY_MODE ? STR_COPYINGMODEL : STR_MOVINGMODEL); @@ -378,6 +386,8 @@ void menuModelSelect(uint8_t event) s_copySrcRow = -1; } break; + +#if !defined(PCBX9D) case EVT_KEY_FIRST(KEY_LEFT): case EVT_KEY_FIRST(KEY_RIGHT): if (sub == g_eeGeneral.currModel) { @@ -386,18 +396,25 @@ void menuModelSelect(uint8_t event) } AUDIO_WARNING2(); break; -#if !defined(PCBX9D) - case EVT_KEY_FIRST(KEY_UP): - case EVT_KEY_FIRST(KEY_DOWN): +#endif + + case EVT_KEY_FIRST(KEY_MOVE_UP): + case EVT_KEY_FIRST(KEY_MOVE_DOWN): +#if defined(PCBX9D) + if (s_editMode == -1) { + chainMenu(event == EVT_KEY_FIRST(KEY_RIGHT) ? menuModelSetup : menuTabModel[DIM(menuTabModel)-1]); + return; + } +#endif if (s_copyMode) { - int8_t next_ofs = (event == EVT_KEY_FIRST(KEY_UP) ? s_copyTgtOfs+1 : s_copyTgtOfs-1); + int8_t next_ofs = (event == EVT_KEY_FIRST(KEY_MOVE_UP) ? s_copyTgtOfs+1 : s_copyTgtOfs-1); if (next_ofs == MAX_MODELS || next_ofs == -MAX_MODELS) next_ofs = 0; if (s_copySrcRow < 0 && s_copyMode==COPY_MODE) { s_copySrcRow = oldSub; // find a hole (in the first empty slot above / below) - m_posVert = eeFindEmptyModel(s_copySrcRow, event==EVT_KEY_FIRST(KEY_DOWN)); + m_posVert = eeFindEmptyModel(s_copySrcRow, event==EVT_KEY_FIRST(KEY_MOVE_DOWN)); if ((uint8_t)m_posVert == 0xff) { // no free room for duplicating the model AUDIO_ERROR(); @@ -410,7 +427,7 @@ void menuModelSelect(uint8_t event) s_copyTgtOfs = next_ofs; } break; -#endif + } #if !defined(PCBSKY9X) diff --git a/src/open9x.cpp b/src/open9x.cpp index 15aebf730..43624921b 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -1172,7 +1172,7 @@ void doSplash() lcdSetRefVolt(contrast); #endif - getADC_single(); // init ADC array + getADC(); // init ADC array uint16_t inacSum = stickMoveValue(); @@ -1185,7 +1185,7 @@ void doSplash() CoTickDelay(1); #endif - getADC_single(); + getADC(); uint16_t tsum = stickMoveValue(); @@ -1243,7 +1243,7 @@ void checkTHR() #ifdef SIMU int16_t lowLim = THRCHK_DEADBAND - 1024 ; #else - getADC_single(); // if thr is down - do not display warning at all + getADC(); // if thr is down - do not display warning at all int16_t lowLim = g_eeGeneral.calibMid[thrchn]; lowLim = (g_eeGeneral.throttleReversed ? - lowLim - g_eeGeneral.calibSpanPos[thrchn] : lowLim - g_eeGeneral.calibSpanNeg[thrchn]); lowLim += THRCHK_DEADBAND; @@ -1259,7 +1259,7 @@ void checkTHR() { SIMU_SLEEP(1); - getADC_single(); + getADC(); int16_t v = thrAnaIn(thrchn); @@ -1539,51 +1539,34 @@ uint16_t anaIn(uint8_t chan) } #if defined(PCBSKY9X) - -void getADC_osmp() +void getADC() { register uint32_t x; register uint32_t y; - uint16_t temp[NUMBER_ANALOG]; + uint16_t temp[NUMBER_ANALOG] = { 0 }; - for( x = 0; x < NUMBER_ANALOG; x += 1 ) - { - temp[x] = 0; - } - for( y = 0; y < 4; y += 1 ) - { + for( y = 0; y < 4; y += 1 ) { read_9_adc(); for( x = 0; x < NUMBER_ANALOG; x += 1 ) { temp[x] += Analog_values[x]; } } + for( x = 0; x < NUMBER_ANALOG; x += 1 ) { s_anaFilt[x] = temp[x] >> 3; } } - -void getADC_single() -{ - register uint32_t x ; - - read_9_adc() ; - - for( x = 0 ; x < NUMBER_ANALOG ; x += 1 ) - { - s_anaFilt[x] = Analog_values[x] >> 1 ; - } -} #else -void getADC_osmp() +void getADC() { uint16_t temp_ana; for (uint8_t adc_input=0; adc_input<8; adc_input++) { temp_ana = 0; ADMUX = adc_input|ADC_VREF_TYPE; - for (uint8_t i=0; i<4;i++) { // Going from 10bits to 11 bits. Addition = n. Loop 4^n times + for (uint8_t i=0; i<2;i++) { // Going from 10bits to 11 bits. // Start the AD conversion ADCSRA|=0x40; // Wait for the AD conversion to complete @@ -1591,22 +1574,9 @@ void getADC_osmp() ADCSRA|=0x10; temp_ana += ADC; } - s_anaFilt[adc_input] = temp_ana / 2; // divide by 2^n to normalize result. + s_anaFilt[adc_input] = temp_ana; } } - -void getADC_single() -{ - for (uint8_t adc_input=0; adc_input<8; adc_input++) { - ADMUX=adc_input|ADC_VREF_TYPE; - // Start the AD conversion - ADCSRA|=0x40; - // Wait for the AD conversion to complete - while ((ADCSRA & 0x10)==0); - ADCSRA|=0x10; - s_anaFilt[adc_input]= ADC * 2; // use 11 bit numbers - } -} #endif #if !defined(PCBSKY9X) @@ -2544,10 +2514,7 @@ FORCEINLINE void doMixerCalculations() activeMixes = 0; #endif - if (g_eeGeneral.filterInput == 0) - getADC_single(); - else - getADC_osmp(); + getADC(); #if defined(PCBSKY9X) && defined(REVB) && !defined(SIMU) Current_analogue = ( Current_analogue * 31 + s_anaFilt[8] ) >> 5 ; diff --git a/src/open9x.h b/src/open9x.h index 74e307f69..47e8e2622 100644 --- a/src/open9x.h +++ b/src/open9x.h @@ -898,8 +898,7 @@ void checkAll(); #define GETADC_FILT = 2 #if !defined(SIMU) -void getADC_single(); -void getADC_osmp(); +void getADC(); #endif extern uint8_t s_eeDirtyMsk; diff --git a/src/simpgmspace.h b/src/simpgmspace.h index 8d83288ba..2299601ae 100644 --- a/src/simpgmspace.h +++ b/src/simpgmspace.h @@ -280,9 +280,7 @@ extern uint8_t portb, portc, porth, dummyport; extern uint16_t dummyport16; extern uint8_t main_thread_running; -#define getADC_single() -#define getADC_osmp() -#define getADC_bandgap() +#define getADC() #define SIMU_SLEEP(x) do { if (!main_thread_running) return; sleep(x/*ms*/); } while (0) diff --git a/src/translations.cpp b/src/translations.cpp index dd4222ee5..08388cd6c 100644 --- a/src/translations.cpp +++ b/src/translations.cpp @@ -48,7 +48,6 @@ const pm_char STR_OPEN9X[] PROGMEM = ISTR(VRENAVIG) ISTR(VRENCODERS) #endif - ISTR(VFILTERADC) ISTR(TRNMODE) ISTR(TRNCHN) ISTR(VTRIMINC) @@ -180,7 +179,6 @@ const pm_char STR_ALARMWARNING[] PROGMEM = TR_ALARMWARNING; #if defined(ROTARY_ENCODERS) const pm_char STR_RENAVIG[] PROGMEM = TR_RENAVIG; #endif -const pm_char STR_FILTERADC[] PROGMEM = TR_FILTERADC; const pm_char STR_THROTTLEREVERSE[] PROGMEM = TR_THROTTLEREVERSE; const pm_char STR_BEEP_LABEL[] PROGMEM = TR_BEEP_LABEL; const pm_char STR_MINUTEBEEP[] PROGMEM = TR_MINUTEBEEP; diff --git a/src/translations.h b/src/translations.h index c6aad0f45..141e051d8 100644 --- a/src/translations.h +++ b/src/translations.h @@ -78,11 +78,10 @@ extern const pm_char STR_OPEN9X[]; #if defined(ROTARY_ENCODERS) #define OFS_VRENAVIG (OFS_VBEEPMODE + sizeof(TR_VBEEPMODE)) #define OFS_VRENCODERS (OFS_VRENAVIG + sizeof(TR_VRENAVIG)) -#define OFS_VFILTERADC (OFS_VRENCODERS + sizeof(TR_VRENCODERS)) +#define OFS_TRNMODE (OFS_VRENCODERS + sizeof(TR_VRENCODERS)) #else -#define OFS_VFILTERADC (OFS_VBEEPMODE + sizeof(TR_VBEEPMODE)) +#define OFS_TRNMODE (OFS_VBEEPMODE + sizeof(TR_VBEEPMODE)) #endif -#define OFS_TRNMODE (OFS_VFILTERADC + sizeof(TR_VFILTERADC)) #define OFS_TRNCHN (OFS_TRNMODE + sizeof(TR_TRNMODE)) #define OFS_VTRIMINC (OFS_TRNCHN + sizeof(TR_TRNCHN)) #define OFS_RETA123 (OFS_VTRIMINC + sizeof(TR_VTRIMINC)) @@ -147,7 +146,6 @@ extern const pm_char STR_OPEN9X[]; #define STR_VBEEPLEN (STR_OPEN9X + OFS_VBEEPLEN) #endif #define STR_VBEEPMODE (STR_OPEN9X + OFS_VBEEPMODE) -#define STR_VFILTERADC (STR_OPEN9X + OFS_VFILTERADC) #define STR_TRNMODE (STR_OPEN9X + OFS_TRNMODE) #define STR_TRNCHN (STR_OPEN9X + OFS_TRNCHN) #define STR_VTRIMINC (STR_OPEN9X + OFS_VTRIMINC) @@ -289,7 +287,6 @@ extern const pm_char STR_INACTIVITYALARM[]; extern const pm_char STR_MEMORYWARNING[]; extern const pm_char STR_ALARMWARNING[]; extern const pm_char STR_RENAVIG[]; -extern const pm_char STR_FILTERADC[]; extern const pm_char STR_THROTTLEREVERSE[]; extern const pm_char STR_BEEP_LABEL[]; extern const pm_char STR_MINUTEBEEP[]; diff --git a/src/translations/cz.h b/src/translations/cz.h index 80df2f4e2..36adc5688 100644 --- a/src/translations/cz.h +++ b/src/translations/cz.h @@ -17,9 +17,6 @@ #define LEN_VRENAVIG "\003" #define TR_VRENAVIG "Ne REaREb" -#define LEN_VFILTERADC "\004" -#define TR_VFILTERADC "SING""OSMP" - #define LEN_VBLMODE "\005" #define TR_VBLMODE "Vyp\0 ""Kl\200v.""P\200ky\0""Kl+P\200""Zap\0 " @@ -309,7 +306,6 @@ #define TR_MEMORYWARNING INDENT"Pln\200 Pam\203t'" #define TR_ALARMWARNING INDENT"Vypnut\212 Zvuk" #define TR_RENAVIG "Navig. RotEnc" -#define TR_FILTERADC "Filtr ADC" #define TR_THROTTLEREVERSE "Revers Plynu" #define TR_BEEP_LABEL "Upozorn\203n\204 Stopek" #define TR_MINUTEBEEP INDENT"Cel\200 minuta" diff --git a/src/translations/de.h b/src/translations/de.h index 0dc28d343..a96e6f5fe 100644 --- a/src/translations/de.h +++ b/src/translations/de.h @@ -17,9 +17,6 @@ #define LEN_VRENAVIG "\003" #define TR_VRENAVIG "AUSDGaDGb" -#define LEN_VFILTERADC "\004" -#define TR_VFILTERADC "SING""OSMP" - #define LEN_VBLMODE "\004" #define TR_VBLMODE "OFF ""Tast""Knpl""Alle""ON\0" @@ -310,7 +307,6 @@ #define TR_MEMORYWARNING INDENT"Speicher voll" #define TR_ALARMWARNING INDENT"Ton aus" #define TR_RENAVIG "Drehgeb. Navig." -#define TR_FILTERADC "ADC Filter" #define TR_THROTTLEREVERSE "Gasumkehrung" #define TR_BEEP_LABEL "Stoppuhrpieper" #define TR_MINUTEBEEP INDENT"Minuten" diff --git a/src/translations/en.h b/src/translations/en.h index 755239b9d..cdf4d8a5c 100644 --- a/src/translations/en.h +++ b/src/translations/en.h @@ -17,9 +17,6 @@ #define LEN_VRENAVIG "\003" #define TR_VRENAVIG "No REaREb" -#define LEN_VFILTERADC "\004" -#define TR_VFILTERADC "SING""OSMP" - #define LEN_VBLMODE "\004" #define TR_VBLMODE "OFF ""Keys""Stks""Both""ON\0" @@ -321,7 +318,6 @@ #define TR_MEMORYWARNING INDENT"Memory Low" #define TR_ALARMWARNING INDENT"Sound Off" #define TR_RENAVIG "RotEnc Navig" -#define TR_FILTERADC "ADC Filter" #define TR_THROTTLEREVERSE "Thr reverse" #define TR_BEEP_LABEL "Timer events" #define TR_MINUTEBEEP INDENT"Minute" diff --git a/src/translations/es.h b/src/translations/es.h index 85c9a9c83..2e73968ad 100644 --- a/src/translations/es.h +++ b/src/translations/es.h @@ -17,9 +17,6 @@ #define LEN_VRENAVIG "\003" #define TR_VRENAVIG "No REaREb" -#define LEN_VFILTERADC "\004" -#define TR_VFILTERADC "SIMP""OSMP" - #define LEN_VBLMODE "\004" #define TR_VBLMODE "OFF ""Keys""Stks""Dos ""ON\0" @@ -300,7 +297,6 @@ #define TR_BATTERYWARNING "Aviso Bateria" #define TR_INACTIVITYALARM "Alarma Reposo" #define TR_RENAVIG "Navig RotEnc" -#define TR_FILTERADC "Filtro ADC" #define TR_THROTTLEREVERSE "Inversion Acel." #define TR_BEEP_LABEL "Timer events" #define TR_MINUTEBEEP "Pitido/minuto" diff --git a/src/translations/fr.h b/src/translations/fr.h index dd913fbc2..3231c38bd 100644 --- a/src/translations/fr.h +++ b/src/translations/fr.h @@ -17,9 +17,6 @@ #define LEN_VRENAVIG "\003" #define TR_VRENAVIG "NonREaREb" -#define LEN_VFILTERADC "\004" -#define TR_VFILTERADC "SIMP""OSMP" - #define LEN_VBLMODE "\004" #define TR_VBLMODE "OFF\0""Btns""Stks""Tout""ON\0" @@ -310,7 +307,6 @@ #define TR_MEMORYWARNING INDENT"M\200moire faible" #define TR_ALARMWARNING INDENT"Sons d\200sactiv\200s" #define TR_RENAVIG "Navig EncRot" -#define TR_FILTERADC "Filtre ADC" #define TR_THROTTLEREVERSE "Inversion Gaz" #define TR_BEEP_LABEL "Bips Chronos" #define TR_MINUTEBEEP INDENT"Minutes" diff --git a/src/translations/it.h b/src/translations/it.h index 9804bbbed..7c7a00852 100644 --- a/src/translations/it.h +++ b/src/translations/it.h @@ -16,9 +16,6 @@ #define LEN_VRENAVIG "\003" #define TR_VRENAVIG "No REaREb" -#define LEN_VFILTERADC "\004" -#define TR_VFILTERADC "SING""OSMP" - #define LEN_VBLMODE "\004" #define TR_VBLMODE "OFF ""Tast""Stks""Tutt""ON\0" @@ -308,7 +305,6 @@ #define TR_MEMORYWARNING INDENT"Avviso memoria" #define TR_ALARMWARNING INDENT"Spento" #define TR_RENAVIG "Navig RotEnc " -#define TR_FILTERADC "Filtro ADC" #define TR_THROTTLEREVERSE "Thr inverso" #define TR_BEEP_LABEL "Timer events" #define TR_MINUTEBEEP INDENT"Minuto" diff --git a/src/translations/pt.h b/src/translations/pt.h index b8d4c8ab1..785b012ec 100644 --- a/src/translations/pt.h +++ b/src/translations/pt.h @@ -17,9 +17,6 @@ #define LEN_VRENAVIG "\003" #define TR_VRENAVIG "No REaREb" -#define LEN_VFILTERADC "\004" -#define TR_VFILTERADC "SIMP""OSMP" - #define LEN_VBLMODE "\004" #define TR_VBLMODE "OFF ""Chav""Stks""Tudo""ON\0" @@ -310,7 +307,6 @@ #define TR_MEMORYWARNING INDENT"Memoria Baixa" #define TR_ALARMWARNING INDENT"Som Off" #define TR_RENAVIG "RotEnc Navig" -#define TR_FILTERADC "Filtro ADC " #define TR_THROTTLEREVERSE "Inverte Acel." #define TR_BEEP_LABEL "Beep Cronom." #define TR_MINUTEBEEP INDENT"Beep Minuto" diff --git a/src/translations/se.h b/src/translations/se.h index 9acb15159..ced0e4a37 100644 --- a/src/translations/se.h +++ b/src/translations/se.h @@ -17,9 +17,6 @@ #define LEN_VRENAVIG "\003" #define TR_VRENAVIG "No REaREb" -#define LEN_VFILTERADC "\004" -#define TR_VFILTERADC "SING""OSMP" - #define LEN_VBLMODE "\004" #define TR_VBLMODE "AV ""Knpp""Spak""B\200da""P\203 " @@ -313,7 +310,6 @@ #define TR_MEMORYWARNING INDENT"Lite Minne" #define TR_ALARMWARNING INDENT"Ljud AV" #define TR_RENAVIG "RotEnc Navig" -#define TR_FILTERADC "ADC-filter" #define TR_THROTTLEREVERSE "Reverserad Gas" #define TR_BEEP_LABEL "Pip" #define TR_MINUTEBEEP INDENT"Varje Minut"