From 54d6634a8b76ba4882c9574d67aae3c1ed997503 Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 13 Oct 2011 18:23:01 +0000 Subject: [PATCH] Calibration screen. Bugs and optimizations. --- src/frsky.cpp | 2 +- src/general_menus.cpp | 101 +++++++++++++++++++++++++----------------- src/gruvin9x.cpp | 29 ++++++------ src/gruvin9x.h | 21 ++++----- src/lcd.cpp | 46 +++++++++++++------ src/lcd.h | 6 +-- src/main_views.cpp | 75 ++++++++++++++++--------------- src/menus.cpp | 20 ++++----- src/menus.h | 2 + src/model_menus.cpp | 81 ++++++++++++++++----------------- src/simu.cpp | 4 +- 11 files changed, 212 insertions(+), 175 deletions(-) diff --git a/src/frsky.cpp b/src/frsky.cpp index 5a56c7bd6..a0575617d 100644 --- a/src/frsky.cpp +++ b/src/frsky.cpp @@ -1,5 +1,5 @@ /* - * Authors (alpahbetical order) + * Authors (alphabetical order) * - Bertrand Songis * - Bryan J. Rentoul (Gruvin) * diff --git a/src/general_menus.cpp b/src/general_menus.cpp index d43fe9872..c699fee3c 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -488,65 +488,84 @@ void menuProcDiagAna(uint8_t event) } +const prog_char APM menuWhenDone[] = " [MENU] WHEN DONE " ; + void menuProcDiagCalib(uint8_t event) { - SIMPLE_MENU("CALIBRATION", menuTabDiag, e_Calib, 4); + SIMPLE_MENU("CALIBRATION", menuTabDiag, e_Calib, 1); - int8_t sub = m_posVert ; static int16_t midVals[7]; static int16_t loVals[7]; static int16_t hiVals[7]; + static uint8_t idxState; - for(uint8_t i=0; i<7; i++) { //get low and high vals for sticks and trims + for (uint8_t i=0; i<7; i++) { //get low and high vals for sticks and trims int16_t vt = anaIn(i); - loVals[i] = min(vt,loVals[i]); - hiVals[i] = max(vt,hiVals[i]); + loVals[i] = min(vt, loVals[i]); + hiVals[i] = max(vt, hiVals[i]); //if(i>=4) midVals[i] = (loVals[i] + hiVals[i])/2; } + s_noScroll = idxState; // make sure we don't scroll while calibrating + switch(event) { case EVT_ENTRY: - for(uint8_t i=0; i<7; i++) loVals[i] = 15000; + idxState = 0; break; - case EVT_KEY_BREAK(KEY_DOWN): // !! achtung sub schon umgesetzt - switch(sub) - { - case 2: //get mid - for(uint8_t i=0; i<7; i++)midVals[i] = anaIn(i); - beepKey(); - break; - case 3: - for(uint8_t i=0; i<7; i++) - if(abs(loVals[i]-hiVals[i])>50) { - g_eeGeneral.calibMid[i] = midVals[i]; - int16_t v = midVals[i] - loVals[i]; - g_eeGeneral.calibSpanNeg[i] = v - v/64; - v = hiVals[i] - midVals[i]; - g_eeGeneral.calibSpanPos[i] = v - v/64; - } - int16_t sum=0; - for(uint8_t i=0; i<12;i++) sum+=g_eeGeneral.calibMid[i]; - g_eeGeneral.chkSum = sum; - eeDirty(EE_GENERAL); //eeWriteGeneral(); - beepKey(); - break; + + case EVT_KEY_BREAK(KEY_MENU): + idxState++; + if (idxState==3) { + STORE_GENERALVARS; + idxState = 0; } break; } - for(uint8_t i=1; i<4; i++) - { - uint8_t y=i*FH+FH; - lcd_putsnAtt( 0, y,PSTR("SetMid SetSpanDone ")+7*(i-1),7, - sub==i ? INVERS : 0); - } - for(uint8_t i=0; i<7; i++) - { - uint8_t y=i*FH; - lcd_puts_P( 11*FW, y+1*FH, PSTR("< >")); - lcd_outhex4( 8*FW-3, y+1*FH, sub==2 ? loVals[i] : g_eeGeneral.calibSpanNeg[i]); - lcd_outhex4(12*FW, y+1*FH, sub==1 ? anaIn(i) : (sub==2 ? midVals[i] : g_eeGeneral.calibMid[i])); - lcd_outhex4(17*FW, y+1*FH, sub==2 ? hiVals[i] : g_eeGeneral.calibSpanPos[i]); + + + switch (idxState) { + case 0: + // START CALIBRATION + // [MENU] + lcd_putsnAtt(2*FW, 3*FH, PSTR(" [MENU] TO START "), 18, 0); + break; + + case 1: + // SET MIDPOINT + // [MENU] + lcd_putsnAtt(2*FW, 2*FH, PSTR(" SET MIDPOINT "), 18, s_noScroll ? INVERS : 0); + lcd_putsnAtt(2*FW, 3*FH, menuWhenDone, 18, 0); + + for (uint8_t i=0; i<7; i++) { + loVals[i] = 15000; + hiVals[i] = -15000; + midVals[i] = anaIn(i); + } + break; + + case 2: + // MOVE STICKS/POTS + // [MENU] + lcd_putsnAtt(2*FW, 2*FH, PSTR(" MOVE STICKS/POTS "), 18, s_noScroll ? INVERS : 0); + lcd_putsnAtt(2*FW, 3*FH, menuWhenDone, 18, 0); + + for (uint8_t i=0; i<7; i++) { + if (abs(loVals[i]-hiVals[i])>50) { + g_eeGeneral.calibMid[i] = midVals[i]; + int16_t v = midVals[i] - loVals[i]; + g_eeGeneral.calibSpanNeg[i] = v - v/64; + v = hiVals[i] - midVals[i]; + g_eeGeneral.calibSpanPos[i] = v - v/64; + } + } + + int16_t sum = 0; + for (uint8_t i=0; i<12; i++) + sum += g_eeGeneral.calibMid[i]; + g_eeGeneral.chkSum = sum; + break; } + doMainScreenGrphics(); } diff --git a/src/gruvin9x.cpp b/src/gruvin9x.cpp index 2a91a167f..0d847ed18 100644 --- a/src/gruvin9x.cpp +++ b/src/gruvin9x.cpp @@ -67,17 +67,17 @@ const prog_char APM s_charTab[] = "_-.,"; //E=2 //T=3 //A=4 -const prog_uint8_t APM chout_ar[24][4] = { //First number is 0..23 -> template setup, Second is relevant channel out -{1,2,3,4},{1,2,4,3},{1,3,2,4},{1,3,4,2},{1,4,2,3},{1,4,3,2}, -{2,1,3,4},{2,1,4,3},{2,3,1,4},{2,3,4,1},{2,4,1,3},{2,4,3,1}, -{3,1,2,4},{3,1,4,2},{3,2,1,4},{3,2,4,1},{3,4,1,2},{3,4,2,1}, -{4,1,2,3},{4,1,3,2},{4,2,1,3},{4,2,3,1},{4,3,1,2},{4,3,2,1} }; +const prog_uint8_t APM chout_ar[] = { //First number is 0..23 -> template setup, Second is relevant channel out + 1,2,3,4 , 1,2,4,3 , 1,3,2,4 , 1,3,4,2 , 1,4,2,3 , 1,4,3,2, + 2,1,3,4 , 2,1,4,3 , 2,3,1,4 , 2,3,4,1 , 2,4,1,3 , 2,4,3,1, + 3,1,2,4 , 3,1,4,2 , 3,2,1,4 , 3,2,4,1 , 3,4,1,2 , 3,4,2,1, + 4,1,2,3 , 4,1,3,2 , 4,2,1,3 , 4,2,3,1 , 4,3,1,2 , 4,3,2,1 }; -const prog_uint8_t APM modn12x3[4][4]= { - {1, 2, 3, 4}, - {1, 3, 2, 4}, - {4, 2, 3, 1}, - {4, 3, 2, 1} }; +const prog_uint8_t APM modn12x3[]= { + 1, 2, 3, 4, + 1, 3, 2, 4, + 4, 2, 3, 1, + 4, 3, 2, 1 }; #ifdef TRANSLATIONS int8_t char2idx(char c) @@ -295,11 +295,6 @@ void applyExpos(int16_t *anas) } } -const prog_char *get_switches_string() -{ - return PSTR(SWITCHES_STR); -} - static bool s_noStickInputs = false; inline int16_t getValue(uint8_t i) { @@ -1142,10 +1137,14 @@ uint8_t evalSticks() // normalization [0..2048] -> [-1024..1024] int16_t v = anaIn(i); + +#ifndef SIMU v -= g_eeGeneral.calibMid[i]; v = v * (int32_t)RESX / (max((int16_t)100,(v>0 ? g_eeGeneral.calibSpanPos[i] : g_eeGeneral.calibSpanNeg[i]))); +#endif + if(v <= -RESX) v = -RESX; if(v >= RESX) v = RESX; calibratedStick[i] = v; //for show in expo diff --git a/src/gruvin9x.h b/src/gruvin9x.h index 20d296c04..759b3e02e 100644 --- a/src/gruvin9x.h +++ b/src/gruvin9x.h @@ -254,13 +254,13 @@ extern uint16_t DEBUG2; #define SLAVE_MODE (PING & (1< 1..4 -> 1..4 -#define CONVERT_MODE(x) (((x)<=4) ? pgm_read_byte(modn12x3+g_eeGeneral.stickMode*4+(x)-1) : (x)) -#define CHANNEL_ORDER(x) pgm_read_byte(chout_ar+g_eeGeneral.templateSetup*4+(x)-1) +#define CONVERT_MODE(x) (((x)<=4) ? pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + (x)-1) : (x) ) +#define CHANNEL_ORDER(x) pgm_read_byte(chout_ar + 4*g_eeGeneral.templateSetup + (x)-1) #define THR_STICK (2-(g_eeGeneral.stickMode&1)) #define ELE_STICK (1+(g_eeGeneral.stickMode&1)) #define AIL_STICK ((g_eeGeneral.stickMode&2) ? 0 : 3) @@ -294,9 +294,6 @@ enum EnumKeys { SW_Trainer }; -#define SWITCHES_STR "THR""RUD""ELE""ID0""ID1""ID2""AIL""GEA""TRN""SW1""SW2""SW3""SW4""SW5""SW6""SW7""SW8""SW9""SWA""SWB""SWC" - -#define CURV_STR "---x>0x<0|x|f>0f<0|f|c1 c2 c3 c4 c5 c6 c7 c8 c9 c10c11c12c13c14c15c16" #define CURVE_BASE 7 #define CSWITCH_STR "---- v>ofs vofs|v|v2 ""v1=v2 ""v1<=v2 " @@ -350,11 +347,13 @@ enum EnumKeys { #define CHOUT_BASE (PPM_BASE+NUM_PPM) #ifdef FRSKY -#define NUM_TELEMETRY 2 -#define TELEMETRY_CHANNELS "AD1 AD2 " +#define NUM_TELEMETRY 2 +#define TELEMETRY_CHANNELS "AD1AD2" +#define TELEMETRY_STRLEN 3 #else -#define NUM_TELEMETRY 0 +#define NUM_TELEMETRY 0 #define TELEMETRY_CHANNELS "" +#define TELEMETRY_STRLEN 0 #endif #define DSW_THR 1 @@ -505,8 +504,6 @@ extern uint8_t s_traceBuf[MAXTRACE]; extern uint16_t s_traceWr; extern uint16_t s_traceCnt; -const prog_char *get_switches_string() ; - uint16_t getTmr16KHz(); uint16_t stack_free(); diff --git a/src/lcd.cpp b/src/lcd.cpp index 46e83deb8..a120c42b4 100644 --- a/src/lcd.cpp +++ b/src/lcd.cpp @@ -389,14 +389,26 @@ void putsVBat(uint8_t x, uint8_t y, uint8_t att) putsVolts(x, y, g_vbat100mV, att); } +void putsStrIdx(uint8_t x, uint8_t y, const prog_char *str, uint8_t idx, uint8_t att) +{ + lcd_putsAtt(x, y, str, att); + lcd_outdezNAtt(lcd_lastPos, y, idx, att|LEFT, 2); +} + void putsChnRaw(uint8_t x, uint8_t y, uint8_t idx, uint8_t att) { if (idx==0) - lcd_putsnAtt(x,y,PSTR("----"),4,att); - else if(idx<=4) - lcd_putsnAtt(x,y,modi12x3+g_eeGeneral.stickMode*16+4*(idx-1),4,att); - else if(idx<=NUM_XCHNRAW) - lcd_putsnAtt(x,y,PSTR("P1 P2 P3 MAX FULLCYC1CYC2CYC3PPM1PPM2PPM3PPM4PPM5PPM6PPM7PPM8CH1 CH2 CH3 CH4 CH5 CH6 CH7 CH8 CH9 CH10CH11CH12CH13CH14CH15CH16"TELEMETRY_CHANNELS)+4*(idx-5),4,att); + lcd_putsnAtt(x, y, PSTR("----"), 4, att); + else if (idx<=NUM_STICKS) + lcd_putsnAtt(x, y, modi12x3+g_eeGeneral.stickMode*16+4*(idx-1), 4, att); + else if (idx<=NUM_STICKS+NUM_POTS+2+3) + lcd_putsnAtt(x,y,PSTR("P1 P2 P3 MAX FULLCYC1CYC2CYC3")+4*(idx-5), 4, att); + else if (idx<=NUM_STICKS+NUM_POTS+2+3+NUM_PPM) + putsStrIdx(x,y,PSTR("PPM"), idx - (NUM_STICKS+NUM_POTS+2+3), att); + else if (idx<=NUM_STICKS+NUM_POTS+2+3+NUM_PPM+NUM_CHNOUT) + putsStrIdx(x, y, PSTR("CH"), idx - (NUM_STICKS+NUM_POTS+2+3+NUM_PPM), att); + else if (idx<=NUM_XCHNRAW) + lcd_putsnAtt(x, y, PSTR(TELEMETRY_CHANNELS)+TELEMETRY_STRLEN*(idx-1-(NUM_STICKS+NUM_POTS+2+3+NUM_PPM+NUM_CHNOUT)), TELEMETRY_STRLEN, att); } void putsChn(uint8_t x, uint8_t y, uint8_t idx, uint8_t att) @@ -415,31 +427,39 @@ void putsModelName(uint8_t x, uint8_t y, char *name, uint8_t id, uint8_t att) uint8_t len = sizeof(g_model.name); while (len>0 && !name[len-1]) --len; if (len==0) { - lcd_putsAtt(x, y, PSTR("MODEL"/*MODEL*/), att); - lcd_outdezNAtt(lcd_lastPos, y, id+1, att|LEADING0|LEFT, 2); + putsStrIdx(x, y, PSTR("MODEL"), id+1, att|LEADING0); } else { lcd_putsnAtt(x, y, name, sizeof(g_model.name), ZCHAR|att); } } -void putsSwitches(uint8_t x,uint8_t y,int8_t idx,uint8_t att) +#define SWITCHES_STR "THR""RUD""ELE""ID0""ID1""ID2""AIL""GEA""TRN""SW1""SW2""SW3""SW4""SW5""SW6""SW7""SW8""SW9""SWA""SWB""SWC" +void putsSwitches(uint8_t x, uint8_t y, int8_t idx, uint8_t att) { switch(idx){ case 0: lcd_putsAtt(x,y,PSTR("---"),att);return; case MAX_SWITCH: lcd_putsAtt(x,y,PSTR("ON "),att);return; case -MAX_SWITCH: lcd_putsAtt(x,y,PSTR("OFF"),att);return; } - if (idx<0) lcd_putcAtt(x-FW, y, '!', att); - lcd_putsnAtt(x,y,get_switches_string()+3*(abs(idx)-1),3,att); + if (idx<0) lcd_vlineStip(x-2, y, 8, 0x5E/*'!'*/); + lcd_putsnAtt(x, y, PSTR(SWITCHES_STR)+3*(abs(idx)-1), 3, att); } void putsFlightPhase(uint8_t x, uint8_t y, int8_t idx, uint8_t att) { if (idx==0) { lcd_putsAtt(x,y,PSTR("---"),att); return; } - if (idx < 0) { lcd_putcAtt(x-FW, y, '!', att); idx = -idx; } - lcd_putsAtt(x, y, PSTR("FP"), att); - lcd_putcAtt(x+2*FW, y, '0'+idx-1, att); + if (idx < 0) { lcd_vlineStip(x-2, y, 8, 0x5E/*'!'*/); idx = -idx; } + putsStrIdx(x, y, PSTR("FP"), idx, att); +} + +#define CURV_STR "---x>0x<0|x|f>0f<0|f|" +void putsCurve(uint8_t x, uint8_t y, uint8_t idx, uint8_t att) +{ + if (idx < CURVE_BASE) + lcd_putsnAtt(x, y, PSTR(CURV_STR)+3*idx, 3, att); + else + putsStrIdx(x, y, PSTR("c"), idx-CURVE_BASE+1, att); } void putsTmrMode(uint8_t x, uint8_t y, int8_t mode, uint8_t att) diff --git a/src/lcd.h b/src/lcd.h index 253665624..8b76358ca 100644 --- a/src/lcd.h +++ b/src/lcd.h @@ -64,7 +64,6 @@ #define NO_UNIT UNSIGN #define SHRT_TM_MODE LEFT - extern uint8_t displayBuf[DISPLAY_W*DISPLAY_H/8]; extern uint8_t lcd_lastPos; @@ -83,8 +82,9 @@ extern void lcd_outdezNAtt(uint8_t x, uint8_t y, int16_t val, uint8_t mode=0, ui extern void lcd_outdez8(uint8_t x, uint8_t y, int8_t val); extern void putsModelName(uint8_t x, uint8_t y, char *name, uint8_t id, uint8_t att); -extern void putsSwitches(uint8_t x, uint8_t y, int8_t swtch, uint8_t att); -extern void putsFlightPhase(uint8_t x, uint8_t y, int8_t idx, uint8_t att); +extern void putsSwitches(uint8_t x, uint8_t y, int8_t swtch, uint8_t att=0); +extern void putsFlightPhase(uint8_t x, uint8_t y, int8_t idx, uint8_t att=0); +extern void putsCurve(uint8_t x, uint8_t y, uint8_t idx, uint8_t att=0); extern void putsTmrMode(uint8_t x, uint8_t y, int8_t mode, uint8_t att); extern void putsChnRaw(uint8_t x,uint8_t y,uint8_t idx1,uint8_t att); diff --git a/src/main_views.cpp b/src/main_views.cpp index 60c3f9a9c..d1d335a50 100644 --- a/src/main_views.cpp +++ b/src/main_views.cpp @@ -46,6 +46,39 @@ uint8_t tabViews[] = { #endif }; +#define BOX_WIDTH 23 +#define BAR_HEIGHT (BOX_WIDTH-1l) +#define MARKER_WIDTH 5 +#define SCREEN_WIDTH 128 +#define SCREEN_HEIGHT 64 +#define BOX_LIMIT (BOX_WIDTH-MARKER_WIDTH) +#define LBOX_CENTERX ( SCREEN_WIDTH/4 + 10) +#define LBOX_CENTERY (SCREEN_HEIGHT-9-BOX_WIDTH/2) +#define RBOX_CENTERX (3*SCREEN_WIDTH/4 - 10) +#define RBOX_CENTERY (SCREEN_HEIGHT-9-BOX_WIDTH/2) + +void doMainScreenGrphics() +{ + lcd_square(LBOX_CENTERX-BOX_WIDTH/2, LBOX_CENTERY-BOX_WIDTH/2, BOX_WIDTH); + lcd_square(RBOX_CENTERX-BOX_WIDTH/2, RBOX_CENTERY-BOX_WIDTH/2, BOX_WIDTH); + + DO_CROSS(LBOX_CENTERX,LBOX_CENTERY,3) + DO_CROSS(RBOX_CENTERX,RBOX_CENTERY,3) + + lcd_square(LBOX_CENTERX+(calibratedStick[0]*BOX_LIMIT/(2*RESX))-MARKER_WIDTH/2, LBOX_CENTERY-(calibratedStick[1]*BOX_LIMIT/(2*RESX))-MARKER_WIDTH/2, MARKER_WIDTH); + lcd_square(RBOX_CENTERX+(calibratedStick[3]*BOX_LIMIT/(2*RESX))-MARKER_WIDTH/2, RBOX_CENTERY-(calibratedStick[2]*BOX_LIMIT/(2*RESX))-MARKER_WIDTH/2, MARKER_WIDTH); + + // Optimization by Mike Blandford + { + uint8_t x, y, len ; // declare temporary variables + for( x = -5, y = 4 ; y < 7 ; x += 5, y += 1 ) + { + len = ((calibratedStick[y]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop + V_BAR(SCREEN_WIDTH/2+x,SCREEN_HEIGHT-8, len) + } + } +} + void menuMainView(uint8_t event) { static uint8_t switchView = 255; @@ -492,43 +525,13 @@ void menuMainView(uint8_t event) } #endif else if (view_base0) { g_menuStackPtr = g_menuStackPtr-1; beepKey(); - m_posHorz = g_menuPos[g_menuStackPtr] & 0x0F; - m_posVert = g_menuPos[g_menuStackPtr] >> 4; + m_posHorz = 0; + m_posVert = g_menuPos[g_menuStackPtr]; (*g_menuStack[g_menuStackPtr])(EVT_ENTRY_UP); } else { @@ -287,7 +290,7 @@ void chainMenu(MenuFuncP newMenu) void pushMenu(MenuFuncP newMenu) { - g_menuPos[g_menuStackPtr] = (m_posVert << 4) + m_posHorz; + g_menuPos[g_menuStackPtr] = m_posVert; g_menuStackPtr++; if(g_menuStackPtr >= DIM(g_menuStack)) @@ -323,13 +326,6 @@ void setupPulses() setupPulsesTracerCtp1009(); break; } -#if defined (DPPMPB7_HARDWARE) - - //Don't know if its usefull for the other encoding type or if they have polarity option cannot test those - //Force an ouput compare to match the ppm polarity - if(PINB&(1<<7) && g_model.pulsePol) - TCCR1C |=(1<expo, invBlk); - if(edit) CHECK_INCDEC_MODELVAR(event, ed->expo,-100, 100); + lcd_outdezAtt(9*FW+5, y, ed->weight, invBlk); + if(edit) CHECK_INCDEC_MODELVAR(event, ed->weight, 0, 100); break; case 1: - lcd_outdezAtt(9*FW, y, ed->weight, invBlk); - if(edit) CHECK_INCDEC_MODELVAR(event, ed->weight, 0, 100); + lcd_outdezAtt(9*FW+5, y, ed->expo, invBlk); + if(edit) CHECK_INCDEC_MODELVAR(event, ed->expo, -100, 100); break; case 2: { int8_t phase = ed->negPhase ? -ed->phase : +ed->phase; - putsFlightPhase(6*FW, y, phase, invBlk); + putsFlightPhase(6*FW+5, y, phase, invBlk); if(edit) { phase = checkIncDecModel(event, phase, -MAX_PHASES, MAX_PHASES); ed->negPhase = (phase < 0); ed->phase = abs(phase); } } break; case 3: - putsSwitches(6*FW, y, ed->swtch, invBlk); + putsSwitches(6*FW+5, y, ed->swtch, invBlk); if(edit) CHECK_INCDEC_MODELVAR(event, ed->swtch, -MAX_DRSWITCH, MAX_DRSWITCH); break; case 4: - lcd_putsnAtt(6*FW, y, PSTR(CURV_STR)+3*(ed->curve+(ed->curve >= CURVE_BASE+4 ? 4 : 0)), 3, invBlk); + lcd_putsnAtt(6*FW+5, y, PSTR("---x>0x<0")+9-3*ed->mode, 3, invBlk); + if(edit) ed->mode = 4 - checkIncDecModel(event, 4-ed->mode, 1, 3); + break; + case 5: + putsCurve(6*FW+5, y, ed->curve+(ed->curve >= CURVE_BASE+4 ? 4 : 0), invBlk); if(invBlk) CHECK_INCDEC_MODELVAR(event, ed->curve, 0, 15); if(invBlk && ed->curve>=CURVE_BASE && event==EVT_KEY_FIRST(KEY_MENU)) { s_curveChan = ed->curve - (ed->curve >= CURVE_BASE+4 ? CURVE_BASE-4 : CURVE_BASE); pushMenu(menuProcCurveOne); } break; - case 5: - lcd_putsnAtt(6*FW, y, PSTR("---PosNeg")+9-3*ed->mode, 3, invBlk); - if(edit) ed->mode = 4 - checkIncDecModel(event, 4-ed->mode, 1, 3); - break; } } void menuProcExpoOne(uint8_t event) { - SIMPLE_SUBMENU("EXPO/DR", 6); + SIMPLE_SUBMENU("DR/EXPO", 6); ExpoData *ed = expoaddress(s_currIdx); @@ -991,7 +991,7 @@ void menuProcExpoOne(uint8_t event) uint8_t y = FH; for (uint8_t i=0; i<7; i++) { - lcd_putsnAtt(0, y, PSTR("Expo WeightPhase Swtch Curve Mode ")+6*i, 6, 0); + lcd_putsnAtt(0, y, PSTR("Weight""Expo ""Phase ""Swtch ""When ""Curve "" ")+6*i, 6, 0); editExpoVals(event, i, sub==i, y, s_currIdx); y+=FH; } @@ -1060,7 +1060,7 @@ void menuProcMixOne(uint8_t event) break; case 4: lcd_putsAtt( 2*FW,y,PSTR("Curves"),0); - lcd_putsnAtt( FW*10,y,PSTR(CURV_STR)+md2->curve*3,3,attr); + putsCurve(FW*10, y, md2->curve, attr); if(attr) CHECK_INCDEC_MODELVAR( event, md2->curve, 0,MAX_CURVE5+MAX_CURVE9+7-1); if(attr && md2->curve>=CURVE_BASE && event==EVT_KEY_FIRST(KEY_MENU)){ s_curveChan = md2->curve-CURVE_BASE; @@ -1133,8 +1133,8 @@ inline void displayMixerLine(uint8_t row, uint8_t mix, uint8_t ch, uint8_t idx, if (attr != 0) CHECK_INCDEC_MODELVAR(event, md->weight, -125, 125); - if (md->curve) lcd_putsnAtt(12*FW+7, y, PSTR(CURV_STR)+md->curve*3, 3, 0); - if (md->swtch) putsSwitches(16*FW+6, y, md->swtch, 0); + if (md->curve) putsCurve(12*FW+7, y, md->curve); + if (md->swtch) putsSwitches(16*FW+6, y, md->swtch); char cs = ' '; if (md->speedDown || md->speedUp) @@ -1161,26 +1161,24 @@ inline void displayExpoLine(uint8_t row, uint8_t expo, uint8_t ch, uint8_t idx, uint8_t y = (row-s_pgOfs)*FH; ExpoData *ed = expoaddress(expo); - lcd_outdezAtt(7*FW, y, ed->expo, 0); - uint8_t attr = ((s_copyMode || cur != row) ? 0 : INVERS); - lcd_outdezAtt(10*FW, y, ed->weight, attr); + lcd_outdezAtt(6*FW-2, y, ed->weight, attr); if (attr != 0) CHECK_INCDEC_MODELVAR(event, ed->weight, 0, 100); - - putsSwitches(11*FW+FW/2, y, ed->swtch, 0); - if (ed->curve) lcd_putsnAtt(16*FW, y, PSTR(CURV_STR)+ed->curve*3, 3, 0); - if (ed->mode!=3) lcd_putc(20*FW, y, ed->mode == 2 ? 127 : 126);//'|' : (stkVal[i] ? '<' : '>'),0);*/ + lcd_outdezAtt(9*FW+1, y, ed->expo, 0); + putsFlightPhase(10*FW, y, ed->negPhase ? -ed->phase : +ed->phase); + putsSwitches(13*FW+4, y, ed->swtch, 0); // normal switches + if (ed->mode!=3) lcd_putc(17*FW, y, ed->mode == 2 ? 127 : 126);//'|' : (stkVal[i] ? '<' : '>'),0);*/ + if (ed->curve) putsCurve(18*FW+2, y, ed->curve+(ed->curve >= CURVE_BASE+4 ? 4 : 0)); if (s_copyMode) { if ((s_copyMode==COPY_MODE || s_copyTgtOfs == 0) && s_copySrcCh == ch && expo == (s_copySrcIdx + (s_copyTgtOfs<0))) { /* draw a border around the raw on selection mode (copy/move) */ - lcd_rect(22, y-1, DISPLAY_W-1-21, 9, s_copyMode == COPY_MODE ? 0xff : 0x55); + lcd_rect(18, y-1, DISPLAY_W-18, 9, s_copyMode == COPY_MODE ? 0xff : 0x55); } - if (row == cur) { /* invert the raw when it's the current one */ - lcd_filled_rect(23, y, DISPLAY_W-1-23, 7); + lcd_filled_rect(19, y, DISPLAY_W-20, 7); } } } @@ -1197,7 +1195,7 @@ void menuProcExpoMix(uint8_t expo, uint8_t __event) } SIMPLE_MENU_NOTITLE(menuTabModel, expo ? e_ExposAll : e_MixAll, s_maxLines); - TITLEP(expo ? PSTR("EXPO/DR") : PSTR("MIXER")); + TITLEP(expo ? PSTR("DR/EXPO") : PSTR("MIXER")); uint8_t sub = m_posVert; @@ -1420,19 +1418,20 @@ void menuProcLimits(uint8_t event) if((g_chans512[k] - v) < -50) swVal[k] = (false==ld->revert); putsChn(0,y,k+1,0); lcd_putcAtt(12*FW+FW/2, y, (swVal[k] ? 127 : 126),0); //'<' : '>' - for(uint8_t j=0; j<4;j++){ + for (uint8_t j=0; j<4; j++) { uint8_t attr = ((sub==k && m_posHorz==j) ? (s_editMode ? BLINK : INVERS) : 0); + uint8_t active = (attr && (s_editMode || p1valdiff)) ; switch(j) { case 0: lcd_outdezAtt( 8*FW, y, ld->offset, attr|PREC1); - if(attr && (s_editMode || p1valdiff)) { + if (active) { ld->offset = checkIncDec(event, ld->offset, -1000, 1000, EE_MODEL); } break; case 1: lcd_outdezAtt( 12*FW, y, (int8_t)(ld->min-100), attr); - if(attr && (s_editMode || p1valdiff)) { + if (active) { ld->min -= 100; if(g_model.extendedLimits) CHECK_INCDEC_MODELVAR( event, ld->min, -125,125); @@ -1443,7 +1442,7 @@ void menuProcLimits(uint8_t event) break; case 2: lcd_outdezAtt( 17*FW, y, (int8_t)(ld->max+100), attr); - if(attr && (s_editMode || p1valdiff)) { + if (active) { ld->max += 100; if(g_model.extendedLimits) CHECK_INCDEC_MODELVAR( event, ld->max, -125,125); @@ -1454,7 +1453,7 @@ void menuProcLimits(uint8_t event) break; case 3: lcd_putsnAtt( 18*FW, y, PSTR("---INV")+ld->revert*3,3,attr); - if(attr && (s_editMode || p1valdiff)) { + if (active) { CHECK_INCDEC_MODELVAR(event, ld->revert, 0, 1); } break; @@ -1620,17 +1619,18 @@ void menuProcFunctionSwitches(uint8_t event) FuncSwData *sd = &g_model.funcSw[k]; for (uint8_t j=0; j<2; j++) { uint8_t attr = ((sub==k && m_posHorz==j) ? (s_editMode ? BLINK : INVERS) : 0); + uint8_t active = (attr && (s_editMode || p1valdiff)); switch (j) { case 0: putsSwitches(1*FW, y, sd->swtch, attr); - if (attr && (s_editMode || p1valdiff)) { + if (active) { CHECK_INCDEC_MODELVAR( event, sd->swtch, -MAX_SWITCH, MAX_SWITCH); } break; case 1: if (sd->swtch) { lcd_putsnAtt(5*FW, y, PSTR(FSWITCH_STR)+FSW_LEN_FUNC*sd->func, FSW_LEN_FUNC, attr); - if (attr && (s_editMode || p1valdiff)) { + if (active) { CHECK_INCDEC_MODELVAR( event, sd->func, 0, FUNC_LAST); } } @@ -1658,18 +1658,19 @@ void menuProcSafetySwitches(uint8_t event) putsChn(0,y,k+1,0); for(uint8_t j=0; j<=2;j++){ uint8_t attr = ((m_posVert-1==k && m_posHorz==j) ? (s_editMode ? BLINK : INVERS) : 0); + uint8_t active = (attr && (s_editMode || p1valdiff)); switch(j) { - case 0: + case 0: putsSwitches(6*FW, y, sd->swtch , attr); - if(attr && (s_editMode || p1valdiff)) { - CHECK_INCDEC_MODELVAR( event, sd->swtch, -MAX_SWITCH, MAX_SWITCH); + if (active) { + CHECK_INCDEC_MODELVAR( event, sd->swtch, -MAX_SWITCH, MAX_SWITCH); } break; - case 1: + case 1: lcd_outdezAtt(16*FW, y, sd->val, attr); - if(attr && (s_editMode || p1valdiff)) { - CHECK_INCDEC_MODELVAR( event, sd->val, -125, 125); + if (active) { + CHECK_INCDEC_MODELVAR( event, sd->val, -125, 125); } break; } diff --git a/src/simu.cpp b/src/simu.cpp index d164d1d80..7c6de7b6d 100644 --- a/src/simu.cpp +++ b/src/simu.cpp @@ -119,9 +119,9 @@ Gruvin9xSim::Gruvin9xSim(FXApp* a) break; default:; } - sliders[i]->setRange(0+i*50,1023); + sliders[i]->setRange(-1024, 1024); sliders[i]->setTickDelta(7); - sliders[i]->setValue(i==1 ? 200 : 512+i*25); + sliders[i]->setValue(0); } arrow[0]= new FXArrowButton(hf10,this,1000,ARROW_LEFT); arrow[1]= new FXArrowButton(hf10,this,1000,ARROW_UP);