[X9D] Navigation in CustomFunctions menu

This commit is contained in:
bsongis
2013-01-13 07:45:10 +00:00
parent af344a3687
commit 4cb48022a2
7 changed files with 78 additions and 41 deletions
+12 -15
View File
@@ -139,21 +139,15 @@ enum menuGeneralSetupItems {
ITEM_SETUP_MAX ITEM_SETUP_MAX
}; };
void menuGeneralSetup(uint8_t event) void menuGeneralSetup(uint8_t event)
{ {
#if defined(RTCLOCK) #if defined(RTCLOCK)
static struct gtm t; struct gtm t;
if (m_posVert==ITEM_SETUP_DATE+1 || m_posVert!=ITEM_SETUP_TIME+1) { gettime(&t);
if (s_editMode<=0 && event == EVT_KEY_FIRST(KEY_ENTER)) {
// set the date and time into RTC chip if ((m_posVert==ITEM_SETUP_DATE+1 || m_posVert==ITEM_SETUP_TIME+1) && s_editMode>0 && event == EVT_KEY_FIRST(KEY_ENTER)) {
rtc_settime(&t); // set the date and time into RTC chip
g_rtcTime = gmktime(t); // update local timestamp and get wday calculated rtc_settime(&t);
g_ms100 = 0; // start of next second begins now
}
}
else if (s_editMode<=0) {
gettime(&t);
} }
#endif #endif
@@ -186,7 +180,7 @@ void menuGeneralSetup(uint8_t event)
case 2: case 2:
{ {
int16_t year = 1900 + t.tm_year; 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 int8_t dmon[] = {31,28,31,30,31,30,31,31,30,31,30,31}; // TODO in flash
dlim += dmon[t.tm_mon]; dlim += dmon[t.tm_mon];
lcd_outdezNAtt(RADIO_SETUP_DATE_COLUMN+6*FW-2, y, t.tm_mday, rowattr|LEADING0, 2); 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; break;
case ITEM_SETUP_TIME: case ITEM_SETUP_TIME:
@@ -217,6 +213,8 @@ void menuGeneralSetup(uint8_t event)
break; break;
} }
} }
if (attr && checkIncDec_Ret)
g_rtcTime = gmktime(&t); // update local timestamp and get wday calculated
break; break;
#endif #endif
@@ -297,8 +295,7 @@ void menuGeneralSetup(uint8_t event)
lcd_putsLeft(y, STR_BRIGHTNESS); lcd_putsLeft(y, STR_BRIGHTNESS);
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, 100-g_eeGeneral.backlightBright, attr|LEFT) ; lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, 100-g_eeGeneral.backlightBright, attr|LEFT) ;
if(attr) { if(attr) {
uint8_t b ; uint8_t b = 100 - g_eeGeneral.backlightBright;
b = 100 - g_eeGeneral.backlightBright;
CHECK_INCDEC_GENVAR(event, b, 0, 100); CHECK_INCDEC_GENVAR(event, b, 0, 100);
g_eeGeneral.backlightBright = 100 - b; g_eeGeneral.backlightBright = 100 - b;
} }
+6 -2
View File
@@ -79,6 +79,7 @@ void displayScrollbar(xcoord_t x, uint8_t y, uint8_t h, uint16_t offset, uint16_
#if defined(ROTARY_ENCODERS) #if defined(ROTARY_ENCODERS)
int8_t scrollRE; int8_t scrollRE;
int16_t p1valdiff; int16_t p1valdiff;
int8_t lastCursorMove;
#elif defined(NAVIGATION_POT1) #elif defined(NAVIGATION_POT1)
int16_t p1valdiff; int16_t p1valdiff;
#endif #endif
@@ -205,10 +206,10 @@ bool check_submenu_simple(check_event_t event, uint8_t maxrow)
#if defined(PCBX9D) || defined(PCBACT) #if defined(PCBX9D) || defined(PCBACT)
void check_rotary_encoder(uint8_t & event) 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; 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; scrollRE = 1;
} }
else { else {
@@ -414,11 +415,13 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
} }
#if defined(ROTARY_ENCODERS) #if defined(ROTARY_ENCODERS)
lastCursorMove = 0;
while (!s_editMode && scrollRE) { while (!s_editMode && scrollRE) {
if (scrollRE > 0) { if (scrollRE > 0) {
--scrollRE; --scrollRE;
maxcol = MAXCOL(l_posVert); maxcol = MAXCOL(l_posVert);
if (maxcol & ZCHAR) maxcol = 0; if (maxcol & ZCHAR) maxcol = 0;
lastCursorMove = +1;
if (++l_posHorz > maxcol) { if (++l_posHorz > maxcol) {
if (l_posVert < maxrow) { if (l_posVert < maxrow) {
do { do {
@@ -441,6 +444,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
} }
else { else {
++scrollRE; ++scrollRE;
lastCursorMove = -1;
if (l_posHorz-- == 0) { if (l_posHorz-- == 0) {
do { do {
--l_posVert; --l_posVert;
+14 -2
View File
@@ -99,12 +99,14 @@ void menuStatisticsDebug(uint8_t event);
#if defined(PCBX9D) #if defined(PCBX9D)
extern int8_t scrollRE; extern int8_t scrollRE;
extern int16_t p1valdiff; extern int16_t p1valdiff;
extern int8_t lastCursorMove;
#define IS_RE_NAVIGATION_ENABLE() true #define IS_RE_NAVIGATION_ENABLE() true
#define IS_RE_NAVIGATION_EVT_TYPE(event, type) (event==type(KEY_ENTER)) #define IS_RE_NAVIGATION_EVT_TYPE(event, type) (event==type(KEY_ENTER))
#define IS_RE_NAVIGATION_EVT(event) ((event&EVT_KEY_MASK)==KEY_ENTER) #define IS_RE_NAVIGATION_EVT(event) ((event&EVT_KEY_MASK)==KEY_ENTER)
#elif defined(ROTARY_ENCODERS) #elif defined(ROTARY_ENCODERS)
extern int8_t scrollRE; extern int8_t scrollRE;
extern int16_t p1valdiff; extern int16_t p1valdiff;
extern int8_t lastCursorMove;
#define IS_RE_NAVIGATION_ENABLE() g_eeGeneral.reNavigation #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_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)) #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) var = checkIncDecModel(event,var,min,max)
#if defined(AUTOSWITCH) #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) \ #define CHECK_INCDEC_MODELSWITCH(event, var, min, max) \
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH) var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH)
#else #else
#define AUTOSWITCH_MENU_LONG() (0) #define AUTOSWITCH_ENTER_LONG() (0)
#define CHECK_INCDEC_MODELSWITCH CHECK_INCDEC_MODELVAR #define CHECK_INCDEC_MODELSWITCH CHECK_INCDEC_MODELVAR
#endif #endif
@@ -255,4 +257,14 @@ void menuChannelsMonitor(uint8_t event);
#define LABEL(...) (uint8_t)-1 #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 #endif
+29 -16
View File
@@ -2814,7 +2814,19 @@ void menuModelCustomSwitches(uint8_t event)
} }
#endif #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) 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);
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)); 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 (active || AUTOSWITCH_ENTER_LONG()) {
#if defined(CPUARM) #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); CHECK_INCDEC_MODELSWITCH(event, sd->swtch, SWITCH_OFF-MAX_SWITCH, SWITCH_ON+MAX_SWITCH+1+2*MAX_PSWITCH);
#else #else
CHECK_INCDEC_MODELSWITCH(event, sd->swtch, SWITCH_OFF-MAX_SWITCH, SWITCH_ON+MAX_SWITCH+1); CHECK_INCDEC_MODELSWITCH(event, sd->swtch, SWITCH_OFF-MAX_SWITCH, SWITCH_ON+MAX_SWITCH+1);
#endif #endif
} }
break; break;
case 1: case 1:
if (sd->swtch) { if (sd->swtch) {
uint8_t func_displayed; uint8_t func_displayed;
if (sd->func < FUNC_TRAINER) { if (sd->func < FUNC_TRAINER) {
func_displayed = 0; 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) { else if (sd->func < 16 + NUM_STICKS + 1) {
func_displayed = 1; func_displayed = 1;
if (sd->func != FUNC_TRAINER) 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) #if defined(DEBUG)
else if (sd->func == FUNC_TEST) { else if (sd->func == FUNC_TEST) {
@@ -2878,22 +2894,23 @@ void menuModelCustomFunctions(uint8_t event)
#if defined(GVARS) #if defined(GVARS)
else if (sd->func >= FUNC_ADJUST_GV1) { else if (sd->func >= FUNC_ADJUST_GV1) {
func_displayed = FUNC_ADJUST_GV1 - 16 - NUM_STICKS + 1; 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 #endif
else { else {
func_displayed = 2 + sd->func - 16 - NUM_STICKS - 1; 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) { if (active) {
CHECK_INCDEC_MODELVAR(event, sd->func, 0, FUNC_MAX-1); CHECK_INCDEC_MODELVAR(event, sd->func, 0, FUNC_MAX-1);
if (checkIncDec_Ret) FSW_RESET_PARAM(sd); if (checkIncDec_Ret) FSW_RESET_PARAM(sd);
} }
} }
else if (attr) { else if (attr) {
m_posHorz = 0; REPEAT_LAST_CURSOR_MOVE();
} }
break; break;
case 2: case 2:
if (sd->swtch) { if (sd->swtch) {
int16_t val_displayed = FSW_PARAM(sd); int16_t val_displayed = FSW_PARAM(sd);
@@ -2979,7 +2996,7 @@ void menuModelCustomFunctions(uint8_t event)
} }
#endif #endif
else { else {
if (attr) m_posHorz = ((event & EVT_KEY_MASK) == KEY_LEFT ? 1 : 3); if (attr) m_posHorz = (CURSOR_MOVED_LEFT(event) ? 1 : 3);
break; break;
} }
@@ -2988,21 +3005,17 @@ void menuModelCustomFunctions(uint8_t event)
} }
} }
else if (attr) { else if (attr) {
m_posHorz = 0; REPEAT_LAST_CURSOR_MOVE();
} }
break; break;
case 3: case 3:
if (sd->swtch && sd->func <= FUNC_INSTANT_TRIM) { if (sd->swtch && sd->func <= FUNC_INSTANT_TRIM) {
#if defined(GRAPHICS) menu_lcd_onoff(MODEL_CUSTOM_FUNC_4TH_COLUMN, y, sd->active, attr);
menu_lcd_onoff(20*FW, y, sd->active, attr);
#else
menu_lcd_onoff(18*FW+2, y, sd->active, attr) ;
#endif
if (active) CHECK_INCDEC_MODELVAR(event, sd->active, 0, 1); if (active) CHECK_INCDEC_MODELVAR(event, sd->active, 0, 1);
} }
else if (attr) { else if (attr) {
m_posHorz = 0; REPEAT_LAST_CURSOR_MOVE();
} }
break; break;
} }
+14 -5
View File
@@ -1196,12 +1196,17 @@ void backlightOn()
#define SPLASH_NEEDED() (!IS_DSM2_PROTOCOL(g_model.protocol) && !g_eeGeneral.splashMode) #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() void doSplash()
{ {
if (SPLASH_NEEDED()) { if (SPLASH_NEEDED()) {
lcd_clear(); Splash();
lcd_img(0, 0, splash_lbm, 0, 0);
lcdRefresh();
#if !defined(CPUARM) #if !defined(CPUARM)
AUDIO_TADA(); AUDIO_TADA();
@@ -1209,7 +1214,7 @@ void doSplash()
#if defined(PCBSTD) #if defined(PCBSTD)
lcdSetContrast(); lcdSetContrast();
#else #elif !defined(PCBX9D)
tmr10ms_t curTime = get_tmr10ms() + 10; tmr10ms_t curTime = get_tmr10ms() + 10;
uint8_t contrast = 10; uint8_t contrast = 10;
lcdSetRefVolt(contrast); lcdSetRefVolt(contrast);
@@ -1239,7 +1244,7 @@ void doSplash()
if (check_soft_power()==e_power_off) return; if (check_soft_power()==e_power_off) return;
#if !defined(PCBSTD) #if !defined(PCBSTD) && !defined(PCBX9D)
if (curTime < get_tmr10ms()) { if (curTime < get_tmr10ms()) {
curTime += 10; curTime += 10;
if (contrast < g_eeGeneral.contrast) { if (contrast < g_eeGeneral.contrast) {
@@ -3402,6 +3407,10 @@ uint16_t stack_free()
inline void open9xInit(OPEN9X_INIT_ARGS) inline void open9xInit(OPEN9X_INIT_ARGS)
{ {
#if defined(PCBX9D)
Splash();
#endif
eeReadAll(); eeReadAll();
#if defined(CPUARM) #if defined(CPUARM)
+1 -1
View File
@@ -184,7 +184,7 @@ void audioInit()
/* Initialize the I2S peripheral with the structure above */ /* Initialize the I2S peripheral with the structure above */
I2S_Init(CODEC_I2S, &I2S_InitStructure); I2S_Init(CODEC_I2S, &I2S_InitStructure);
I2S_Cmd(CODEC_I2S,ENABLE); I2S_Cmd(CODEC_I2S, ENABLE);
//interrupt //interrupt
#ifdef CODEC_USE_INT #ifdef CODEC_USE_INT
SPI_I2S_ITConfig(CODEC_I2S,SPI_I2S_IT_TXE,ENABLE); SPI_I2S_ITConfig(CODEC_I2S,SPI_I2S_IT_TXE,ENABLE);
+2
View File
@@ -105,12 +105,14 @@ void readKeysAndTrims()
++enuk; ++enuk;
} }
#if !defined(SIMU)
in = readTrims(); in = readTrims();
for (i = 1; i < 256; i <<= 1) { for (i = 1; i < 256; i <<= 1) {
keys[enuk].input(in & i, (EnumKeys)enuk); keys[enuk].input(in & i, (EnumKeys)enuk);
++enuk; ++enuk;
} }
#endif
} }
uint32_t keyState(EnumKeys enuk) uint32_t keyState(EnumKeys enuk)