1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 00:05:17 +03:00

Calibration screen. Bugs and optimizations.

This commit is contained in:
bsongis 2011-10-13 18:23:01 +00:00
parent f131b0a016
commit 54d6634a8b
11 changed files with 212 additions and 175 deletions

View file

@ -1,5 +1,5 @@
/*
* Authors (alpahbetical order)
* Authors (alphabetical order)
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
*

View file

@ -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();
case EVT_KEY_BREAK(KEY_MENU):
idxState++;
if (idxState==3) {
STORE_GENERALVARS;
idxState = 0;
}
break;
case 3:
for(uint8_t i=0; i<7; i++)
if(abs(loVals[i]-hiVals[i])>50) {
}
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;
eeDirty(EE_GENERAL); //eeWriteGeneral();
beepKey();
break;
}
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]);
}
int16_t sum = 0;
for (uint8_t i=0; i<12; i++)
sum += g_eeGeneral.calibMid[i];
g_eeGeneral.chkSum = sum;
break;
}
doMainScreenGrphics();
}

View file

@ -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

View file

@ -254,13 +254,13 @@ extern uint16_t DEBUG2;
#define SLAVE_MODE (PING & (1<<INP_G_RF_POW))
extern const prog_uint8_t APM chout_ar[24][4];
extern const prog_uint8_t APM modn12x3[4][4];
extern const prog_uint8_t APM chout_ar[24*4];
extern const prog_uint8_t APM modn12x3[4*4];
//convert from mode 1 to mode g_eeGeneral.stickMode
//NOTICE! => 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 v<ofs |v|>ofs|v|<ofsAND OR XOR ""v1==v2 ""v1!=v2 ""v1>v2 ""v1<v2 ""v1>=v2 ""v1<=v2 "
@ -351,10 +348,12 @@ enum EnumKeys {
#ifdef FRSKY
#define NUM_TELEMETRY 2
#define TELEMETRY_CHANNELS "AD1 AD2 "
#define TELEMETRY_CHANNELS "AD1AD2"
#define TELEMETRY_STRLEN 3
#else
#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();

View file

@ -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)

View file

@ -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);

View file

@ -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_base<e_timer2) {
#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)
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 )
doMainScreenGrphics();
int8_t a = (view == e_inputs) ? 1 : 4+(view/ALTERNATE)*6;
int8_t b = (view == e_inputs) ? 7 : 7+(view/ALTERNATE)*6;
for(int8_t i=a; i<(a+3); i++) putsSwitches(2*FW-2, (i-a)*FH+4*FH, i, getSwitch(i, 0) ? INVERS : 0);
for(int8_t i=b; i<(b+3); i++) putsSwitches(17*FW-1, (i-b)*FH+4*FH, i, getSwitch(i, 0) ? INVERS : 0);
}
}
int8_t a = (view == e_inputs) ? 0 : 3+(view/ALTERNATE)*6;
int8_t b = (view == e_inputs) ? 6 : 6+(view/ALTERNATE)*6;
for(int8_t i=a; i<(a+3); i++) lcd_putsnAtt(2*FW-2 ,(i-a)*FH+4*FH,get_switches_string()+3*i,3,getSwitch(i+1, 0) ? INVERS : 0);
for(int8_t i=b; i<(b+3); i++) lcd_putsnAtt(17*FW-1,(i-b)*FH+4*FH,get_switches_string()+3*i,3,getSwitch(i+1, 0) ? INVERS : 0);
}
else // timer2
{
else { // timer2
putsTime(33+FW+2, FH*5, timer2, DBLSIZE, DBLSIZE);
}
}

View file

@ -29,6 +29,7 @@ int16_t ex_chans[NUM_CHNOUT]; // Outputs + intermidiates
uint8_t s_pgOfs;
uint8_t s_editMode;
uint8_t s_noHi;
uint8_t s_noScroll;
int16_t g_chans512[NUM_CHNOUT];
@ -160,9 +161,10 @@ bool check_submenu_simple(uint8_t event, uint8_t maxrow)
bool check(uint8_t event, uint8_t curr, MenuFuncP *menuTab, uint8_t menuTabSize, prog_uint8_t *horTab, uint8_t horTabMax, uint8_t maxrow)
{
if (menuTab) {
uint8_t attr = m_posVert==0 ? INVERS : 0;
uint8_t attr = 0;
if (m_posVert==0) {
if (m_posVert==0 && !s_noScroll) {
attr = INVERS;
switch(event)
{
case EVT_KEY_FIRST(KEY_LEFT):
@ -179,6 +181,7 @@ bool check(uint8_t event, uint8_t curr, MenuFuncP *menuTab, uint8_t menuTabSize,
return false;
}
}
s_noScroll = 0;
DisplayScreenIndex(curr, menuTabSize, attr);
}
@ -269,8 +272,8 @@ void popMenu()
if (g_menuStackPtr>0) {
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<<FOC1C);
#endif
}
//inline int16_t reduceRange(int16_t x) // for in case we want to have room for subtrims

View file

@ -47,6 +47,7 @@ void DisplayScreenIndex(uint8_t index, uint8_t count, uint8_t attr);
extern uint8_t s_pgOfs;
extern uint8_t s_noHi;
extern uint8_t s_noScroll;
// extern int16_t expo(int16_t x, int16_t k);
@ -68,6 +69,7 @@ inline MenuFuncP lastPopMenu()
return g_menuStack[g_menuStackPtr+1];
}
void doMainScreenGrphics();
void menuMainView(uint8_t event);
void menuProcSetup(uint8_t event);
void menuProcModelSelect(uint8_t event);

View file

@ -945,42 +945,42 @@ inline void editExpoVals(uint8_t event, uint8_t which, bool edit, uint8_t y, uin
switch(which)
{
case 0:
lcd_outdezAtt(9*FW, y, ed->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,17 +1658,18 @@ 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:
putsSwitches(6*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:
lcd_outdezAtt(16*FW, y, sd->val, attr);
if(attr && (s_editMode || p1valdiff)) {
if (active) {
CHECK_INCDEC_MODELVAR( event, sd->val, -125, 125);
}
break;

View file

@ -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);