Issue 177 fixed (Vario limits). To be tested. Perhaps some flash saving to find here. Companion9x needs to be updated.
This commit is contained in:
@@ -41,8 +41,8 @@ PACK(typedef struct {
|
||||
FrSkyBarData bars[4];
|
||||
uint8_t lines[4*2*2];
|
||||
uint8_t varioSource;
|
||||
uint8_t varioSpeedUpMin; // if increment in 0.2m/s = 3.0m/s max
|
||||
uint8_t varioSpeedDownMin;
|
||||
uint8_t varioCenterMin;
|
||||
uint8_t varioCenterMax;
|
||||
uint8_t spare[4];
|
||||
}) FrSkyData_v212;
|
||||
|
||||
@@ -191,8 +191,8 @@ bool eeConvert()
|
||||
g_model.frsky.blades = oldModel.frsky.blades;
|
||||
g_model.frsky.currentSource = oldModel.frsky.currentSource;
|
||||
g_model.frsky.varioSource = oldModel.frsky.varioSource;
|
||||
g_model.frsky.varioSpeedUpMin = oldModel.frsky.varioSpeedUpMin;
|
||||
g_model.frsky.varioSpeedDownMin = oldModel.frsky.varioSpeedDownMin;
|
||||
g_model.frsky.varioCenterMax = oldModel.frsky.varioCenterMax;
|
||||
g_model.frsky.varioCenterMin = oldModel.frsky.varioCenterMin;
|
||||
for (uint8_t i=0; i<2; i++) {
|
||||
g_model.frsky.channels[i] = oldModel.frsky.channels[i];
|
||||
g_model.frsky.rssiAlarms[i] = oldModel.frsky.rssiAlarms[i];
|
||||
|
||||
+24
-8
@@ -776,14 +776,29 @@ NOINLINE void check_frsky()
|
||||
static uint16_t s_varioTmr = 0;
|
||||
if (isFunctionActive(FUNC_VARIO)) {
|
||||
#if defined(AUDIO)
|
||||
int16_t varioSpeedUpMin = (g_model.frsky.varioSpeedUpMin - VARIO_SPEED_LIMIT_UP_CENTER)*VARIO_SPEED_LIMIT_MUL;
|
||||
int16_t varioSpeedDownMin = (VARIO_SPEED_LIMIT_DOWN_OFF - g_model.frsky.varioSpeedDownMin)*(-VARIO_SPEED_LIMIT_MUL);
|
||||
int16_t verticalSpeed = limit((int16_t)(-VARIO_SPEED_LIMIT*100), frskyData.varioSpeed, (int16_t)(+VARIO_SPEED_LIMIT*100));
|
||||
// conversion in cm/s
|
||||
do {
|
||||
int16_t verticalSpeed;
|
||||
int16_t varioCenterMax = (int16_t)g_model.frsky.varioCenterMax * 10;
|
||||
if (frskyData.varioSpeed >= varioCenterMax) {
|
||||
verticalSpeed = frskyData.varioSpeed - varioCenterMax;
|
||||
int16_t varioMax = (10+(int16_t)g_model.frsky.varioMax) * 100;
|
||||
if (verticalSpeed > varioMax) verticalSpeed = varioMax;
|
||||
verticalSpeed = (verticalSpeed * 10) / ((varioMax-varioCenterMax) / 100);
|
||||
}
|
||||
else {
|
||||
int16_t varioCenterMin = (int16_t)g_model.frsky.varioCenterMin * 10;
|
||||
if (frskyData.varioSpeed <= varioCenterMin) {
|
||||
verticalSpeed = frskyData.varioSpeed - varioCenterMin;
|
||||
int16_t varioMin = (-10+(int16_t)g_model.frsky.varioMin) * 100;
|
||||
if (verticalSpeed < varioMin) verticalSpeed = varioMin;
|
||||
verticalSpeed = (verticalSpeed * 10) / ((varioCenterMin-varioMin) / 100);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (verticalSpeed <= varioSpeedDownMin || verticalSpeed >= varioSpeedUpMin) { // check thresholds here in cm/s
|
||||
if (varioSpeedUpMin < 0 && verticalSpeed >= varioSpeedUpMin) {
|
||||
verticalSpeed -= varioSpeedUpMin;
|
||||
}
|
||||
uint16_t tmr10ms = g_tmr10ms;
|
||||
if (verticalSpeed < 0 || tmr10ms > s_varioTmr) {
|
||||
uint8_t SoundVarioBeepTime = (1600 - verticalSpeed) / 100;
|
||||
@@ -791,7 +806,8 @@ NOINLINE void check_frsky()
|
||||
s_varioTmr = tmr10ms + (SoundVarioBeepTime*2);
|
||||
AUDIO_VARIO(SoundVarioBeepFreq, SoundVarioBeepTime);
|
||||
}
|
||||
}
|
||||
|
||||
} while(0);
|
||||
#else
|
||||
int8_t verticalSpeed = limit((int16_t)-100, (int16_t)(frskyData.varioSpeed/10), (int16_t)+100);
|
||||
|
||||
|
||||
@@ -71,11 +71,6 @@ class FrskyValueWithMinMax: public FrskyValueWithMin {
|
||||
#define EARTH_RADIUS ((uint32_t)111194)
|
||||
|
||||
#define VARIO_QUEUE_LENGTH 5
|
||||
#define VARIO_SPEED_LIMIT 10 //m/s
|
||||
#define VARIO_SPEED_LIMIT_MUL 10 //to get 0.1m/s steps
|
||||
#define VARIO_SPEED_LIMIT_DOWN_OFF (100+1) //100 steps + OFF
|
||||
#define VARIO_SPEED_LIMIT_UP_CENTER 10
|
||||
#define VARIO_SPEED_LIMIT_UP_MAX (10+30)
|
||||
|
||||
#if defined(FRSKY_HUB)
|
||||
PACK(struct FrskyHubData {
|
||||
|
||||
+13
-9
@@ -3203,7 +3203,7 @@ enum menuModelTelemetryItems {
|
||||
|
||||
void menuModelTelemetry(uint8_t event)
|
||||
{
|
||||
MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX+1, {0, (uint8_t)-1, 1, 0, 2, 2, (uint8_t)-1, 1, 0, 2, 2, (uint8_t)-1, 1, 1, USRDATA_LINES 0, 0, IF_VARIO((uint8_t)-1) IF_VARIO(0) IF_VARIO(1) 0, 2, 2, 2, 2, 0, 2, 2, 2, IF_CPUARM(2) IF_CPUARM(0) IF_CPUARM(2) IF_CPUARM(2) IF_CPUARM(2) 2 });
|
||||
MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX+1, {0, (uint8_t)-1, 1, 0, 2, 2, (uint8_t)-1, 1, 0, 2, 2, (uint8_t)-1, 1, 1, USRDATA_LINES 0, 0, IF_VARIO((uint8_t)-1) IF_VARIO(0) IF_VARIO(3) 0, 2, 2, 2, 2, 0, 2, 2, 2, IF_CPUARM(2) IF_CPUARM(0) IF_CPUARM(2) IF_CPUARM(2) IF_CPUARM(2) 2 });
|
||||
|
||||
uint8_t sub = m_posVert - 1;
|
||||
|
||||
@@ -3369,19 +3369,23 @@ void menuModelTelemetry(uint8_t event)
|
||||
|
||||
case ITEM_TELEMETRY_VARIO_SPEED:
|
||||
lcd_putsLeft(y, STR_LIMIT);
|
||||
if (!g_model.frsky.varioSpeedDownMin)
|
||||
lcd_putsAtt(TELEM_COL2, y, STR_OFF, ((attr && m_posHorz==0) ? blink : 0));
|
||||
else
|
||||
lcd_outdezAtt(TELEM_COL2, y, -VARIO_SPEED_LIMIT_MUL*(VARIO_SPEED_LIMIT_DOWN_OFF - g_model.frsky.varioSpeedDownMin), ((attr && m_posHorz==0) ? blink : 0)|PREC2|LEFT);
|
||||
lcd_outdezAtt(TELEM_COL2+6*FW, y, VARIO_SPEED_LIMIT_MUL*(g_model.frsky.varioSpeedUpMin - VARIO_SPEED_LIMIT_UP_CENTER), ((attr && m_posHorz==1) ? blink : 0)|PREC2|LEFT);
|
||||
|
||||
lcd_outdezAtt(TELEM_COL2, y, -10+g_model.frsky.varioMin, ((attr && m_posHorz==0) ? blink : 0)|LEFT);
|
||||
lcd_outdezAtt(TELEM_COL2+7*FW, y, g_model.frsky.varioCenterMin, ((attr && m_posHorz==1) ? blink : 0)|PREC1);
|
||||
lcd_outdezAtt(TELEM_COL2+10*FW, y, g_model.frsky.varioCenterMax, ((attr && m_posHorz==2) ? blink : 0)|PREC1);
|
||||
lcd_outdezAtt(TELEM_COL2+13*FW+2, y, 10+g_model.frsky.varioMax, ((attr && m_posHorz==3) ? blink : 0));
|
||||
if (attr && (s_editMode>0 || p1valdiff)) {
|
||||
switch (m_posHorz) {
|
||||
case 0:
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioSpeedDownMin, 0, VARIO_SPEED_LIMIT_DOWN_OFF);
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioMin, -7, 7);
|
||||
break;
|
||||
case 1:
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioSpeedUpMin, 0, VARIO_SPEED_LIMIT_UP_MAX);
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioCenterMin, -10, min<int8_t>(0, g_model.frsky.varioCenterMax));
|
||||
break;
|
||||
case 2:
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioCenterMax, max<int8_t>(-10, g_model.frsky.varioCenterMin), +10);
|
||||
break;
|
||||
case 3:
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioMax, -7, 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-9
@@ -509,9 +509,11 @@ PACK(typedef struct t_FrSkyData {
|
||||
uint8_t screensType;
|
||||
FrSkyScreenData screens[MAX_FRSKY_SCREENS];
|
||||
uint8_t varioSource;
|
||||
uint8_t varioSpeedUpMin; // if increment in 0.2m/s = 3.0m/s max
|
||||
uint8_t varioSpeedDownMin;
|
||||
uint8_t spare[4];
|
||||
uint8_t varioCenterMax;
|
||||
uint8_t varioCenterMin;
|
||||
int8_t varioMin;
|
||||
int8_t varioMax;
|
||||
uint8_t spare[2];
|
||||
}) FrSkyData;
|
||||
#else
|
||||
#define MAX_FRSKY_SCREENS 2
|
||||
@@ -519,15 +521,16 @@ PACK(typedef struct t_FrSkyData {
|
||||
FrSkyChannelData channels[2];
|
||||
uint8_t usrProto:2; // Protocol in FrSky user data, 0=None, 1=FrSky hub, 2=WS HowHigh, 3=Halcyon
|
||||
uint8_t blades:2; // How many blades for RPMs, 0=2 blades, 1=3 blades
|
||||
uint8_t spare1:4;
|
||||
uint8_t voltsSource:3;
|
||||
uint8_t currentSource:3;
|
||||
uint8_t screensType:2;
|
||||
uint8_t varioSource:2;
|
||||
int8_t varioMin:4;
|
||||
int8_t varioMax:4;
|
||||
FrSkyRSSIAlarm rssiAlarms[2];
|
||||
FrSkyScreenData screens[MAX_FRSKY_SCREENS];
|
||||
uint8_t varioSource:3;
|
||||
uint8_t varioSpeedUpMin:5; // if increment in 0.2m/s = 3.0m/s max
|
||||
uint8_t varioSpeedDownMin;
|
||||
uint8_t voltsSource:3;
|
||||
int8_t varioCenterMin:5;
|
||||
uint8_t currentSource:3;
|
||||
int8_t varioCenterMax:5;
|
||||
}) FrSkyData;
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user