mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 16:25:16 +03:00
Vario (still untested). Flash savings.
This commit is contained in:
parent
32b6726968
commit
a7a530487b
11 changed files with 122 additions and 126 deletions
|
@ -473,7 +473,7 @@ void per10ms()
|
||||||
#if defined(AUDIO)
|
#if defined(AUDIO)
|
||||||
uint8_t warble = 0;
|
uint8_t warble = 0;
|
||||||
#endif
|
#endif
|
||||||
int8_t verticalSpeed = frskyHubData.baroAltitude_bp; // TODO to be modified of course!!
|
int8_t verticalSpeed = limit((int16_t)-100, frskyHubData.varioSpeed, (int16_t)+100);
|
||||||
|
|
||||||
uint16_t interval;
|
uint16_t interval;
|
||||||
if (verticalSpeed == 0) {
|
if (verticalSpeed == 0) {
|
||||||
|
@ -484,8 +484,7 @@ void per10ms()
|
||||||
verticalSpeed = -verticalSpeed;
|
verticalSpeed = -verticalSpeed;
|
||||||
warble = 1;
|
warble = 1;
|
||||||
}
|
}
|
||||||
if (verticalSpeed > 100) verticalSpeed = 100;
|
interval = (uint8_t)200 / verticalSpeed;
|
||||||
interval = (uint16_t)200 / verticalSpeed;
|
|
||||||
}
|
}
|
||||||
if (g_tmr10ms - s_varioTmr > interval) {
|
if (g_tmr10ms - s_varioTmr > interval) {
|
||||||
s_varioTmr = g_tmr10ms;
|
s_varioTmr = g_tmr10ms;
|
||||||
|
|
31
src/file.cpp
31
src/file.cpp
|
@ -31,8 +31,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PROGRESS_VERTICAL_BAR
|
|
||||||
|
|
||||||
#include "open9x.h"
|
#include "open9x.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "inttypes.h"
|
#include "inttypes.h"
|
||||||
|
@ -470,9 +468,7 @@ void RlcFile::writeRlc(uint8_t i_fileId, uint8_t typ, uint8_t*buf, uint16_t i_le
|
||||||
m_rlc_buf = buf;
|
m_rlc_buf = buf;
|
||||||
m_rlc_len = i_len;
|
m_rlc_len = i_len;
|
||||||
m_cur_rlc_len = 0;
|
m_cur_rlc_len = 0;
|
||||||
#if defined (PROGRESS_CIRCLE)
|
#if defined (EEPROM_PROGRESS_BAR)
|
||||||
m_ratio = (typ == FILE_TYP_MODEL ? 60 : 6);
|
|
||||||
#elif defined (PROGRESS_VERTICAL_BAR)
|
|
||||||
m_ratio = (typ == FILE_TYP_MODEL ? 100 : 10);
|
m_ratio = (typ == FILE_TYP_MODEL ? 100 : 10);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -590,32 +586,13 @@ void RlcFile::flush()
|
||||||
s_sync_write = false;
|
s_sync_write = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined (EEPROM_PROGRESS_BAR)
|
||||||
void RlcFile::DisplayProgressBar(uint8_t x)
|
void RlcFile::DisplayProgressBar(uint8_t x)
|
||||||
{
|
{
|
||||||
if (s_eeDirtyMsk || isWriting() || eeprom_buffer_size) {
|
if (s_eeDirtyMsk || isWriting() || eeprom_buffer_size) {
|
||||||
#if defined (PROGRESS_BAR)
|
|
||||||
uint8_t len = (s_eeDirtyMsk ? 123 : min((uint8_t)123, (uint8_t)((m_rlc_len) / 5 + eeprom_buffer_size)));
|
|
||||||
lcd_filled_rect(2, 1, 125, 5, SOLID, WHITE);
|
|
||||||
lcd_filled_rect(3, 2, 123-len, 3);
|
|
||||||
#elif defined (PROGRESS_CIRCLE)
|
|
||||||
lcd_filled_rect(x-1, 0, 7, 7, SOLID, WHITE);
|
|
||||||
uint8_t len = s_eeDirtyMsk ? 1 : limit(1, 12 - (uint8_t)(m_rlc_len/m_ratio), 12);
|
|
||||||
lcd_hline(x+1, 1, min((uint8_t)3, len));
|
|
||||||
if (len >= 3) {
|
|
||||||
lcd_vline(x+4, 2, min(3, len-3));
|
|
||||||
if (len >= 6) {
|
|
||||||
lcd_hline(x+4, 1+4, -min(3, len-6));
|
|
||||||
if (len >= 9) {
|
|
||||||
lcd_vline(x, 5, -min(3, len-9));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif defined (PROGRESS_VERTICAL_BAR)
|
|
||||||
uint8_t len = s_eeDirtyMsk ? 1 : limit((uint8_t)1, (uint8_t)(7 - (m_rlc_len/m_ratio)), (uint8_t)7);
|
uint8_t len = s_eeDirtyMsk ? 1 : limit((uint8_t)1, (uint8_t)(7 - (m_rlc_len/m_ratio)), (uint8_t)7);
|
||||||
lcd_filled_rect(x+1, 0, 5, FH, SOLID, WHITE);
|
lcd_filled_rect(x+1, 0, 5, FH, SOLID, WHITE);
|
||||||
lcd_filled_rect(x+2, 7-len, 3, len);
|
lcd_filled_rect(x+2, 7-len, 3, len);
|
||||||
#elif defined (PROGRESS_FIXED_CIRCLE)
|
}
|
||||||
lcd_square(x, 1, 5);
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
12
src/file.h
12
src/file.h
|
@ -126,7 +126,9 @@ class RlcFile: public EFile
|
||||||
uint8_t m_write1_byte;
|
uint8_t m_write1_byte;
|
||||||
uint8_t m_write_len;
|
uint8_t m_write_len;
|
||||||
uint8_t * m_write_buf;
|
uint8_t * m_write_buf;
|
||||||
|
#if defined (EEPROM_PROGRESS_BAR)
|
||||||
uint8_t m_ratio;
|
uint8_t m_ratio;
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -160,8 +162,18 @@ public:
|
||||||
uint16_t readRlc(uint8_t*buf, uint16_t i_len); // TODO should be like writeRlc?
|
uint16_t readRlc(uint8_t*buf, uint16_t i_len); // TODO should be like writeRlc?
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined (EEPROM_PROGRESS_BAR)
|
||||||
void DisplayProgressBar(uint8_t x);
|
void DisplayProgressBar(uint8_t x);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined (EEPROM_PROGRESS_BAR)
|
||||||
|
#define DISPLAY_PROGRESS_BAR(x) theFile.DisplayProgressBar(x)
|
||||||
|
#else
|
||||||
|
#define DISPLAY_PROGRESS_BAR(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint16_t evalChkSum();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/*eof*/
|
/*eof*/
|
||||||
|
|
|
@ -152,16 +152,6 @@ inline void getGpsDistance()
|
||||||
frskyHubData.maxGpsDistance = frskyHubData.gpsDistance;
|
frskyHubData.maxGpsDistance = frskyHubData.gpsDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int8_t parseTelemHubIndex(uint8_t index)
|
|
||||||
{
|
|
||||||
if (index > 0x39) {
|
|
||||||
if (index > 0x3b)
|
|
||||||
return -1; // invalid index
|
|
||||||
index -= 17;
|
|
||||||
}
|
|
||||||
return index*2;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TS_IDLE = 0, // waiting for 0x5e frame marker
|
TS_IDLE = 0, // waiting for 0x5e frame marker
|
||||||
TS_DATA_ID, // waiting for dataID
|
TS_DATA_ID, // waiting for dataID
|
||||||
|
@ -192,10 +182,13 @@ void parseTelemHubByte(uint8_t byte)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state == TS_DATA_ID) {
|
if (state == TS_DATA_ID) {
|
||||||
structPos = parseTelemHubIndex(byte);
|
if (byte > 0x3b) {
|
||||||
state = TS_DATA_LOW;
|
|
||||||
if (structPos < 0)
|
|
||||||
state = TS_IDLE;
|
state = TS_IDLE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
structPos = byte*2;
|
||||||
|
state = TS_DATA_LOW;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state == TS_DATA_LOW) {
|
if (state == TS_DATA_LOW) {
|
||||||
|
@ -258,6 +251,20 @@ void parseTelemHubByte(uint8_t byte)
|
||||||
frskyHubData.minAltitude = frskyHubData.baroAltitude_bp;
|
frskyHubData.minAltitude = frskyHubData.baroAltitude_bp;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case offsetof(FrskyHubData, baroAltitude_ap):
|
||||||
|
{
|
||||||
|
uint16_t actVario = frskyHubData.baroAltitude_bp - frskyHubData.lastBaroAltitude_bp;
|
||||||
|
actVario *= 100;
|
||||||
|
actVario += frskyHubData.baroAltitude_ap - frskyHubData.lastBaroAltitude_ap;
|
||||||
|
frskyHubData.varioSpeed = frskyHubData.varioSpeed - frskyHubData.varioQueue[frskyHubData.queuePointer] + actVario;
|
||||||
|
frskyHubData.varioQueue[frskyHubData.queuePointer] = actVario;
|
||||||
|
if (++frskyHubData.queuePointer > 4)
|
||||||
|
frskyHubData.queuePointer=0;
|
||||||
|
frskyHubData.lastBaroAltitude_bp = frskyHubData.baroAltitude_bp;
|
||||||
|
frskyHubData.lastBaroAltitude_ap = frskyHubData.baroAltitude_ap;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case offsetof(FrskyHubData, gpsAltitude_ap):
|
case offsetof(FrskyHubData, gpsAltitude_ap):
|
||||||
if (!frskyHubData.gpsAltitudeOffset)
|
if (!frskyHubData.gpsAltitudeOffset)
|
||||||
frskyHubData.gpsAltitudeOffset = -frskyHubData.gpsAltitude_bp;
|
frskyHubData.gpsAltitudeOffset = -frskyHubData.gpsAltitude_bp;
|
||||||
|
|
19
src/frsky.h
19
src/frsky.h
|
@ -109,14 +109,11 @@ PACK(struct FrskyHubData {
|
||||||
uint8_t cellsCount:4; // 4bits out of 16bits spare reused
|
uint8_t cellsCount:4; // 4bits out of 16bits spare reused
|
||||||
uint8_t minCellVolts; // 8bits out of 16bits spare reused
|
uint8_t minCellVolts; // 8bits out of 16bits spare reused
|
||||||
uint16_t current; // 0x28 Current
|
uint16_t current; // 0x28 Current
|
||||||
// 17 spares
|
int16_t varioQueue[5]; // circular-buffer
|
||||||
uint16_t volts_bp; // 0x3A
|
uint8_t queuePointer; // circular-buffer pointer
|
||||||
uint16_t volts_ap; // 0x3B
|
int8_t lastBaroAltitude_ap;
|
||||||
// end of FrSky Hub data
|
int16_t lastBaroAltitude_bp;
|
||||||
uint16_t gpsDistance;
|
int16_t varioSpeed;
|
||||||
int16_t gpsAltitudeOffset;
|
|
||||||
uint8_t minCellMinVolts;
|
|
||||||
/* order is important starting from here */
|
|
||||||
int16_t minAltitude;
|
int16_t minAltitude;
|
||||||
int16_t maxAltitude;
|
int16_t maxAltitude;
|
||||||
uint16_t maxRpm;
|
uint16_t maxRpm;
|
||||||
|
@ -124,6 +121,12 @@ PACK(struct FrskyHubData {
|
||||||
int16_t maxTemperature2;
|
int16_t maxTemperature2;
|
||||||
uint16_t maxGpsSpeed;
|
uint16_t maxGpsSpeed;
|
||||||
uint16_t maxGpsDistance;
|
uint16_t maxGpsDistance;
|
||||||
|
uint16_t gpsDistance;
|
||||||
|
int16_t gpsAltitudeOffset;
|
||||||
|
uint16_t volts_bp; // 0x3A
|
||||||
|
uint16_t volts_ap; // 0x3B
|
||||||
|
// end of FrSky Hub data
|
||||||
|
uint8_t minCellMinVolts;
|
||||||
});
|
});
|
||||||
|
|
||||||
#elif defined(WS_HOW_HIGH)
|
#elif defined(WS_HOW_HIGH)
|
||||||
|
|
|
@ -663,10 +663,7 @@ void menuProcDiagCalib(uint8_t event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t sum = 0;
|
g_eeGeneral.chkSum = evalChkSum();
|
||||||
for (uint8_t i=0; i<12; i++)
|
|
||||||
sum += g_eeGeneral.calibMid[i];
|
|
||||||
g_eeGeneral.chkSum = sum;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -323,5 +323,5 @@ void menuMainView(uint8_t event)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
theFile.DisplayProgressBar(20*FW+1);
|
DISPLAY_PROGRESS_BAR(20*FW+1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,7 +276,7 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
theFile.DisplayProgressBar(menuTab ? lcd_lastPos-2*FW-((curr+1)/10*FWNUM)-2 : 20*FW+1);
|
DISPLAY_PROGRESS_BAR(menuTab ? lcd_lastPos-2*FW-((curr+1)/10*FWNUM)-2 : 20*FW+1);
|
||||||
|
|
||||||
if (s_editMode<=0) {
|
if (s_editMode<=0) {
|
||||||
if (scrollUD) {
|
if (scrollUD) {
|
||||||
|
|
|
@ -401,6 +401,7 @@ void EditName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, boo
|
||||||
if (event==EVT_KEY_LONG(KEY_LEFT))
|
if (event==EVT_KEY_LONG(KEY_LEFT))
|
||||||
killEvents(KEY_LEFT);
|
killEvents(KEY_LEFT);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
name[cur] = v;
|
name[cur] = v;
|
||||||
|
@ -418,7 +419,9 @@ void EditName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, boo
|
||||||
void menuProcModel(uint8_t event)
|
void menuProcModel(uint8_t event)
|
||||||
{
|
{
|
||||||
lcd_outdezNAtt(7*FW,0,g_eeGeneral.currModel+1,INVERS+LEADING0,2);
|
lcd_outdezNAtt(7*FW,0,g_eeGeneral.currModel+1,INVERS+LEADING0,2);
|
||||||
MENU(STR_MENUSETUP, menuTabModel, e_Model, (g_model.protocol==PROTO_PPM||g_model.protocol==PROTO_FAAST||g_model.protocol==PROTO_DSM2||g_model.protocol==PROTO_PXX ? 12 : 11), {0,ZCHAR|(sizeof(g_model.name)-1),2,2,0,0,0,0,0,6,2,1});
|
|
||||||
|
uint8_t protocol = g_model.protocol;
|
||||||
|
MENU(STR_MENUSETUP, menuTabModel, e_Model, (protocol==PROTO_PPM||protocol==PROTO_FAAST||protocol==PROTO_DSM2||protocol==PROTO_PXX ? 12 : 11), {0,ZCHAR|(sizeof(g_model.name)-1),2,2,0,0,0,0,0,6,2,1});
|
||||||
|
|
||||||
uint8_t sub = m_posVert;
|
uint8_t sub = m_posVert;
|
||||||
uint8_t y = 1*FH;
|
uint8_t y = 1*FH;
|
||||||
|
@ -521,21 +524,17 @@ void menuProcModel(uint8_t event)
|
||||||
|
|
||||||
if(s_pgOfs<subN) {
|
if(s_pgOfs<subN) {
|
||||||
lcd_putsLeft( y, STR_PROTO);
|
lcd_putsLeft( y, STR_PROTO);
|
||||||
lcd_putsiAtt(PARAM_OFS, y, STR_VPROTOS, g_model.protocol,
|
lcd_putsiAtt(PARAM_OFS, y, STR_VPROTOS, protocol,
|
||||||
(sub==subN && m_posHorz==0 ? (s_editMode>0 ? BLINK|INVERS : INVERS):0));
|
(sub==subN && m_posHorz==0 ? (s_editMode>0 ? BLINK|INVERS : INVERS):0));
|
||||||
if (g_model.protocol == PROTO_PPM || g_model.protocol == PROTO_FAAST) {
|
if (protocol == PROTO_PPM || protocol == PROTO_FAAST) {
|
||||||
lcd_putsiAtt(PARAM_OFS+4*FW, y, STR_NCHANNELS, g_model.ppmNCH+2, (sub==subN && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
lcd_putsiAtt(PARAM_OFS+4*FW, y, STR_NCHANNELS, g_model.ppmNCH+2, (sub==subN && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
||||||
lcd_puts(PARAM_OFS+11*FW, y, PSTR("u"));
|
lcd_puts(PARAM_OFS+11*FW, y, PSTR("u"));
|
||||||
lcd_outdezAtt(PARAM_OFS+11*FW, y, (g_model.ppmDelay*50)+300, ((sub==subN && m_posHorz==2) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0));
|
lcd_outdezAtt(PARAM_OFS+11*FW, y, (g_model.ppmDelay*50)+300, ((sub==subN && m_posHorz==2) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0));
|
||||||
}
|
}
|
||||||
#ifdef DSM2
|
#ifdef DSM2
|
||||||
// TODO optimize that?
|
else if (protocol == PROTO_DSM2) {
|
||||||
else if (g_model.protocol == PROTO_DSM2) {
|
|
||||||
if (m_posHorz > 1) m_posHorz = 1;
|
if (m_posHorz > 1) m_posHorz = 1;
|
||||||
int8_t x;
|
int8_t x = limit((int8_t)0, (int8_t)g_model.ppmNCH, (int8_t)2);
|
||||||
x = g_model.ppmNCH;
|
|
||||||
if ( x < 0 ) x = 0;
|
|
||||||
if ( x > 2 ) x = 2;
|
|
||||||
g_model.ppmNCH = x;
|
g_model.ppmNCH = x;
|
||||||
lcd_putsiAtt(PARAM_OFS+5*FW, y, STR_DSM2MODE, x, (sub==subN && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
lcd_putsiAtt(PARAM_OFS+5*FW, y, STR_DSM2MODE, x, (sub==subN && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
||||||
}
|
}
|
||||||
|
@ -543,14 +542,14 @@ void menuProcModel(uint8_t event)
|
||||||
else if (sub==subN) {
|
else if (sub==subN) {
|
||||||
m_posHorz = 0;
|
m_posHorz = 0;
|
||||||
}
|
}
|
||||||
if (sub==subN && (s_editMode>0 || p1valdiff || (g_model.protocol!=PROTO_PPM && g_model.protocol!=PROTO_FAAST && g_model.protocol!=PROTO_DSM2))) { // TODO avoid DSM2 when not defined
|
if (sub==subN && (s_editMode>0 || p1valdiff || (protocol!=PROTO_PPM && protocol!=PROTO_FAAST && protocol!=PROTO_DSM2))) { // TODO avoid DSM2 when not defined
|
||||||
switch (m_posHorz) {
|
switch (m_posHorz) {
|
||||||
case 0:
|
case 0:
|
||||||
CHECK_INCDEC_MODELVAR(event, g_model.protocol,0, PROTO_MAX-1);
|
CHECK_INCDEC_MODELVAR(event, g_model.protocol,0, PROTO_MAX-1);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
#ifdef DSM2
|
#ifdef DSM2
|
||||||
if (g_model.protocol == PROTO_DSM2)
|
if (protocol == PROTO_DSM2)
|
||||||
CHECK_INCDEC_MODELVAR(event, g_model.ppmNCH, 0, 2);
|
CHECK_INCDEC_MODELVAR(event, g_model.ppmNCH, 0, 2);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -565,7 +564,7 @@ void menuProcModel(uint8_t event)
|
||||||
}subN++;
|
}subN++;
|
||||||
|
|
||||||
if(s_pgOfs<subN) {
|
if(s_pgOfs<subN) {
|
||||||
if (g_model.protocol == PROTO_PPM || g_model.protocol == PROTO_FAAST) {
|
if (protocol == PROTO_PPM || protocol == PROTO_FAAST) {
|
||||||
lcd_putsLeft( y, STR_PPMFRAME);
|
lcd_putsLeft( y, STR_PPMFRAME);
|
||||||
lcd_puts(PARAM_OFS+3*FW, y, STR_MS);
|
lcd_puts(PARAM_OFS+3*FW, y, STR_MS);
|
||||||
lcd_outdezAtt(PARAM_OFS, y, (int16_t)g_model.ppmFrameLength*5 + 225, ((sub==subN && m_posHorz==0) ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0) | PREC1|LEFT);
|
lcd_outdezAtt(PARAM_OFS, y, (int16_t)g_model.ppmFrameLength*5 + 225, ((sub==subN && m_posHorz==0) ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0) | PREC1|LEFT);
|
||||||
|
@ -583,9 +582,9 @@ void menuProcModel(uint8_t event)
|
||||||
}
|
}
|
||||||
// TODO port PPM16 ppmDelay from er9x
|
// TODO port PPM16 ppmDelay from er9x
|
||||||
#if defined(DSM2) || defined(PXX)
|
#if defined(DSM2) || defined(PXX)
|
||||||
else if (g_model.protocol == PROTO_DSM2 || g_model.protocol == PROTO_PXX) {
|
else if (protocol == PROTO_DSM2 || protocol == PROTO_PXX) {
|
||||||
lcd_putsLeft( y, STR_RXNUM);
|
lcd_putsLeft( y, STR_RXNUM);
|
||||||
lcd_outdezNAtt(PARAM_OFS-(g_model.protocol==PROTO_DSM2 ? 0 : 3*FW), y, g_model.modelId, ((sub==subN && m_posHorz==0) ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0) | LEADING0|LEFT, 2);
|
lcd_outdezNAtt(PARAM_OFS-(protocol==PROTO_DSM2 ? 0 : 3*FW), y, g_model.modelId, ((sub==subN && m_posHorz==0) ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0) | LEADING0|LEFT, 2);
|
||||||
|
|
||||||
if (sub==subN && (s_editMode>0 || p1valdiff)) {
|
if (sub==subN && (s_editMode>0 || p1valdiff)) {
|
||||||
switch (m_posHorz) {
|
switch (m_posHorz) {
|
||||||
|
@ -596,7 +595,7 @@ void menuProcModel(uint8_t event)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PXX)
|
#if defined(PXX)
|
||||||
if (g_model.protocol == PROTO_PXX) {
|
if (protocol == PROTO_PXX) {
|
||||||
lcd_putsAtt(PARAM_OFS, y, STR_SYNCMENU, ((sub==subN && m_posHorz==1) ? INVERS : 0));
|
lcd_putsAtt(PARAM_OFS, y, STR_SYNCMENU, ((sub==subN && m_posHorz==1) ? INVERS : 0));
|
||||||
if (sub==subN && m_posHorz==1) {
|
if (sub==subN && m_posHorz==1) {
|
||||||
s_editMode = false;
|
s_editMode = false;
|
||||||
|
@ -829,7 +828,7 @@ void menuProcCurveOne(uint8_t event)
|
||||||
|
|
||||||
TITLE(STR_MENUCURVE);
|
TITLE(STR_MENUCURVE);
|
||||||
lcd_outdezAtt(5*FW+1, 0, s_curveChan+1, INVERS|LEFT);
|
lcd_outdezAtt(5*FW+1, 0, s_curveChan+1, INVERS|LEFT);
|
||||||
theFile.DisplayProgressBar(20*FW+1);
|
DISPLAY_PROGRESS_BAR(20*FW+1);
|
||||||
|
|
||||||
if (s_curveChan >= MAX_CURVE5) {
|
if (s_curveChan >= MAX_CURVE5) {
|
||||||
points = 9;
|
points = 9;
|
||||||
|
|
|
@ -525,16 +525,29 @@ void clearKeyEvents()
|
||||||
putEvent(0);
|
putEvent(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SPLASH
|
#define INAC_DEVISOR 256 // Bypass splash screen with stick movement
|
||||||
void doSplash()
|
uint16_t stickMoveValue()
|
||||||
{
|
{
|
||||||
if(!g_eeGeneral.disableSplashScreen)
|
uint16_t sum = 0;
|
||||||
|
for (uint8_t i=0; i<4; i++)
|
||||||
|
sum += anaIn(i)/INAC_DEVISOR;
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkBacklight()
|
||||||
{
|
{
|
||||||
if (getSwitch(g_eeGeneral.lightSw, 0) || g_eeGeneral.lightAutoOff)
|
if (getSwitch(g_eeGeneral.lightSw, 0) || g_eeGeneral.lightAutoOff)
|
||||||
BACKLIGHT_ON;
|
BACKLIGHT_ON;
|
||||||
else
|
else
|
||||||
BACKLIGHT_OFF;
|
BACKLIGHT_OFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SPLASH
|
||||||
|
void doSplash()
|
||||||
|
{
|
||||||
|
if(!g_eeGeneral.disableSplashScreen)
|
||||||
|
{
|
||||||
|
checkBacklight() ;
|
||||||
lcd_clear();
|
lcd_clear();
|
||||||
lcd_img(0, 0, s9xsplash,0,0);
|
lcd_img(0, 0, s9xsplash,0,0);
|
||||||
refreshDisplay();
|
refreshDisplay();
|
||||||
|
@ -546,11 +559,7 @@ void doSplash()
|
||||||
getADC_filt(); // init ADC array
|
getADC_filt(); // init ADC array
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INAC_DEVISOR 256 // Bypass splash screen with stick movement
|
uint16_t inacSum = stickMoveValue();
|
||||||
uint16_t inacSum = 0;
|
|
||||||
// TODO uint16_t inacSum = stickMoveValue();
|
|
||||||
for(uint8_t i=0; i<4; i++)
|
|
||||||
inacSum += anaIn(i)/INAC_DEVISOR;
|
|
||||||
|
|
||||||
uint16_t tgtime = get_tmr10ms() + SPLASH_TIMEOUT; //2sec splash screen
|
uint16_t tgtime = get_tmr10ms() + SPLASH_TIMEOUT; //2sec splash screen
|
||||||
while (tgtime != get_tmr10ms())
|
while (tgtime != get_tmr10ms())
|
||||||
|
@ -561,17 +570,11 @@ void doSplash()
|
||||||
#else
|
#else
|
||||||
getADC_filt();
|
getADC_filt();
|
||||||
#endif
|
#endif
|
||||||
uint16_t tsum = 0;
|
uint16_t tsum = stickMoveValue();
|
||||||
for(uint8_t i=0; i<4; i++)
|
|
||||||
tsum += anaIn(i)/INAC_DEVISOR;
|
|
||||||
|
|
||||||
if(keyDown() || (tsum!=inacSum)) return; //wait for key release
|
if(keyDown() || (tsum!=inacSum)) return; //wait for key release
|
||||||
|
|
||||||
// TODO check_backlight() ;
|
checkBacklight();
|
||||||
if(getSwitch(g_eeGeneral.lightSw,0) || g_eeGeneral.lightAutoOff)
|
|
||||||
BACKLIGHT_ON;
|
|
||||||
else
|
|
||||||
BACKLIGHT_OFF;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -635,10 +638,7 @@ void checkTHR()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getSwitch(g_eeGeneral.lightSw,0) || g_eeGeneral.lightAutoOff)
|
checkBacklight();
|
||||||
BACKLIGHT_ON;
|
|
||||||
else
|
|
||||||
BACKLIGHT_OFF;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,10 +673,7 @@ void checkSwitches()
|
||||||
}
|
}
|
||||||
if(i==SW_Trainer || keyDown()) return;
|
if(i==SW_Trainer || keyDown()) return;
|
||||||
|
|
||||||
if(getSwitch(g_eeGeneral.lightSw,0) || g_eeGeneral.lightAutoOff)
|
checkBacklight();
|
||||||
BACKLIGHT_ON;
|
|
||||||
else
|
|
||||||
BACKLIGHT_OFF;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1269,10 +1266,12 @@ void perOut(uint8_t phase)
|
||||||
v = getValue(k <= MIXSRC_3POS ? k : k-MAX_SWITCH);
|
v = getValue(k <= MIXSRC_3POS ? k : k-MAX_SWITCH);
|
||||||
|
|
||||||
//========== DELAYS ===============
|
//========== DELAYS ===============
|
||||||
|
uint8_t swTog;
|
||||||
if (sw) { // switch on? (if no switch selected => on)
|
if (sw) { // switch on? (if no switch selected => on)
|
||||||
if (md->delayUp) {
|
swTog = !swOn[i];
|
||||||
if (!swOn[i]) {
|
|
||||||
swOn[i] = true;
|
swOn[i] = true;
|
||||||
|
if (md->delayUp) {
|
||||||
|
if (swTog) {
|
||||||
sDelay[i] = md->delayUp * 100;
|
sDelay[i] = md->delayUp * 100;
|
||||||
}
|
}
|
||||||
if (sDelay[i]) { // perform delay
|
if (sDelay[i]) { // perform delay
|
||||||
|
@ -1285,15 +1284,15 @@ void perOut(uint8_t phase)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
swOn[i] = true; // TODO optim
|
|
||||||
if (md->mixWarn) mixWarning |= 1<<(md->mixWarn-1); // Mix warning
|
if (md->mixWarn) mixWarning |= 1<<(md->mixWarn-1); // Mix warning
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bool has_delay = false;
|
bool has_delay = false;
|
||||||
if (md->delayDown) {
|
swTog = swOn[i];
|
||||||
if (swOn[i]) {
|
|
||||||
sDelay[i] = md->delayDown * 100;
|
|
||||||
swOn[i] = false;
|
swOn[i] = false;
|
||||||
|
if (md->delayDown) {
|
||||||
|
if (swTog) {
|
||||||
|
sDelay[i] = md->delayDown * 100;
|
||||||
}
|
}
|
||||||
if (sDelay[i]) { // perform delay
|
if (sDelay[i]) { // perform delay
|
||||||
if(tick10ms) sDelay[i]--;
|
if(tick10ms) sDelay[i]--;
|
||||||
|
@ -1304,7 +1303,6 @@ void perOut(uint8_t phase)
|
||||||
v = -1024;
|
v = -1024;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
swOn[i] = false;
|
|
||||||
if (!has_delay) {
|
if (!has_delay) {
|
||||||
if (md->speedDown) {
|
if (md->speedDown) {
|
||||||
if (md->mltpx==MLTPX_REP) continue;
|
if (md->mltpx==MLTPX_REP) continue;
|
||||||
|
@ -1721,10 +1719,7 @@ void perMain()
|
||||||
if(g_LightOffCounter) g_LightOffCounter--;
|
if(g_LightOffCounter) g_LightOffCounter--;
|
||||||
if(evt) g_LightOffCounter = g_eeGeneral.lightAutoOff*500; // on keypress turn the light on 5*100
|
if(evt) g_LightOffCounter = g_eeGeneral.lightAutoOff*500; // on keypress turn the light on 5*100
|
||||||
|
|
||||||
if( getSwitch(g_eeGeneral.lightSw,0) || g_LightOffCounter)
|
checkBacklight();
|
||||||
BACKLIGHT_ON;
|
|
||||||
else
|
|
||||||
BACKLIGHT_OFF;
|
|
||||||
|
|
||||||
g_menuStack[g_menuStackPtr](evt);
|
g_menuStack[g_menuStackPtr](evt);
|
||||||
refreshDisplay();
|
refreshDisplay();
|
||||||
|
|
11
src/pers.cpp
11
src/pers.cpp
|
@ -50,14 +50,21 @@ void generalDefault()
|
||||||
g_eeGeneral.chkSum = (0x200 * 7) + (0x180 * 5);
|
g_eeGeneral.chkSum = (0x200 * 7) + (0x180 * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t evalChkSum()
|
||||||
|
{
|
||||||
|
uint16_t sum=0;
|
||||||
|
for (int i=0; i<12;i++)
|
||||||
|
sum += g_eeGeneral.calibMid[i];
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
bool eeLoadGeneral()
|
bool eeLoadGeneral()
|
||||||
{
|
{
|
||||||
theFile.openRlc(FILE_GENERAL);
|
theFile.openRlc(FILE_GENERAL);
|
||||||
if (theFile.readRlc((uint8_t*)&g_eeGeneral, 1) == 1 && g_eeGeneral.myVers == EEPROM_VER) {
|
if (theFile.readRlc((uint8_t*)&g_eeGeneral, 1) == 1 && g_eeGeneral.myVers == EEPROM_VER) {
|
||||||
theFile.openRlc(FILE_GENERAL); // TODO include this openRlc inside readRlc
|
theFile.openRlc(FILE_GENERAL); // TODO include this openRlc inside readRlc
|
||||||
if (theFile.readRlc((uint8_t*)&g_eeGeneral, sizeof(g_eeGeneral)) <= sizeof(EEGeneral)) {
|
if (theFile.readRlc((uint8_t*)&g_eeGeneral, sizeof(g_eeGeneral)) <= sizeof(EEGeneral)) {
|
||||||
uint16_t sum=0;
|
uint16_t sum = evalChkSum();
|
||||||
for (int i=0; i<12;i++) sum += g_eeGeneral.calibMid[i];
|
|
||||||
if (g_eeGeneral.chkSum == sum) {
|
if (g_eeGeneral.chkSum == sum) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue