From bfdc66635d9f7df486808750aa227723a52fa959 Mon Sep 17 00:00:00 2001 From: bsongis Date: Wed, 25 Jul 2012 14:27:38 +0000 Subject: [PATCH] XCURVES option removed. There will be only one EEPROM format. And some functionnality will be removed later (no custom curves) when XCURVES will be disabled. For now it's always enabled. --- src/eeprom_arm.cpp | 2 +- src/ersky9x/audio.cpp | 2 + src/lcd.cpp | 15 ++++ src/lcd.h | 4 + src/model_menus.cpp | 180 ++---------------------------------------- src/myeeprom.h | 27 +++---- src/open9x.cpp | 63 ++++----------- src/open9x.h | 13 +-- src/simpgmspace.cpp | 17 +++- src/stock/voice.h | 40 ++++++++++ src/templates.cpp | 4 - src/translations.cpp | 3 - src/translations.h | 8 -- src/translations/cz.h | 3 - src/translations/de.h | 3 - src/translations/en.h | 3 - src/translations/fr.h | 3 - src/translations/it.h | 3 - src/translations/se.h | 3 - 19 files changed, 110 insertions(+), 286 deletions(-) diff --git a/src/eeprom_arm.cpp b/src/eeprom_arm.cpp index 757026013..65e1d97ed 100644 --- a/src/eeprom_arm.cpp +++ b/src/eeprom_arm.cpp @@ -456,7 +456,7 @@ bool ee32LoadGeneral() } #ifdef SIMU else { - printf("EEPROM version %d instead of %d\n", g_eeGeneral.myVers, EEPROM_VER); + printf("EEPROM version %d (%d) instead of %d (%d)\n", g_eeGeneral.myVers, g_eeGeneral.variants, EEPROM_VER, EEPROM_VARIANTS); fflush(stdout); } #endif diff --git a/src/ersky9x/audio.cpp b/src/ersky9x/audio.cpp index 6bfb4790c..2bdfd1dd0 100644 --- a/src/ersky9x/audio.cpp +++ b/src/ersky9x/audio.cpp @@ -84,8 +84,10 @@ void retrieveAvailableAudioFiles() FILINFO info; char filename[32] = SYSTEM_SOUNDS_PATH "/"; +#if !defined WIN32 && defined __GNUC__ assert(sizeof(audioFilenames)==AU_FRSKY_FIRST*sizeof(char *)); assert(sizeof(sdAvailableAudioFiles)*8 > AU_FRSKY_FIRST); +#endif sdAvailableAudioFiles = 0; diff --git a/src/lcd.cpp b/src/lcd.cpp index e8d714dbe..dbb80c0b9 100644 --- a/src/lcd.cpp +++ b/src/lcd.cpp @@ -915,11 +915,21 @@ void lcdSendCtl(uint8_t val) PORTC_LCD_CTRL |= (1< NUM_POINTS-5*MAX_CURVES) { @@ -1240,108 +1239,6 @@ void menuProcCurveOne(uint8_t event) DrawCurve(curveFn); } -#else -void menuProcCurveOne(uint8_t event) -{ - uint8_t points; - int8_t *crv; - static int8_t dfltCrv; - - TITLE(STR_MENUCURVE); - lcd_outdezAtt(5*FW+1, 0, s_curveChan+1, INVERS|LEFT); - DISPLAY_PROGRESS_BAR(20*FW+1); - - if (s_curveChan >= MAX_CURVE5) { - points = 9; - } - else { - points = 5; - } - - crv = curveaddress(s_curveChan); - - switch(event) { - case EVT_ENTRY: - dfltCrv = 0; -#if defined(ROTARY_ENCODERS) - s_editMode = -1; -#endif - break; -#if defined(ROTARY_ENCODERS) - case EVT_KEY_BREAK(BTN_REa): - case EVT_KEY_BREAK(BTN_REb): - if (!navigationRotaryEncoder(event)) - break; -#endif - case EVT_KEY_FIRST(KEY_MENU): - if (s_editMode<=0) { - switch (m_posHorz) { - case 0: - s_editMode = 1; - break; - case 1: - if (++dfltCrv > 4) - dfltCrv = -4; - for (uint8_t i=0; i0) { - m_posHorz = 0; - s_editMode = 0; - } - else { - popMenu(); - } - break; - case EVT_KEY_REPT(KEY_LEFT): - case EVT_KEY_FIRST(KEY_LEFT): - if (m_posHorz>0) m_posHorz--; - break; - case EVT_KEY_REPT(KEY_RIGHT): - case EVT_KEY_FIRST(KEY_RIGHT): - if (m_posHorz<((s_editMode>0) ? points-1 : 1)) m_posHorz++; - break; - } - - for (uint8_t i = 0; i < points; i++) { - uint8_t x, y; - if (i>4) { - x = 8*FW; y = (i-4) * FH; - } - else { - x = 4*FW; y = (i+1) * FH; - } - uint8_t attr = (s_editMode>0 && m_posHorz==i) ? INVERS : 0; - lcd_outdezAtt(x, y, crv[i], attr); - } - - lcd_putsLeft(7*FH, STR_MODE); - lcd_putsiAtt(5*FW-2, 7*FH, STR_CURVMODES, (s_editMode<=0)*m_posHorz, s_editMode>0 ? 0 : INVERS); - - if (s_editMode>0) { - for (uint8_t i=0; iexpo, -100, 100, 0, STR_DREXPO); break; case EXPO_FIELD_CURVE: -#if defined(XCURVES) putsCurve(6*FW+5, y, ed->curve, attr); - if (attr) CHECK_INCDEC_MODELVAR(event, ed->curve, 0, MAX_CURVES+7-1); -#else - putsCurve(6*FW+5, y, ed->curve+(ed->curve >= CURVE_BASE+4 ? 4 : 0), attr); - if (attr) CHECK_INCDEC_MODELVAR(event, ed->curve, 0, 15); -#endif - - if (attr && 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); + if (attr) { + CHECK_INCDEC_MODELVAR(event, ed->curve, 0, MAX_CURVES+7-1); + if (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; #ifdef FLIGHT_PHASES @@ -1991,11 +1884,7 @@ void menuProcExpoMix(uint8_t expo, uint8_t _event_) #endif putsSwitches(EXPO_LINE_SWITCH_POS, y, ed->swtch, 0); // normal switches if (ed->mode!=3) lcd_putc(17*FW, y, ed->mode == 2 ? 126 : 127);//'|' : (stkVal[i] ? '<' : '>'),0);*/ -#if defined(XCURVES) if (ed->curve) putsCurve(18*FW+2, y, ed->curve); -#else - if (ed->curve) putsCurve(18*FW+2, y, ed->curve+(ed->curve >= CURVE_BASE+4 ? 4 : 0)); -#endif } } else { @@ -2251,7 +2140,6 @@ void menuProcLimits(uint8_t _event) } } -#if defined(XCURVES) void menuProcCurvesAll(uint8_t event) { SIMPLE_MENU(STR_MENUCURVES, menuTabModel, e_CurvesAll, 1+MAX_CURVES); @@ -2285,62 +2173,6 @@ void menuProcCurvesAll(uint8_t event) s_curveChan = sub; DrawCurve(curveFn); } -#else -void menuProcCurvesAll(uint8_t event) -{ - SIMPLE_MENU(STR_MENUCURVES, menuTabModel, e_CurvesAll, 1+MAX_CURVES); - - int8_t sub = m_posVert - 1; - - switch (event) { -#if defined(ROTARY_ENCODERS) - case EVT_KEY_BREAK(BTN_REa): - case EVT_KEY_BREAK(BTN_REb): - if (!navigationRotaryEncoder(event)) - break; - // no break -#endif - case EVT_KEY_FIRST(KEY_RIGHT): - case EVT_KEY_FIRST(KEY_MENU): - if (sub >= 0) { - s_curveChan = sub; - pushMenu(menuProcCurveOne); - } - break; - } - - uint8_t y = 1*FH; - uint8_t yd = 1; - uint8_t m = 0; - for (uint8_t i = 0; i < 7; i++) { - uint8_t k = i + s_pgOfs; - uint8_t attr = sub == k ? INVERS : 0; -#if defined(XCURVES) - bool cv9 = (getCurvePoints(k) == 9); -#else - bool cv9 = k >= MAX_CURVE5; -#endif - - if(cv9 && (yd>6)) break; - if(yd>7) break; - if(!m) m = attr; - putsStrIdx(0, y, STR_CV, k+1, attr); - int8_t *crv = curveaddress(k); - for (uint8_t j = 0; j < (5); j++) { - lcd_outdezAtt( j*(3*FW+3) + 7*FW + 2, y, crv[j], 0); - } - y += FH;yd++; - if(cv9){ - for (uint8_t j = 0; j < 4; j++) { - lcd_outdezAtt( j*(3*FW+3) + 7*FW + 2, y, crv[j+5], 0); - } - y += FH;yd++; - } - } - - if(!m) s_pgOfs++; -} -#endif #if defined(PCBARM) enum CustomSwitchFields { diff --git a/src/myeeprom.h b/src/myeeprom.h index 5ed871d50..5d94f51ef 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -49,11 +49,11 @@ #define BEEP_VAL ( (g_eeGeneral.warnOpts & WARN_BVAL_BIT) >>3 ) #if defined(PCBARM) -#define EEPROM_VER 210 +#define EEPROM_VER 211 #elif defined(PCBV4) -#define EEPROM_VER 209 +#define EEPROM_VER 210 #else -#define EEPROM_VER 209 +#define EEPROM_VER 210 #endif #ifndef PACK @@ -590,22 +590,16 @@ PACK(typedef struct t_PhaseData { #define MAX_TIMERS 2 -#if defined(XCURVES) +#if defined(PCBARM) +#define MAX_CURVES 16 +#define NUM_POINTS 256 +#else #define MAX_CURVES 8 #define NUM_POINTS (112-MAX_CURVES) +#endif + #define MIN_POINTS 3 #define MAX_POINTS 17 -#define CURVES_DATA \ - int8_t curves[MAX_CURVES]; \ - int8_t points[NUM_POINTS] -#else -#define MAX_CURVE5 8 -#define MAX_CURVE9 8 -#define MAX_CURVES (MAX_CURVE5+MAX_CURVE9) -#define CURVES_DATA \ - int8_t curves5[MAX_CURVE5][5]; \ - int8_t curves9[MAX_CURVE9][9] -#endif #define TMRMODE_NONE 0 #define TMRMODE_ABS 1 @@ -682,7 +676,8 @@ PACK(typedef struct t_ModelData { LimitData limitData[NUM_CHNOUT]; ExpoData expoData[MAX_EXPOS]; - CURVES_DATA; + int8_t curves[MAX_CURVES]; + int8_t points[NUM_POINTS]; CustomSwData customSw[NUM_CSW]; FuncSwData funcSw[NUM_FSW]; diff --git a/src/open9x.cpp b/src/open9x.cpp index f6d25394f..bb2edd267 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -162,7 +162,6 @@ LimitData *limitaddress(uint8_t idx) return &g_model.limitData[idx]; } -#if defined(XCURVES) int8_t *curveaddress(uint8_t idx) { return &g_model.points[idx==0 ? 0 : 5*idx+g_model.curves[idx-1]]; @@ -183,12 +182,6 @@ CurveInfo curveinfo(uint8_t idx) } return result; } -#else -int8_t *curveaddress(uint8_t idx) -{ - return (idx >= MAX_CURVE5 ? g_model.curves9[idx-MAX_CURVE5] : g_model.curves5[idx]); -} -#endif CustomSwData *cswaddress(uint8_t idx) { @@ -272,7 +265,6 @@ void resetProto() #endif } -#if defined(XCURVES) int16_t intpol(int16_t x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 100 { CurveInfo crv = curveinfo(idx); @@ -306,37 +298,6 @@ int16_t intpol(int16_t x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 10 return erg / 25; // 100*D5/RESX; } -#else -int16_t intpol(int16_t x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 100 -{ -#define D9 (RESX * 2 / 8) -#define D5 (RESX * 2 / 4) - bool cv9 = idx >= MAX_CURVE5; - int8_t *crv = curveaddress(idx); - int16_t erg; - - x+=RESXu; - if (x < 0) { - erg = (int16_t)crv[0] * (RESX/4); - } - else if (x >= (RESX*2)) { - erg = (int16_t)crv[(cv9 ? 8 : 4)] * (RESX/4); - } - else { - int16_t a,dx; - if (cv9) { - a = (uint16_t)x / D9; - dx =((uint16_t)x % D9) * 2; - } - else { - a = (uint16_t)x / D5; - dx = (uint16_t)x % D5; - } - erg = (int16_t)crv[a]*((D5-dx)/2) + (int16_t)crv[a+1]*(dx/2); - } - return erg / 25; // 100*D5/RESX; -} -#endif int16_t applyCurve(int16_t x, int8_t idx) { @@ -484,11 +445,7 @@ void applyExpos(int16_t *anas) int16_t k = ed.expo; v = expo(v, k); uint8_t ed_curve = ed.curve; -#if defined(XCURVES) if (ed_curve) v = applyCurve(v, ed_curve); -#else - if (ed_curve) v = applyCurve(v, ed_curve > 10 ? ed_curve + 4 : ed_curve); -#endif v = ((int32_t)v * ed.weight) / 100; anas[cur_chn] = v; } @@ -497,7 +454,7 @@ void applyExpos(int16_t *anas) } #if !defined(PCBARM) -int16_t calc1000toRESX(int16_t x) +int16_t calc1000toRESX(int16_t x) // improve calc time by Pat MacKenzie { // return x + x/32 - x/128 + x/512; int16_t y = x>>5; @@ -2771,7 +2728,7 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer #else TIMSK &= ~(1< #include -#define VARIANT_XCURVES_MASK 0x80 - -#if defined(XCURVES) -#define VARIANT_XCURVES VARIANT_XCURVES_MASK -#else -#define VARIANT_XCURVES 0x00 -#endif - -#define EEPROM_VARIANTS (VARIANT_XCURVES) +#define EEPROM_VARIANTS (0x00) #if defined(PCBSTD) #define WDT_RESET_STOCK() wdt_reset() @@ -819,14 +811,13 @@ extern MixData *mixaddress(uint8_t idx); extern LimitData *limitaddress(uint8_t idx); extern int8_t *curveaddress(uint8_t idx); extern CustomSwData *cswaddress(uint8_t idx); -#if defined(XCURVES) + struct CurveInfo { int8_t *crv; uint8_t points; bool custom; }; extern CurveInfo curveinfo(uint8_t idx); -#endif extern void deleteExpoMix(uint8_t expo, uint8_t idx); diff --git a/src/simpgmspace.cpp b/src/simpgmspace.cpp index 637416929..57dc6f41f 100644 --- a/src/simpgmspace.cpp +++ b/src/simpgmspace.cpp @@ -274,11 +274,16 @@ static void EeFsDump(){ } #endif -#if defined(SDCARD) && !defined WIN32 && defined __GNUC__ +#if defined(SDCARD) namespace simu { #include } #include "FatFs/ff.h" + +#if defined WIN32 || !defined __GNUC__ +#include +#endif + FRESULT f_stat (const TCHAR*, FILINFO*) { return FR_OK; @@ -332,7 +337,15 @@ FRESULT f_readdir (DIR * rep, FILINFO * fil) { simu::dirent * ent = simu::readdir((simu::DIR *)rep->fs); if (!ent) return FR_NO_FILE; - if(ent->d_type == simu::DT_DIR) fil->fattrib = AM_DIR; else fil->fattrib = 0; + +#if defined WIN32 || !defined __GNUC__ + if (ent->d_type == DT_DIR) +#else + if (ent->d_type == simu::DT_DIR) +#endif + fil->fattrib = AM_DIR; + else + fil->fattrib = 0; memset(fil->fname, 0, 13); memset(fil->lfname, 0, SD_SCREEN_FILE_LENGTH); strncpy(fil->fname, ent->d_name, 13-1); diff --git a/src/stock/voice.h b/src/stock/voice.h index f81cce7fd..b7a721a18 100644 --- a/src/stock/voice.h +++ b/src/stock/voice.h @@ -76,3 +76,43 @@ inline bool isPlaying() { return Voice.VoiceState != V_IDLE; } + +/* + * Handle the Voice output + * Check for LcdLocked (in interrupt), and voice_enabled + */ +#define VOICE_DRIVER() \ + if ( LcdLock == 0 ) /* LCD not in use */ \ + { \ + struct t_voice *vptr; \ + vptr = voiceaddress(); \ + if ( vptr->VoiceState == V_CLOCKING ) \ + { \ + if ( vptr->VoiceTimer ) \ + { \ + vptr->VoiceTimer -= 1; \ + } \ + else \ + { \ + PORTB |= (1<VoiceCounter & 1 ) \ + { \ + vptr->VoiceLatch &= ~VOICE_DATA_BIT; \ + if ( vptr->VoiceSerial & 0x8000 ) \ + { \ + vptr->VoiceLatch |= VOICE_DATA_BIT; \ + } \ + vptr->VoiceSerial <<= 1; \ + } \ + vptr->VoiceLatch ^= VOICE_CLOCK_BIT; \ + PORTA_LCD_DAT = vptr->VoiceLatch; /* Latch data set */ \ + PORTB &= ~(1<VoiceCounter == 0 ) \ + { \ + vptr->VoiceState = V_WAIT_BUSY_ON; \ + vptr->VoiceTimer = 5; /* 50 mS */ \ + } \ + } \ + } \ + } + diff --git a/src/templates.cpp b/src/templates.cpp index 4b5fba07b..09efa1b11 100644 --- a/src/templates.cpp +++ b/src/templates.cpp @@ -92,11 +92,7 @@ void clearMixes() void clearCurves() { -#if defined(XCURVES) memclear(g_model.curves, sizeof(g_model.curves) + sizeof(g_model.points)); // clear all curves -#else - memclear(g_model.curves5, sizeof(g_model.curves5) + sizeof(g_model.curves9)); // clear all curves -#endif } void setCurve(uint8_t c, const pm_int8_t ar[]) diff --git a/src/translations.cpp b/src/translations.cpp index 8264dd678..5cfb5f163 100644 --- a/src/translations.cpp +++ b/src/translations.cpp @@ -57,9 +57,6 @@ const pm_char STR_OPEN9X[] PROGMEM = ISTR(POSNEG) ISTR(VBLMODE) ISTR(VCURVEFUNC) -#if !defined(XCURVES) - ISTR(CURVMODES) -#endif ISTR(EXPLABELS) ISTR(VMLTPX) ISTR(VMLTPX2) diff --git a/src/translations.h b/src/translations.h index d2f18024c..eb1130b03 100644 --- a/src/translations.h +++ b/src/translations.h @@ -84,12 +84,7 @@ extern const pm_char STR_OPEN9X[]; #define OFS_POSNEG (OFS_VPROTOS + sizeof(TR_VPROTOS)) #define OFS_VBLMODE (OFS_POSNEG + sizeof(TR_POSNEG)) #define OFS_VCURVEFUNC (OFS_VBLMODE + sizeof(TR_VBLMODE)) -#if defined(XCURVES) #define OFS_EXPLABELS (OFS_VCURVEFUNC + sizeof(TR_VCURVEFUNC)) -#else -#define OFS_CURVMODES (OFS_VCURVEFUNC + sizeof(TR_VCURVEFUNC)) -#define OFS_EXPLABELS (OFS_CURVMODES + sizeof(TR_CURVMODES)) -#endif #define OFS_VMLTPX (OFS_EXPLABELS + sizeof(TR_EXPLABELS)) #define OFS_VMLTPX2 (OFS_VMLTPX + sizeof(TR_VMLTPX)) #define OFS_VMIXTRIMS (OFS_VMLTPX2 + sizeof(TR_VMLTPX2)) @@ -154,9 +149,6 @@ extern const pm_char STR_OPEN9X[]; #define STR_VCURVEFUNC (STR_OPEN9X + OFS_VCURVEFUNC) #define STR_VWHEN STR_VCURVEFUNC #define LEN_VWHEN LEN_VCURVEFUNC -#if !defined(XCURVES) -#define STR_CURVMODES (STR_OPEN9X + OFS_CURVMODES) -#endif #define STR_EXPLABELS (STR_OPEN9X + OFS_EXPLABELS) #define STR_VMLTPX (STR_OPEN9X + OFS_VMLTPX) #define STR_VMLTPX2 (STR_OPEN9X + OFS_VMLTPX2) diff --git a/src/translations/cz.h b/src/translations/cz.h index b58abbb06..c1e691168 100644 --- a/src/translations/cz.h +++ b/src/translations/cz.h @@ -70,9 +70,6 @@ #define LEN_VCURVEFUNC "\003" #define TR_VCURVEFUNC "---""x>0""x<0""|x|""f>0""f<0""|f|" -#define LEN_CURVMODES "\005" -#define TR_CURVMODES "EDIT ""PRSET" - #define LEN_EXPLABELS "\006" #ifdef PCBARM #define TR_EXPLABEL_NAME "Jm\202no " diff --git a/src/translations/de.h b/src/translations/de.h index 92c549a1c..0d68d6fc4 100644 --- a/src/translations/de.h +++ b/src/translations/de.h @@ -70,9 +70,6 @@ #define LEN_VCURVEFUNC "\003" #define TR_VCURVEFUNC "---""x>0""x<0""|x|""f>0""f<0""|f|" -#define LEN_CURVMODES "\005" -#define TR_CURVMODES "EDIT ""PRSET" - #define LEN_EXPLABELS "\006" #ifdef PCBARM #define TR_EXPLABEL_NAME "Name " diff --git a/src/translations/en.h b/src/translations/en.h index b3ae06411..ca109aa40 100644 --- a/src/translations/en.h +++ b/src/translations/en.h @@ -70,9 +70,6 @@ #define LEN_VCURVEFUNC "\003" #define TR_VCURVEFUNC "---""x>0""x<0""|x|""f>0""f<0""|f|" -#define LEN_CURVMODES "\005" -#define TR_CURVMODES "EDIT ""PRSET" - #define LEN_EXPLABELS "\006" #ifdef PCBARM #define TR_EXPLABEL_NAME "Name " diff --git a/src/translations/fr.h b/src/translations/fr.h index 7ef0e1040..fd8154260 100644 --- a/src/translations/fr.h +++ b/src/translations/fr.h @@ -65,9 +65,6 @@ #define LEN_VCURVEFUNC "\003" #define TR_VCURVEFUNC "---""x>0""x<0""|x|""f>0""f<0""|f|" -#define LEN_CURVMODES "\005" -#define TR_CURVMODES "EDIT ""PRSET" - #define LEN_EXPLABELS "\006" #ifdef PCBARM #define TR_EXPLABEL_NAME "Nom " diff --git a/src/translations/it.h b/src/translations/it.h index 136150c75..c2c74ea05 100644 --- a/src/translations/it.h +++ b/src/translations/it.h @@ -70,9 +70,6 @@ #define LEN_VCURVEFUNC "\003" #define TR_VCURVEFUNC "---""x>0""x<0""|x|""f>0""f<0""|f|" -#define LEN_CURVMODES "\005" -#define TR_CURVMODES "PERS.""PRSET" - #define LEN_EXPLABELS "\006" #ifdef PCBARM #define TR_EXPLABEL_NAME "Name " diff --git a/src/translations/se.h b/src/translations/se.h index 0b7c1252f..e308f59c8 100644 --- a/src/translations/se.h +++ b/src/translations/se.h @@ -65,9 +65,6 @@ #define LEN_VCURVEFUNC "\003" #define TR_VCURVEFUNC "---""x>0""x<0""|x|""f>0""f<0""|f|" -#define LEN_CURVMODES "\005" -#define TR_CURVMODES "EDIT ""PRSET" - #define LEN_EXPLABELS "\006" #ifdef PCBARM #define TR_EXPLABEL_NAME "Namn "