Issue 67 fixed (comma missing!)

Issue 63 fixed (InstantTrim, Trims2Ofs to double check before release)
Issue 68 fixed (better names for vario sources)
[gruvin] 2 digits for voltage calibration
This commit is contained in:
bsongis
2012-08-10 20:34:33 +00:00
parent 9574eadd44
commit e84ece8055
13 changed files with 141 additions and 108 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ const char * audioFilenames[] = {
"thralert", "thralert",
"swalert", "swalert",
"eebad", "eebad",
"eeformat" "eeformat",
"error", "error",
"keyup", "keyup",
"keydown", "keydown",
+8
View File
@@ -806,7 +806,15 @@ void menuProcDiagAna(uint8_t event)
// Voltage calibration // Voltage calibration
lcd_putsLeft(6*FH-2, STR_BATT_CALIB); lcd_putsLeft(6*FH-2, STR_BATT_CALIB);
#if defined (PCBV4)
// Gruvin wants 2 decimal places and instant update of volts calib field when button pressed
static uint16_t adcBatt;
adcBatt = ((adcBatt * 7) + anaIn(7)) / 8; // running average, sourced directly (to avoid unending debate :P)
uint32_t batCalV = ((uint32_t)adcBatt*1390 + (10*(int32_t)adcBatt*g_eeGeneral.vBatCalib)/8) / BandGap;
lcd_outdezNAtt(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, batCalV, PREC2|(m_posVert==1 ? INVERS : 0));
#else
putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, g_vbat100mV, (m_posVert==1 ? INVERS : 0)); putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, g_vbat100mV, (m_posVert==1 ? INVERS : 0));
#endif
if (m_posVert==1) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatCalib, -127, 127); if (m_posVert==1) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatCalib, -127, 127);
#if defined(PCBARM) && defined(REVB) #if defined(PCBARM) && defined(REVB)
+1 -1
View File
@@ -200,7 +200,7 @@ void menuMainView(uint8_t event)
uint8_t phase = s_perout_flight_phase; uint8_t phase = s_perout_flight_phase;
lcd_putsnAtt(6*FW, 2*FH, g_model.phaseData[phase].name, sizeof(g_model.phaseData[phase].name), ZCHAR); lcd_putsnAtt(6*FW, 2*FH, g_model.phaseData[phase].name, sizeof(g_model.phaseData[phase].name), ZCHAR);
uint8_t att = (g_vbat100mV < g_eeGeneral.vBatWarn ? BLINK|INVERS : 0) | DBLSIZE; uint8_t att = (g_vbat100mV <= g_eeGeneral.vBatWarn ? BLINK|INVERS : 0) | DBLSIZE;
putsModelName(2*FW-2, 0*FH, g_model.name, g_eeGeneral.currModel, DBLSIZE); putsModelName(2*FW-2, 0*FH, g_model.name, g_eeGeneral.currModel, DBLSIZE);
putsVBat(6*FW-1, 2*FH, att|NO_UNIT); putsVBat(6*FW-1, 2*FH, att|NO_UNIT);
lcd_putc(6*FW, 3*FH, 'V'); lcd_putc(6*FW, 3*FH, 'V');
+11 -1
View File
@@ -2107,9 +2107,19 @@ void menuProcLimits(uint8_t _event)
} }
} }
else if (attr && event==EVT_KEY_LONG(KEY_MENU)) { else if (attr && event==EVT_KEY_LONG(KEY_MENU)) {
int16_t zero = g_chans512[k];
pauseMixerCalculations(); pauseMixerCalculations();
int32_t zero = (int32_t)g_chans512[k];
s_perout_mode = e_perout_mode_nosticks+e_perout_mode_notrainer;
perOut(0);
int32_t chan = chans[k];
int8_t lim = ld->max+100;
if (chan < 0) {
chan = -chan;
lim = ld->min-100;
}
zero = (zero*100000 - 10*chan*lim) / (102400 - chan);
ld->offset = (ld->revert) ? -zero : zero; ld->offset = (ld->revert) ? -zero : zero;
s_perout_mode = e_perout_mode_normal;
resumeMixerCalculations(); resumeMixerCalculations();
s_editMode = 0; s_editMode = 0;
STORE_MODELVARS; STORE_MODELVARS;
+42 -40
View File
@@ -1399,16 +1399,18 @@ void getADC_single()
void getADC_bandgap() void getADC_bandgap()
{ {
#if defined (PCBV4) #if defined (PCBV4)
// For times over-sample with no divide, x2 to end at a half averaged, x8. DON'T ASK mmmkay? :P This is how I want it. static uint8_t s_bgCheck = 0;
ADCSRA|=0x40; while ((ADCSRA & 0x10)==0); ADCSRA|=0x10; static uint16_t s_bgSum = 0;
BandGap=ADCW; ADCSRA|=0x40; // request sample
ADCSRA|=0x40; while ((ADCSRA & 0x10)==0); ADCSRA|=0x10; s_bgCheck += 32;
BandGap+=ADCW; while ((ADCSRA & 0x10)==0); ADCSRA|=0x10; // wait for sample
ADCSRA|=0x40; while ((ADCSRA & 0x10)==0); ADCSRA|=0x10; if (s_bgCheck == 0) { // 8x over-sample (256/32=8)
BandGap+=ADCW; BandGap = s_bgSum+ADCW;
ADCSRA|=0x40; while ((ADCSRA & 0x10)==0); ADCSRA|=0x10; s_bgSum = 0;
BandGap+=ADCW; }
BandGap *= 2; else {
s_bgSum += ADCW;
}
ADCSRB |= (1<<MUX5); ADCSRB |= (1<<MUX5);
#else #else
// TODO is the next line needed (because it has been called before perMain)? // TODO is the next line needed (because it has been called before perMain)?
@@ -1541,13 +1543,6 @@ FORCEINLINE void evalTrims()
} }
} }
enum PerOutMode {
e_perout_mode_normal = 0,
e_perout_mode_trims,
e_perout_mode_zeros,
e_instant_trim
};
uint8_t s_perout_mode = e_perout_mode_normal; uint8_t s_perout_mode = e_perout_mode_normal;
BeepANACenter evalSticks() BeepANACenter evalSticks()
@@ -1919,6 +1914,7 @@ void perOut(uint8_t tick10ms)
anaCenter &= g_model.beepANACenter; anaCenter &= g_model.beepANACenter;
if(((bpanaCenter ^ anaCenter) & anaCenter)) AUDIO_POT_STICK_MIDDLE(); if(((bpanaCenter ^ anaCenter) & anaCenter)) AUDIO_POT_STICK_MIDDLE();
bpanaCenter = anaCenter; bpanaCenter = anaCenter;
}
#ifdef HELI #ifdef HELI
if(g_model.swashR.value) if(g_model.swashR.value)
@@ -1951,28 +1947,28 @@ void perOut(uint8_t tick10ms)
switch (g_model.swashR.type) switch (g_model.swashR.type)
{ {
case (SWASH_TYPE_120): case SWASH_TYPE_120:
vp = REZ_SWASH_Y(vp); vp = REZ_SWASH_Y(vp);
vr = REZ_SWASH_X(vr); vr = REZ_SWASH_X(vr);
cyc_anas[0] = vc - vp; cyc_anas[0] = vc - vp;
cyc_anas[1] = vc + vp/2 + vr; cyc_anas[1] = vc + vp/2 + vr;
cyc_anas[2] = vc + vp/2 - vr; cyc_anas[2] = vc + vp/2 - vr;
break; break;
case (SWASH_TYPE_120X): case SWASH_TYPE_120X:
vp = REZ_SWASH_X(vp); vp = REZ_SWASH_X(vp);
vr = REZ_SWASH_Y(vr); vr = REZ_SWASH_Y(vr);
cyc_anas[0] = vc - vr; cyc_anas[0] = vc - vr;
cyc_anas[1] = vc + vr/2 + vp; cyc_anas[1] = vc + vr/2 + vp;
cyc_anas[2] = vc + vr/2 - vp; cyc_anas[2] = vc + vr/2 - vp;
break; break;
case (SWASH_TYPE_140): case SWASH_TYPE_140:
vp = REZ_SWASH_Y(vp); vp = REZ_SWASH_Y(vp);
vr = REZ_SWASH_Y(vr); vr = REZ_SWASH_Y(vr);
cyc_anas[0] = vc - vp; cyc_anas[0] = vc - vp;
cyc_anas[1] = vc + vp + vr; cyc_anas[1] = vc + vp + vr;
cyc_anas[2] = vc + vp - vr; cyc_anas[2] = vc + vp - vr;
break; break;
case (SWASH_TYPE_90): case SWASH_TYPE_90:
vp = REZ_SWASH_Y(vp); vp = REZ_SWASH_Y(vp);
vr = REZ_SWASH_Y(vr); vr = REZ_SWASH_Y(vr);
cyc_anas[0] = vc - vp; cyc_anas[0] = vc - vp;
@@ -1984,7 +1980,6 @@ void perOut(uint8_t tick10ms)
} }
} }
#endif #endif
}
memclear(chans, sizeof(chans)); // All outputs to 0 memclear(chans, sizeof(chans)); // All outputs to 0
@@ -2016,9 +2011,16 @@ void perOut(uint8_t tick10ms)
uint8_t k = md->srcRaw-1; uint8_t k = md->srcRaw-1;
int16_t v = 0; int16_t v = 0;
if (s_perout_mode != e_perout_mode_normal) { if (s_perout_mode != e_perout_mode_normal) {
if (!sw || k >= NUM_STICKS || (k == THR_STICK && g_model.thrTrim)) if (!sw || k >= NUM_STICKS || (k == THR_STICK && g_model.thrTrim)) {
printf("CONTINUE\n");
continue; continue;
} }
else {
printf("LIGNE AJOUTEE\n");
if (!(s_perout_mode & e_perout_mode_nosticks))
v = anas[k];
}
}
else { else {
if (k < NUM_STICKS) if (k < NUM_STICKS)
v = anas[k]; //Switch is on. MAX=FULL=512 or value. v = anas[k]; //Switch is on. MAX=FULL=512 or value.
@@ -2093,6 +2095,19 @@ void perOut(uint8_t tick10ms)
//========== OFFSET =============== //========== OFFSET ===============
if (apply_offset && md->sOffset) v += calc100toRESX(md->sOffset); if (apply_offset && md->sOffset) v += calc100toRESX(md->sOffset);
//========== TRIMS ===============
if (!(s_perout_mode & e_perout_mode_notrims)) {
int8_t mix_trim = md->carryTrim;
if (mix_trim < TRIM_ON)
mix_trim = -mix_trim-1;
else if (mix_trim == TRIM_ON && k < NUM_STICKS)
mix_trim = k;
else
mix_trim = -1;
if (mix_trim >= 0)
v += trims[mix_trim];
}
//========== SPEED =============== //========== SPEED ===============
if (s_perout_mode == e_perout_mode_normal && (md->speedUp || md->speedDown)) // there are delay values if (s_perout_mode == e_perout_mode_normal && (md->speedUp || md->speedDown)) // there are delay values
{ {
@@ -2125,19 +2140,6 @@ void perOut(uint8_t tick10ms)
if (md->curve) if (md->curve)
v = applyCurve(v, md->curve); v = applyCurve(v, md->curve);
//========== TRIMS ===============
if (s_perout_mode < e_perout_mode_zeros) {
int8_t mix_trim = md->carryTrim;
if (mix_trim < TRIM_ON)
mix_trim = -mix_trim-1;
else if (mix_trim == TRIM_ON && k < NUM_STICKS)
mix_trim = k;
else
mix_trim = -1;
if (mix_trim >= 0)
v += trims[mix_trim];
}
//========== MULTIPLEX =============== //========== MULTIPLEX ===============
int32_t dv = (int32_t)v*md->weight; int32_t dv = (int32_t)v*md->weight;
@@ -2640,7 +2642,7 @@ void perMain()
else if (s_batCheck == 0) { else if (s_batCheck == 0) {
g_vbat100mV = s_batSum / 8; g_vbat100mV = s_batSum / 8;
s_batSum = 0; s_batSum = 0;
if (g_vbat100mV<g_eeGeneral.vBatWarn && g_vbat100mV>50) { if (g_vbat100mV <= g_eeGeneral.vBatWarn && g_vbat100mV>50) {
AUDIO_TX_BATTERY_LOW(); AUDIO_TX_BATTERY_LOW();
} }
} }
@@ -2926,7 +2928,7 @@ void instantTrim()
if (i!=THR_STICK) { if (i!=THR_STICK) {
// don't instant trim the throttle stick // don't instant trim the throttle stick
uint8_t trim_phase = getTrimFlightPhase(s_perout_flight_phase, i); uint8_t trim_phase = getTrimFlightPhase(s_perout_flight_phase, i);
s_perout_mode = e_instant_trim; s_perout_mode = e_perout_mode_notrainer;
evalSticks(); evalSticks();
s_perout_mode = e_perout_mode_normal; s_perout_mode = e_perout_mode_normal;
int16_t trim = (anas[i] + trims[i]) / 2; int16_t trim = (anas[i] + trims[i]) / 2;
@@ -2948,13 +2950,13 @@ void moveTrimsToOffsets() // copy state of 3 primary to subtrim
{ {
int16_t zeros[NUM_CHNOUT]; int16_t zeros[NUM_CHNOUT];
s_perout_mode = e_perout_mode_zeros; s_perout_mode = e_perout_mode_noinput;
perOut(0); // do output loop - zero input sticks and trims perOut(0); // do output loop - zero input sticks and trims
for (uint8_t i=0; i<NUM_CHNOUT; i++) { for (uint8_t i=0; i<NUM_CHNOUT; i++) {
zeros[i] = applyLimits(i, chans[i]); zeros[i] = applyLimits(i, chans[i]);
} }
s_perout_mode = e_perout_mode_trims; s_perout_mode = e_perout_mode_nosticks+e_perout_mode_notrainer;
perOut(0); // do output loop - only trims perOut(0); // do output loop - only trims
s_perout_mode = e_perout_mode_normal; s_perout_mode = e_perout_mode_normal;
+13
View File
@@ -531,6 +531,17 @@ uint16_t evalChkSum();
extern void message(const pm_char *title, const pm_char *s, const char *last MESSAGE_SOUND_ARG); extern void message(const pm_char *title, const pm_char *s, const char *last MESSAGE_SOUND_ARG);
extern void alert(const pm_char * t, const pm_char * s MESSAGE_SOUND_ARG); extern void alert(const pm_char * t, const pm_char * s MESSAGE_SOUND_ARG);
enum PerOutMode {
e_perout_mode_normal = 0,
e_perout_mode_notrainer = 1,
e_perout_mode_notrims = 2,
e_perout_mode_nosticks = 4,
e_perout_mode_noinput = e_perout_mode_notrainer+e_perout_mode_notrims+e_perout_mode_nosticks
};
extern uint8_t s_perout_mode;
void perOut(uint8_t tick10ms);
void perMain(); void perMain();
void per10ms(); void per10ms();
@@ -786,6 +797,7 @@ extern uint8_t g_beepVal[5];
extern uint8_t ppmInState; //0=unsync 1..8= wait for value i-1 extern uint8_t ppmInState; //0=unsync 1..8= wait for value i-1
extern int16_t g_ppmIns[8]; extern int16_t g_ppmIns[8];
extern int32_t chans[NUM_CHNOUT];
extern int16_t ex_chans[NUM_CHNOUT]; // Outputs (before LIMITS) of the last perMain extern int16_t ex_chans[NUM_CHNOUT]; // Outputs (before LIMITS) of the last perMain
extern int16_t g_chans512[NUM_CHNOUT]; extern int16_t g_chans512[NUM_CHNOUT];
extern uint16_t BandGap; extern uint16_t BandGap;
@@ -795,6 +807,7 @@ extern int16_t expo(int16_t x, int16_t k);
extern int16_t intpol(int16_t, uint8_t); extern int16_t intpol(int16_t, uint8_t);
extern int16_t applyCurve(int16_t, int8_t); extern int16_t applyCurve(int16_t, int8_t);
extern void applyExpos(int16_t *anas); extern void applyExpos(int16_t *anas);
extern int16_t applyLimits(uint8_t channel, int32_t value);
extern uint16_t anaIn(uint8_t chan); extern uint16_t anaIn(uint8_t chan);
extern int16_t calibratedStick[NUM_STICKS+NUM_POTS]; extern int16_t calibratedStick[NUM_STICKS+NUM_POTS];
+1 -1
View File
@@ -88,7 +88,7 @@ void animRotarySw(uint8_t x) {
switch (num2Display) { switch (num2Display) {
case 0: case 0:
att1 = (g_vbat100mV < g_eeGeneral.vBatWarn ? BLINK : 0); att1 = (g_vbat100mV <= g_eeGeneral.vBatWarn ? BLINK : 0);
putsVBat(x + 4 * FW, 2 * FH, att1 | NO_UNIT | DBLSIZE); putsVBat(x + 4 * FW, 2 * FH, att1 | NO_UNIT | DBLSIZE);
switch (num4Display) { switch (num4Display) {
+2 -2
View File
@@ -183,8 +183,8 @@
#define LEN_VOLTSRC "\003" #define LEN_VOLTSRC "\003"
#define TR_VOLTSRC "---""A1\0""A2\0""FAS""Cel" #define TR_VOLTSRC "---""A1\0""A2\0""FAS""Cel"
#define LEN_VARIOSRC "\006" #define LEN_VARIOSRC "\007"
#define TR_VARIOSRC "BaroV1""BaroV2""A1\0 ""A2\0" #define TR_VARIOSRC "FrSky\0 ""Halcyon""A1\0 ""A2\0"
#define LEN_GPSFORMAT "\004" #define LEN_GPSFORMAT "\004"
#define TR_GPSFORMAT "HMS NMEA" #define TR_GPSFORMAT "HMS NMEA"
+2 -2
View File
@@ -183,8 +183,8 @@
#define LEN_VOLTSRC "\003" #define LEN_VOLTSRC "\003"
#define TR_VOLTSRC "---""A1\0""A2\0""FAS""Cel" #define TR_VOLTSRC "---""A1\0""A2\0""FAS""Cel"
#define LEN_VARIOSRC "\006" #define LEN_VARIOSRC "\007"
#define TR_VARIOSRC "BaroV1""BaroV2""A1\0 ""A2\0" #define TR_VARIOSRC "FrSky\0 ""Halcyon""A1\0 ""A2\0"
#define LEN_GPSFORMAT "\004" #define LEN_GPSFORMAT "\004"
#define TR_GPSFORMAT "HMS NMEA" #define TR_GPSFORMAT "HMS NMEA"
+2 -2
View File
@@ -184,8 +184,8 @@
#define LEN_VOLTSRC "\003" #define LEN_VOLTSRC "\003"
#define TR_VOLTSRC "---""A1\0""A2\0""FAS""Cel" #define TR_VOLTSRC "---""A1\0""A2\0""FAS""Cel"
#define LEN_VARIOSRC "\006" #define LEN_VARIOSRC "\007"
#define TR_VARIOSRC "BaroV1""BaroV2""A1\0 ""A2\0" #define TR_VARIOSRC "FrSky\0 ""Halcyon""A1\0 ""A2\0"
#define LEN_GPSFORMAT "\004" #define LEN_GPSFORMAT "\004"
#define TR_GPSFORMAT "HMS NMEA" #define TR_GPSFORMAT "HMS NMEA"
+2 -2
View File
@@ -178,8 +178,8 @@
#define LEN_VOLTSRC "\003" #define LEN_VOLTSRC "\003"
#define TR_VOLTSRC "---""A1\0""A2\0""FAS""Cel" #define TR_VOLTSRC "---""A1\0""A2\0""FAS""Cel"
#define LEN_VARIOSRC "\006" #define LEN_VARIOSRC "\007"
#define TR_VARIOSRC "BaroV1""BaroV2""A1\0 ""A2\0" #define TR_VARIOSRC "FrSky\0 ""Halcyon""A1\0 ""A2\0"
#define LEN_GPSFORMAT "\004" #define LEN_GPSFORMAT "\004"
#define TR_GPSFORMAT "HMS NMEA" #define TR_GPSFORMAT "HMS NMEA"
+2 -2
View File
@@ -183,8 +183,8 @@
#define LEN_VOLTSRC "\003" #define LEN_VOLTSRC "\003"
#define TR_VOLTSRC "---""A1\0""A2\0""FAS""Cel" #define TR_VOLTSRC "---""A1\0""A2\0""FAS""Cel"
#define LEN_VARIOSRC "\006" #define LEN_VARIOSRC "\007"
#define TR_VARIOSRC "BaroV1""BaroV2""A1\0 ""A2\0" #define TR_VARIOSRC "FrSky\0 ""Halcyon""A1\0 ""A2\0"
#define LEN_GPSFORMAT "\004" #define LEN_GPSFORMAT "\004"
#define TR_GPSFORMAT "HMS NMEA" #define TR_GPSFORMAT "HMS NMEA"
+2 -2
View File
@@ -178,8 +178,8 @@
#define LEN_VOLTSRC "\003" #define LEN_VOLTSRC "\003"
#define TR_VOLTSRC "---""A1\0""A2\0""FAS""Cel" #define TR_VOLTSRC "---""A1\0""A2\0""FAS""Cel"
#define LEN_VARIOSRC "\006" #define LEN_VARIOSRC "\007"
#define TR_VARIOSRC "BaroV1""BaroV2""A1 ""A2\0" #define TR_VARIOSRC "FrSky\0 ""Halcyon""A1\0 ""A2\0"
#define LEN_GPSFORMAT "\004" #define LEN_GPSFORMAT "\004"
#define TR_GPSFORMAT "HMS NMEA" #define TR_GPSFORMAT "HMS NMEA"