diff --git a/src/Makefile b/src/Makefile index 54c18ac3e..d39026187 100644 --- a/src/Makefile +++ b/src/Makefile @@ -89,9 +89,6 @@ SDCARD = NO # PXX (FrSky PCM) protocol PXX = NO -# PPM16 -PPM16 = NO - # DSM2 (Spektrum) protocol DSM2 = NO @@ -389,10 +386,6 @@ ifeq ($(PXX), YES) CPPDEFS += -DPXX endif -ifeq ($(PPM16), YES) - CPPDEFS += -DPPM16 -endif - ifeq ($(DSM2), SERIAL) CPPDEFS += -DDSM2 -DDSM2_SERIAL endif diff --git a/src/model_menus.cpp b/src/model_menus.cpp index f1c528b8b..73855692b 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -550,7 +550,7 @@ void menuProcModel(uint8_t event) lcd_outdezNAtt(7*FW,0,g_eeGeneral.currModel+1,INVERS+LEADING0,2); uint8_t protocol = g_model.protocol; - MENU(STR_MENUSETUP, menuTabModel, e_Model, ((protocol==PROTO_PPM||protocol==PROTO_FAAST||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? 12 : 11), {0,ZCHAR|(sizeof(g_model.name)-1),2,2,0,0,0,0,0,NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1,2,1}); + MENU(STR_MENUSETUP, menuTabModel, e_Model, ((protocol<=PROTO_PPMSIM||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? 12 : 11), {0,ZCHAR|(sizeof(g_model.name)-1),2,2,0,0,0,0,0,NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1,1,2}); uint8_t sub = m_posVert - 1; @@ -657,23 +657,21 @@ void menuProcModel(uint8_t event) lcd_putsLeft(y, STR_PROTO); lcd_putsiAtt(MODEL_PARAM_OFS, y, STR_VPROTOS, protocol, (attr && m_posHorz==0 ? (s_editMode>0 ? BLINK|INVERS : INVERS):0)); - if (protocol == PROTO_PPM || protocol == PROTO_FAAST) { - lcd_putsiAtt(MODEL_PARAM_OFS+4*FW, y, STR_NCHANNELS, g_model.ppmNCH+2, (attr && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); - lcd_puts(MODEL_PARAM_OFS+11*FW, y, PSTR("u")); - lcd_outdezAtt(MODEL_PARAM_OFS+11*FW, y, (g_model.ppmDelay*50)+300, ((attr && m_posHorz==2) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0)); + if (protocol <= PROTO_PPMSIM) { + lcd_putsiAtt(MODEL_PARAM_OFS+7*FW, y, STR_NCHANNELS, g_model.ppmNCH+2, (attr && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); } #ifdef DSM2 else if (protocol == PROTO_DSM2) { if (m_posHorz > 1) m_posHorz = 1; int8_t x = limit((int8_t)0, (int8_t)g_model.ppmNCH, (int8_t)2); g_model.ppmNCH = x; - lcd_putsiAtt(MODEL_PARAM_OFS+5*FW, y, STR_DSM2MODE, x, (attr && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); + lcd_putsiAtt(MODEL_PARAM_OFS+7*FW, y, STR_DSM2MODE, x, (attr && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); } #endif else if (attr) { m_posHorz = 0; } - if (attr && (s_editMode>0 || p1valdiff || (protocol!=PROTO_PPM && protocol!=PROTO_FAAST && protocol!=PROTO_DSM2))) { // TODO avoid DSM2 when not defined + if (attr && (s_editMode>0 || p1valdiff || (protocol>PROTO_PPMSIM && !IS_DSM2_PROTOCOL(protocol)))) { switch (m_posHorz) { case 0: CHECK_INCDEC_MODELVAR(event, g_model.protocol,0, PROTO_MAX-1); @@ -686,25 +684,28 @@ void menuProcModel(uint8_t event) #endif CHECK_INCDEC_MODELVAR(event, g_model.ppmNCH, -2, 4); break; - case 2: - CHECK_INCDEC_MODELVAR(event, g_model.ppmDelay, -4, 10); - break; } } break; case ITEM_MODEL_PROTOCOL_PARAMS: - if (protocol == PROTO_PPM || protocol == PROTO_FAAST) { + if (protocol <= PROTO_PPMSIM) { lcd_putsLeft( y, STR_PPMFRAME); lcd_puts(MODEL_PARAM_OFS+3*FW, y, STR_MS); lcd_outdezAtt(MODEL_PARAM_OFS, y, (int16_t)g_model.ppmFrameLength*5 + 225, ((attr && m_posHorz==0) ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0) | PREC1|LEFT); - lcd_putsiAtt(MODEL_PARAM_OFS+6*FW, y, STR_POSNEG, g_model.pulsePol, (attr && m_posHorz==1) ? INVERS : 0); + lcd_puts(MODEL_PARAM_OFS+8*FW+2, y, PSTR("us")); + lcd_outdezAtt(MODEL_PARAM_OFS+8*FW+2, y, (g_model.ppmDelay*50)+300, ((attr && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0)); + lcd_putcAtt(MODEL_PARAM_OFS+11*FW, y, g_model.pulsePol ? '-' : '+', (attr && m_posHorz==2) ? INVERS : 0); + if(attr && (s_editMode>0 || p1valdiff)) { switch (m_posHorz) { case 0: CHECK_INCDEC_MODELVAR(event, g_model.ppmFrameLength, -20, 20); break; case 1: + CHECK_INCDEC_MODELVAR(event, g_model.ppmDelay, -4, 10); + break; + case 2: CHECK_INCDEC_MODELVAR(event, g_model.pulsePol, 0, 1); break; } diff --git a/src/myeeprom.h b/src/myeeprom.h index 6a2933de5..f4fbd39ed 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -140,7 +140,7 @@ PACK(typedef struct t_EEGeneral { int8_t beeperLength:3; uint8_t hapticStrength:3; uint8_t gpsFormat:1; - uint8_t spare4:1; + uint8_t unexpectedShutdown:1; uint8_t speakerPitch; EXTRA_ARM_FIELDS @@ -506,11 +506,10 @@ PACK(typedef struct t_TimerData { enum Protocols { PROTO_PPM, + PROTO_PPM16, + PROTO_PPMSIM, PROTO_PXX, PROTO_DSM2, - PROTO_PPM16, - PROTO_FAAST, - PROTO_PPMSIM, PROTO_MAX }; diff --git a/src/open9x.cpp b/src/open9x.cpp index 2c35a648b..94eec7046 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -2527,13 +2527,16 @@ int main(void) #endif #if defined(PCBV4) - if (MCUSR != (1 << PORF)) + if (MCUSR != (1 << PORF) && !g_eeGeneral.unexpectedShutdown) #elif defined(PCBSTD) - if (MCUCSR != (1 << PORF)) + if (MCUCSR != (1 << PORF)) +#else + if (!g_eeGeneral.unexpectedShutdown) #endif { #ifdef SPLASH - if (g_model.protocol != PROTO_FAAST && g_model.protocol != PROTO_DSM2) + // TODO rather use another Model Parameter + if (g_model.protocol != PROTO_DSM2) doSplash(); #endif @@ -2548,6 +2551,13 @@ int main(void) checkAlarm(); } +#if defined(PCBARM) || defined(PCBV4) + if (!g_eeGeneral.unexpectedShutdown) { + g_eeGeneral.unexpectedShutdown = 1; + eeDirty(EE_GENERAL); + } +#endif + clearKeyEvents(); //make sure no keys are down before proceeding lcdSetRefVolt(g_eeGeneral.contrast); @@ -2630,6 +2640,8 @@ int main(void) // Time to switch off lcd_clear() ; displayPopup(STR_SHUTDOWN); + g_eeGeneral.unexpectedShutdown=0; + eeDirty(EE_GENERAL); eeCheck(true); lcd_clear() ; refreshDisplay() ; diff --git a/src/pulses_avr.cpp b/src/pulses_avr.cpp index 25efe9d9c..190ef14b8 100644 --- a/src/pulses_avr.cpp +++ b/src/pulses_avr.cpp @@ -55,7 +55,7 @@ inline void DSM2_EnableTXD(void) void set_timer3_capture( void ) ; void set_timer3_ppm( void ) ; -void setupPulsesPPM16( void ) ; +void setupPulsesPPM16( uint8_t proto ) ; void startPulses() { @@ -583,7 +583,6 @@ void setupPulses() break; #endif -#if defined(PPM16) case PROTO_PPM16 : TCCR1B = 0 ; // Stop counter OCR1A = 40000 ; // Next frame starts in 20 mS @@ -595,12 +594,24 @@ void setupPulses() TIMSK |= 0x10 ; // Enable COMPA TCCR1A = (0<