diff --git a/src/general_menus.cpp b/src/general_menus.cpp index c6fdf8b9c..447e2c558 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -139,21 +139,15 @@ enum menuGeneralSetupItems { ITEM_SETUP_MAX }; - void menuGeneralSetup(uint8_t event) { #if defined(RTCLOCK) - static struct gtm t; - if (m_posVert==ITEM_SETUP_DATE+1 || m_posVert!=ITEM_SETUP_TIME+1) { - if (s_editMode<=0 && event == EVT_KEY_FIRST(KEY_ENTER)) { - // set the date and time into RTC chip - rtc_settime(&t); - g_rtcTime = gmktime(t); // update local timestamp and get wday calculated - g_ms100 = 0; // start of next second begins now - } - } - else if (s_editMode<=0) { - gettime(&t); + struct gtm t; + gettime(&t); + + if ((m_posVert==ITEM_SETUP_DATE+1 || m_posVert==ITEM_SETUP_TIME+1) && s_editMode>0 && event == EVT_KEY_FIRST(KEY_ENTER)) { + // set the date and time into RTC chip + rtc_settime(&t); } #endif @@ -186,7 +180,7 @@ void menuGeneralSetup(uint8_t event) case 2: { int16_t year = 1900 + t.tm_year; - int8_t dlim = (((((year%4==0) && (year %100!=0)) || (year%400==0)) && (t.tm_mon==1)) ? 1 : 0); + int8_t dlim = (((((year%4==0) && (year%100!=0)) || (year%400==0)) && (t.tm_mon==1)) ? 1 : 0); int8_t dmon[] = {31,28,31,30,31,30,31,31,30,31,30,31}; // TODO in flash dlim += dmon[t.tm_mon]; lcd_outdezNAtt(RADIO_SETUP_DATE_COLUMN+6*FW-2, y, t.tm_mday, rowattr|LEADING0, 2); @@ -195,6 +189,8 @@ void menuGeneralSetup(uint8_t event) } } } + if (attr && checkIncDec_Ret) + g_rtcTime = gmktime(&t); // update local timestamp and get wday calculated break; case ITEM_SETUP_TIME: @@ -217,6 +213,8 @@ void menuGeneralSetup(uint8_t event) break; } } + if (attr && checkIncDec_Ret) + g_rtcTime = gmktime(&t); // update local timestamp and get wday calculated break; #endif @@ -297,8 +295,7 @@ void menuGeneralSetup(uint8_t event) lcd_putsLeft(y, STR_BRIGHTNESS); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, 100-g_eeGeneral.backlightBright, attr|LEFT) ; if(attr) { - uint8_t b ; - b = 100 - g_eeGeneral.backlightBright; + uint8_t b = 100 - g_eeGeneral.backlightBright; CHECK_INCDEC_GENVAR(event, b, 0, 100); g_eeGeneral.backlightBright = 100 - b; } diff --git a/src/menus.cpp b/src/menus.cpp index a343db42b..4bd914970 100644 --- a/src/menus.cpp +++ b/src/menus.cpp @@ -79,6 +79,7 @@ void displayScrollbar(xcoord_t x, uint8_t y, uint8_t h, uint16_t offset, uint16_ #if defined(ROTARY_ENCODERS) int8_t scrollRE; int16_t p1valdiff; +int8_t lastCursorMove; #elif defined(NAVIGATION_POT1) int16_t p1valdiff; #endif @@ -205,10 +206,10 @@ bool check_submenu_simple(check_event_t event, uint8_t maxrow) #if defined(PCBX9D) || defined(PCBACT) void check_rotary_encoder(uint8_t & event) { - if (event==EVT_KEY_REPT(KEY_MOVE_UP) || event==EVT_KEY_FIRST(KEY_MOVE_UP)) { + if (lastCursorMove < -1 || event==EVT_KEY_REPT(KEY_MOVE_UP) || event==EVT_KEY_FIRST(KEY_MOVE_UP)) { scrollRE = -1; } - else if (event==EVT_KEY_REPT(KEY_MOVE_DOWN) || event==EVT_KEY_FIRST(KEY_MOVE_DOWN)) { + else if (lastCursorMove > 1 || event==EVT_KEY_REPT(KEY_MOVE_DOWN) || event==EVT_KEY_FIRST(KEY_MOVE_DOWN)) { scrollRE = 1; } else { @@ -414,11 +415,13 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t } #if defined(ROTARY_ENCODERS) + lastCursorMove = 0; while (!s_editMode && scrollRE) { if (scrollRE > 0) { --scrollRE; maxcol = MAXCOL(l_posVert); if (maxcol & ZCHAR) maxcol = 0; + lastCursorMove = +1; if (++l_posHorz > maxcol) { if (l_posVert < maxrow) { do { @@ -441,6 +444,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t } else { ++scrollRE; + lastCursorMove = -1; if (l_posHorz-- == 0) { do { --l_posVert; diff --git a/src/menus.h b/src/menus.h index a83d1e8f5..2618aa5a6 100644 --- a/src/menus.h +++ b/src/menus.h @@ -99,12 +99,14 @@ void menuStatisticsDebug(uint8_t event); #if defined(PCBX9D) extern int8_t scrollRE; extern int16_t p1valdiff; +extern int8_t lastCursorMove; #define IS_RE_NAVIGATION_ENABLE() true #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; +extern int8_t lastCursorMove; #define IS_RE_NAVIGATION_ENABLE() g_eeGeneral.reNavigation #define IS_RE_NAVIGATION_EVT_TYPE(event, type) (g_eeGeneral.reNavigation && event==type(BTN_REa + g_eeGeneral.reNavigation - 1)) #define IS_RE_NAVIGATION_EVT(event) (g_eeGeneral.reNavigation && (event&EVT_KEY_MASK)==(BTN_REa + g_eeGeneral.reNavigation - 1)) @@ -134,11 +136,11 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max); var = checkIncDecModel(event,var,min,max) #if defined(AUTOSWITCH) -#define AUTOSWITCH_MENU_LONG() (attr && event==EVT_KEY_LONG(KEY_MENU)) +#define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER)) #define CHECK_INCDEC_MODELSWITCH(event, var, min, max) \ var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH) #else -#define AUTOSWITCH_MENU_LONG() (0) +#define AUTOSWITCH_ENTER_LONG() (0) #define CHECK_INCDEC_MODELSWITCH CHECK_INCDEC_MODELVAR #endif @@ -255,4 +257,14 @@ void menuChannelsMonitor(uint8_t event); #define LABEL(...) (uint8_t)-1 +#if defined(ROTARY_ENCODERS) +#define CURSOR_MOVED_LEFT(event) ((event & EVT_KEY_MASK) == KEY_LEFT || lastCursorMove < 0) +#define CURSOR_MOVED_RIGHT(event) ((event & EVT_KEY_MASK) == KEY_RIGHT || lastCursorMove > 0) +#define REPEAT_LAST_CURSOR_MOVE() if (lastCursorMove) lastCursorMove *= 2; else m_posHorz = 0 +#else +#define CURSOR_MOVED_LEFT(event) ((event & EVT_KEY_MASK) == KEY_LEFT) +#define CURSOR_MOVED_RIGHT(event) ((event & EVT_KEY_MASK) == KEY_RIGHT) +#define REPEAT_LAST_CURSOR_MOVE() m_posHorz = 0; +#endif + #endif diff --git a/src/model_menus.cpp b/src/model_menus.cpp index 040f2c480..f21d61522 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -2814,7 +2814,19 @@ void menuModelCustomSwitches(uint8_t event) } #endif -#define MODEL_CUSTOM_FUNC_3RD_COLUMN (15*FW+2) +#if LCD >= 212 +#define MODEL_CUSTOM_FUNC_2ND_COLUMN (6*FW-2) +#define MODEL_CUSTOM_FUNC_3RD_COLUMN (20*FW+2) +#define MODEL_CUSTOM_FUNC_4TH_COLUMN (25*FW) +#elif defined(GRAPHICS) +#define MODEL_CUSTOM_FUNC_2ND_COLUMN (5*FW-2) +#define MODEL_CUSTOM_FUNC_3RD_COLUMN (15*FW+2) +#define MODEL_CUSTOM_FUNC_4TH_COLUMN (20*FW) +#else +#define MODEL_CUSTOM_FUNC_2ND_COLUMN (5*FW-2) +#define MODEL_CUSTOM_FUNC_3RD_COLUMN (15*FW+2) +#define MODEL_CUSTOM_FUNC_4TH_COLUMN (18*FW+2) +#endif void menuModelCustomFunctions(uint8_t event) { @@ -2845,26 +2857,30 @@ void menuModelCustomFunctions(uint8_t event) if (sd->swtch > MAX_SWITCH+1) sd->swtch -= (MAX_SWITCH+1); if (sd->swtch < -MAX_SWITCH-1) sd->swtch += (MAX_SWITCH+1); } + // printf("ICI switch=%d [%d:%d]\n", sd->swtch, SWITCH_OFF-MAX_SWITCH, SWITCH_ON+MAX_SWITCH+1+2*MAX_PSWITCH); fflush(stdout); putsSwitches(3, y, sd->swtch, SWONOFF | attr | ((abs(sd->swtch) <= (MAX_SWITCH+1) && getSwitch(sd->swtch, 0) && (sd->func > FUNC_INSTANT_TRIM || sd->active)) ? BOLD : 0)); - if (active || AUTOSWITCH_MENU_LONG()) { -#if defined(CPUARM) + if (active || AUTOSWITCH_ENTER_LONG()) { +#if defined(PCBX9D) + CHECK_INCDEC_MODELSWITCH(event, sd->swtch, -127, +127); +#elif defined(CPUARM) CHECK_INCDEC_MODELSWITCH(event, sd->swtch, SWITCH_OFF-MAX_SWITCH, SWITCH_ON+MAX_SWITCH+1+2*MAX_PSWITCH); #else CHECK_INCDEC_MODELSWITCH(event, sd->swtch, SWITCH_OFF-MAX_SWITCH, SWITCH_ON+MAX_SWITCH+1); #endif } break; + case 1: if (sd->swtch) { uint8_t func_displayed; if (sd->func < FUNC_TRAINER) { func_displayed = 0; - putsChnRaw(11*FW-2, y, NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+2+3+NUM_PPM+sd->func+1, attr); + putsChn(MODEL_CUSTOM_FUNC_2ND_COLUMN+6*FW, y, sd->func+1, attr); } else if (sd->func < 16 + NUM_STICKS + 1) { func_displayed = 1; if (sd->func != FUNC_TRAINER) - putsChnRaw(13*FW-2, y, sd->func-FUNC_TRAINER, attr); + putsChnRaw(MODEL_CUSTOM_FUNC_2ND_COLUMN+8*FW, y, sd->func-FUNC_TRAINER, attr); } #if defined(DEBUG) else if (sd->func == FUNC_TEST) { @@ -2878,22 +2894,23 @@ void menuModelCustomFunctions(uint8_t event) #if defined(GVARS) else if (sd->func >= FUNC_ADJUST_GV1) { func_displayed = FUNC_ADJUST_GV1 - 16 - NUM_STICKS + 1; - putsStrIdx(12*FW-2, y, STR_GV, sd->func-FUNC_ADJUST_GV1+1, attr); + putsStrIdx(MODEL_CUSTOM_FUNC_2ND_COLUMN+7*FW, y, STR_GV, sd->func-FUNC_ADJUST_GV1+1, attr); } #endif else { func_displayed = 2 + sd->func - 16 - NUM_STICKS - 1; } - lcd_putsiAtt(5*FW-2, y, STR_VFSWFUNC, func_displayed, attr); + lcd_putsiAtt(MODEL_CUSTOM_FUNC_2ND_COLUMN, y, STR_VFSWFUNC, func_displayed, attr); if (active) { CHECK_INCDEC_MODELVAR(event, sd->func, 0, FUNC_MAX-1); if (checkIncDec_Ret) FSW_RESET_PARAM(sd); } } else if (attr) { - m_posHorz = 0; + REPEAT_LAST_CURSOR_MOVE(); } break; + case 2: if (sd->swtch) { int16_t val_displayed = FSW_PARAM(sd); @@ -2979,7 +2996,7 @@ void menuModelCustomFunctions(uint8_t event) } #endif else { - if (attr) m_posHorz = ((event & EVT_KEY_MASK) == KEY_LEFT ? 1 : 3); + if (attr) m_posHorz = (CURSOR_MOVED_LEFT(event) ? 1 : 3); break; } @@ -2988,21 +3005,17 @@ void menuModelCustomFunctions(uint8_t event) } } else if (attr) { - m_posHorz = 0; + REPEAT_LAST_CURSOR_MOVE(); } break; case 3: if (sd->swtch && sd->func <= FUNC_INSTANT_TRIM) { -#if defined(GRAPHICS) - menu_lcd_onoff(20*FW, y, sd->active, attr); -#else - menu_lcd_onoff(18*FW+2, y, sd->active, attr) ; -#endif + menu_lcd_onoff(MODEL_CUSTOM_FUNC_4TH_COLUMN, y, sd->active, attr); if (active) CHECK_INCDEC_MODELVAR(event, sd->active, 0, 1); } else if (attr) { - m_posHorz = 0; + REPEAT_LAST_CURSOR_MOVE(); } break; } diff --git a/src/open9x.cpp b/src/open9x.cpp index 26929cb14..4dcb387b8 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -1196,12 +1196,17 @@ void backlightOn() #define SPLASH_NEEDED() (!IS_DSM2_PROTOCOL(g_model.protocol) && !g_eeGeneral.splashMode) +inline void Splash() +{ + lcd_clear(); + lcd_img(0, 0, splash_lbm, 0, 0); + lcdRefresh(); +} + void doSplash() { if (SPLASH_NEEDED()) { - lcd_clear(); - lcd_img(0, 0, splash_lbm, 0, 0); - lcdRefresh(); + Splash(); #if !defined(CPUARM) AUDIO_TADA(); @@ -1209,7 +1214,7 @@ void doSplash() #if defined(PCBSTD) lcdSetContrast(); -#else +#elif !defined(PCBX9D) tmr10ms_t curTime = get_tmr10ms() + 10; uint8_t contrast = 10; lcdSetRefVolt(contrast); @@ -1239,7 +1244,7 @@ void doSplash() if (check_soft_power()==e_power_off) return; -#if !defined(PCBSTD) +#if !defined(PCBSTD) && !defined(PCBX9D) if (curTime < get_tmr10ms()) { curTime += 10; if (contrast < g_eeGeneral.contrast) { @@ -3402,6 +3407,10 @@ uint16_t stack_free() inline void open9xInit(OPEN9X_INIT_ARGS) { +#if defined(PCBX9D) + Splash(); +#endif + eeReadAll(); #if defined(CPUARM) diff --git a/src/x9d/audio_driver.cpp b/src/x9d/audio_driver.cpp index 1c92fe8eb..15a3531a6 100644 --- a/src/x9d/audio_driver.cpp +++ b/src/x9d/audio_driver.cpp @@ -184,7 +184,7 @@ void audioInit() /* Initialize the I2S peripheral with the structure above */ I2S_Init(CODEC_I2S, &I2S_InitStructure); - I2S_Cmd(CODEC_I2S,ENABLE); + I2S_Cmd(CODEC_I2S, ENABLE); //interrupt #ifdef CODEC_USE_INT SPI_I2S_ITConfig(CODEC_I2S,SPI_I2S_IT_TXE,ENABLE); diff --git a/src/x9d/keys_driver.cpp b/src/x9d/keys_driver.cpp index 2d5270392..b01684505 100644 --- a/src/x9d/keys_driver.cpp +++ b/src/x9d/keys_driver.cpp @@ -105,12 +105,14 @@ void readKeysAndTrims() ++enuk; } +#if !defined(SIMU) in = readTrims(); for (i = 1; i < 256; i <<= 1) { keys[enuk].input(in & i, (EnumKeys)enuk); ++enuk; } +#endif } uint32_t keyState(EnumKeys enuk)