Issue 34 fixed

Issue 101 fixed
This commit is contained in:
bsongis
2012-09-03 18:13:55 +00:00
parent 9dc1a1fa53
commit d9cb411c12
14 changed files with 150 additions and 45 deletions
+1 -1
View File
@@ -1198,7 +1198,7 @@ uint16_t getCurrent()
static uint8_t Current_count ;
Current_sum += anaIn(NUMBER_ANALOG-1);
if ( ++Current_count > 49 ) {
if (++Current_count >= 50) {
Current = Current_sum / 5 ;
Current_sum = 0 ;
Current_count = 0 ;
+8
View File
@@ -38,6 +38,7 @@
const char * audioFilenames[] = {
"inactiv",
"lowbatt",
"highmah",
"hightemp",
"thralert",
"swalert",
@@ -548,6 +549,13 @@ void audioEvent(uint8_t e, uint8_t f)
audioQueue.play(80, 40, 6, 2, -1);
}
break;
case AU_TX_MAH_HIGH:
if (!audioQueue.busy()) {
// TODO Rob something better here?
audioQueue.play(60, 40, 6, 2, 1);
audioQueue.play(80, 40, 6, 2, -1);
}
break;
case AU_TX_TEMP_HIGH:
if (!audioQueue.busy()) {
// TODO Rob something better here?
+1
View File
@@ -115,6 +115,7 @@ void audioEvent(uint8_t e, uint8_t f=BEEP_DEFAULT_FREQ);
#define AUDIO_WARNING1() audioEvent(AU_WARNING1)
#define AUDIO_WARNING2() audioEvent(AU_WARNING2)
#define AUDIO_TX_BATTERY_LOW() audioEvent(AU_TX_BATTERY_LOW)
#define AUDIO_TX_MAH_HIGH() audioEvent(AU_TX_MAH_HIGH)
#define AUDIO_TX_TEMP_HIGH() audioEvent(AU_TX_TEMP_HIGH)
#define AUDIO_ERROR() audioEvent(AU_ERROR)
#if defined(VOICE)
+55 -26
View File
@@ -948,18 +948,35 @@ uint16_t stickMoveValue()
void checkBacklight()
{
if (g_eeGeneral.backlightMode == e_backlight_mode_on || g_LightOffCounter || isFunctionActive(FUNC_BACKLIGHT))
BACKLIGHT_ON;
else
BACKLIGHT_OFF;
#if defined(PCBSTD) && defined(VOICE)
static uint8_t tmr10ms ;
if (tmr10ms != g_blinkTmr10ms) {
tmr10ms = g_blinkTmr10ms ;
uint16_t tsum = stickMoveValue();
if (tsum != inacSum) {
inacSum = tsum;
inacCounter = 0;
if (g_eeGeneral.backlightMode & e_backlight_mode_sticks)
backlightOn();
}
else if (g_eeGeneral.inactivityTimer && (!g_vbat100mV || g_vbat100mV>50)) {
if (++inacPrescale > 15 ) {
inacCounter++;
inacPrescale = 0;
if (inacCounter > ((uint16_t)g_eeGeneral.inactivityTimer*100*60/16))
if ((inacCounter&0x1F)==1) AUDIO_INACTIVITY();
}
}
if (g_eeGeneral.backlightMode == e_backlight_mode_on || g_LightOffCounter || isFunctionActive(FUNC_BACKLIGHT))
BACKLIGHT_ON;
else
BACKLIGHT_OFF;
#if defined(PCBSTD) && defined(VOICE)
Voice.voice_process() ;
}
#endif
}
}
void backlightOn()
@@ -1263,6 +1280,10 @@ void checkTrims()
#if defined(PCBARM) && defined(REVB)
uint16_t Current_analogue;
uint16_t Current_max;
uint32_t Current_accumulator;
uint32_t Current_used;
uint16_t MAh_used;
#define NUMBER_ANALOG 9
#else
#define NUMBER_ANALOG 8
@@ -2258,6 +2279,8 @@ inline void doMixerCalculations(tmr10ms_t tmr10ms, uint8_t tick10ms)
#if defined(PCBARM) && defined(REVB) && !defined(SIMU)
Current_analogue = ( Current_analogue * 31 + s_anaFilt[8] ) >> 5 ;
if (Current_analogue > Current_max)
Current_max = Current_analogue ;
#elif defined(PCBV4) && !defined(SIMU)
// For PCB V4, use our own 1.2V, external reference (connected to ADC3)
ADCSRB &= ~(1<<MUX5);
@@ -2344,7 +2367,7 @@ inline void doMixerCalculations(tmr10ms_t tmr10ms, uint8_t tick10ms)
val = calibratedStick[THR_STICK]; // get throttle channel value
}
else if (g_model.thrTraceSrc > NUM_POTS) {
val = g_chans512[g_model.thrTraceSrc-NUM_POTS-1];
val = ex_chans[g_model.thrTraceSrc-NUM_POTS-1] / 2;
}
else {
val = calibratedStick[g_model.thrTraceSrc+NUM_STICKS-1];
@@ -2548,10 +2571,20 @@ void perMain()
#if defined(PCBARM)
if (Tenms) {
Tenms = 0 ;
if (Eeprom32_process_state != E32_IDLE)
ee32_process();
else if (TIME_TO_WRITE)
eeCheck();
Current_accumulator += Current_analogue ;
static uint32_t OneSecTimer;
if (++OneSecTimer >= 100) {
OneSecTimer -= 100 ;
Current_used += Current_accumulator / 100 ; // milliAmpSeconds (but scaled)
Current_accumulator = 0 ;
}
#if defined(SDCARD) && !defined(SIMU)
sdPoll10mS();
#endif
@@ -2567,22 +2600,6 @@ void perMain()
if (!tick10ms) return; //make sure the rest happen only every 10ms.
uint16_t tsum = stickMoveValue();
if (tsum != inacSum) {
inacSum = tsum;
inacCounter = 0;
if (g_eeGeneral.backlightMode & e_backlight_mode_sticks)
backlightOn();
}
else if (g_eeGeneral.inactivityTimer && g_vbat100mV>50) {
if (++inacPrescale > 15 ) {
inacCounter++;
inacPrescale = 0;
if (inacCounter > ((uint16_t)g_eeGeneral.inactivityTimer*100*60/16))
if ((inacCounter&0x1F)==1) AUDIO_INACTIVITY();
}
}
#if defined(SDCARD)
#if defined(PCBV4)
static uint8_t mountTimer;
@@ -2707,9 +2724,12 @@ void perMain()
AUDIO_TX_BATTERY_LOW();
}
#if defined(PCBARM)
if (temperature >= g_eeGeneral.temperatureWarn+80) {
else if (temperature >= g_eeGeneral.temperatureWarn+80) {
AUDIO_TX_TEMP_HIGH();
}
else if (g_eeGeneral.mAhWarn && (MAh_used + Current_used * (488 + g_eeGeneral.currentCalib)/8192/36) / 500 >= g_eeGeneral.mAhWarn) {
AUDIO_TX_MAH_HIGH();
}
#endif
}
}
@@ -3127,6 +3147,7 @@ inline void open9xInit(OPEN9X_INIT_ARGS)
#if defined(PCBARM)
setVolume(g_eeGeneral.speakerVolume);
PWM->PWM_CH_NUM[0].PWM_CDTYUPD = g_eeGeneral.backlightBright;
MAh_used = g_eeGeneral.mAhUsed;
#endif
#if defined(PCBARM) && defined(BLUETOOTH)
@@ -3648,7 +3669,15 @@ void menusTask(void * pdata)
if (shutdown_state != e_power_usb) {
displayPopup(STR_SHUTDOWN);
g_eeGeneral.unexpectedShutdown=0;
MAh_used += Current_used/22/36;
if (g_eeGeneral.mAhUsed != MAh_used) {
g_eeGeneral.mAhUsed = MAh_used;
STORE_GENERALVARS;
}
g_eeGeneral.unexpectedShutdown = 0;
eeDirty(EE_GENERAL);
eeCheck(true);
}
+11
View File
@@ -54,6 +54,14 @@
#include "board_ersky9x.h"
#endif
#if defined(PCBARM) && defined(REVB)
extern uint16_t Current_analogue;
extern uint16_t Current_max;
extern uint32_t Current_accumulator;
extern uint32_t Current_used;
extern uint16_t MAh_used;
#endif
#if defined(SIMU)
#include "simpgmspace.h"
#elif defined(PCBARM)
@@ -473,7 +481,9 @@ extern uint8_t heartbeat;
#define MAX_ALERT_TIME 60
extern uint8_t inacPrescale;
extern uint16_t inacCounter;
extern uint16_t inacSum;
#if defined(PXX)
extern uint8_t pxxFlag;
@@ -965,6 +975,7 @@ enum AUDIO_SOUNDS {
AU_INACTIVITY,
AU_TX_BATTERY_LOW,
#if defined(PCBARM)
AU_TX_MAH_HIGH,
AU_TX_TEMP_HIGH,
#endif
#if defined(VOICE)
+23 -7
View File
@@ -79,12 +79,24 @@ void menuProcStatistic(uint8_t event)
#endif
}
#if defined(PCBARM)
#define MENU_DEBUG_COL_OFS (13*FW)
#else
#define MENU_DEBUG_COL_OFS (14*FW)
#endif
void menuProcDebug(uint8_t event)
{
TITLE(STR_MENUDEBUG);
switch(event)
{
#if defined(PCBARM)
case EVT_KEY_LONG(KEY_MENU):
MAh_used = 0;
Current_used = 0;
killEvents(event);
AUDIO_KEYPAD_UP();
break;
#endif
case EVT_KEY_FIRST(KEY_MENU):
#if !defined(PCBARM)
g_tmr1Latency_min = 0xff;
@@ -111,23 +123,27 @@ void menuProcDebug(uint8_t event)
lcd_outdez8(MENU_DEBUG_COL_OFS , 3*FH, (g_tmr1Latency_max - g_tmr1Latency_min) /2 );
#endif
lcd_putsLeft(4*FH, STR_TMAINMAXMS);
#if defined(PCBARM)
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 4*FH, (g_timeMainMax)/20, PREC2);
lcd_putsLeft(5*FH, STR_TMAINMAXMS);
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 5*FH, (g_timeMainMax)/20, PREC2);
#else
lcd_putsLeft(4*FH, STR_TMAINMAXMS);
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 4*FH, (g_timeMainMax*100)/16, PREC2);
#endif
#if defined(PCBARM)
#if defined(REVB)
lcd_putsLeft(2*FH, STR_CURRENT);
lcd_putsLeft(2*FH, STR_CPU_CURRENT);
putsTelemetryValue(MENU_DEBUG_COL_OFS, 2*FH, getCurrent(), UNIT_MILLIAMPS, 0);
uint32_t current_scale = 488 + g_eeGeneral.currentCalib;
putsTelemetryValue(20*FW+2, 2*FH, Current_max*10*current_scale/8192, UNIT_RAW, 0);
lcd_putsLeft(3*FH, STR_CPU_MAH);
putsTelemetryValue(MENU_DEBUG_COL_OFS, 3*FH, MAh_used + Current_used*current_scale/8192/36, UNIT_MAH, PREC1);
#endif
lcd_putsLeft(3*FH, STR_CPU_TEMP);
putsTelemetryValue(MENU_DEBUG_COL_OFS, 3*FH, temperature, UNIT_DEGREES, 0);
putsTelemetryValue(20*FW+2, 3*FH, maxTemperature, UNIT_DEGREES, 0);
// TODO mAh, Battery from ersky9x?
lcd_putsLeft(4*FH, STR_CPU_TEMP);
putsTelemetryValue(MENU_DEBUG_COL_OFS, 4*FH, temperature, UNIT_DEGREES, 0);
putsTelemetryValue(20*FW+2, 4*FH, maxTemperature, UNIT_DEGREES, 0);
#endif
#if !defined(PCBARM)
+2
View File
@@ -338,6 +338,8 @@ const pm_char STR_SPEAKER_VOLUME[] PROGMEM = TR_SPEAKER_VOLUME;
const pm_char STR_OPTREX_DISPLAY[] PROGMEM = TR_OPTREX_DISPLAY;
const pm_char STR_BRIGHTNESS[] PROGMEM = TR_BRIGHTNESS;
const pm_char STR_CPU_TEMP[] PROGMEM = TR_CPU_TEMP;
const pm_char STR_CPU_CURRENT[] PROGMEM = TR_CPU_CURRENT;
const pm_char STR_CPU_MAH[] PROGMEM = TR_CPU_MAH;
const pm_char STR_TEMPWARNING[] PROGMEM = TR_TEMPWARNING;
const pm_char STR_CAPAWARNING[] PROGMEM = TR_CAPAWARNING;
const pm_char STR_FUNC[] PROGMEM = TR_FUNC;
+2
View File
@@ -420,6 +420,8 @@ extern const pm_char STR_SPEAKER_VOLUME[];
extern const pm_char STR_OPTREX_DISPLAY[];
extern const pm_char STR_BRIGHTNESS[];
extern const pm_char STR_CPU_TEMP[];
extern const pm_char STR_CPU_CURRENT[];
extern const pm_char STR_CPU_MAH[];
extern const pm_char STR_CAPAWARNING[];
extern const pm_char STR_TEMPWARNING[];
extern const pm_char STR_FUNC[];
+8 -2
View File
@@ -348,7 +348,11 @@
#define STR_US (STR_TMR1LATMAXUS+12)
#define TR_TMR1LATMINUS "Tmr1Lat min\003us"
#define TR_TMR1JITTERUS "Tmr1 Jitter\003us"
#define TR_TMAINMAXMS "Tmain max\005ms"
#if defined(PCBARM)
#define TR_TMAINMAXMS "Tmain max\004ms"
#else
#define TR_TMAINMAXMS "Tmain max\005ms"
#endif
#define TR_T10MSUS "T10ms\007us"
#define TR_FREESTACKMINB "Free Stack\004b"
#define TR_MENUTORESET "[MENU] >> Reset"
@@ -422,7 +426,9 @@
#define TR_SPEAKER_VOLUME "Hlasitost"
#define TR_OPTREX_DISPLAY "Optrex Display"
#define TR_BRIGHTNESS "Jas"
#define TR_CPU_TEMP "tepl. CPU\010>"
#define TR_CPU_TEMP "tepl. CPU\007>"
#define TR_CPU_CURRENT "Current\011>"
#define TR_CPU_MAH "Consumpt."
#define TR_CAPAWARNING "Capacity Warning"
#define TR_TEMPWARNING "Temp Warning"
#define TR_FUNC "Fun."
+8 -2
View File
@@ -348,7 +348,11 @@
#define STR_US (STR_TMR1LATMAXUS+12)
#define TR_TMR1LATMINUS "Tmr1Lat min\003us"
#define TR_TMR1JITTERUS "Tmr1 Jitter\003us"
#define TR_TMAINMAXMS "Tmain max\005ms"
#if defined(PCBARM)
#define TR_TMAINMAXMS "Tmain max\004ms"
#else
#define TR_TMAINMAXMS "Tmain max\005ms"
#endif
#define TR_T10MSUS "T10ms\007us"
#define TR_FREESTACKMINB "Free Stack\004b"
#define TR_MENUTORESET "[MENU] f\205r Reset"
@@ -422,7 +426,9 @@
#define TR_SPEAKER_VOLUME "Speaker Volume"
#define TR_OPTREX_DISPLAY "Optrex Display"
#define TR_BRIGHTNESS "Brightness"
#define TR_CPU_TEMP "CPU temp.\010>"
#define TR_CPU_TEMP "CPU temp.\007>"
#define TR_CPU_CURRENT "Current\011>"
#define TR_CPU_MAH "Consumpt."
#define TR_CAPAWARNING "Capacity Warning"
#define TR_TEMPWARNING "Temp Warning"
#define TR_FUNC "Func"
+7 -1
View File
@@ -349,7 +349,11 @@
#define STR_US (STR_TMR1LATMAXUS+12)
#define TR_TMR1LATMINUS "Tmr1Lat min\003us"
#define TR_TMR1JITTERUS "Tmr1 Jitter\003us"
#if defined(PCBARM)
#define TR_TMAINMAXMS "Tmain max\004ms"
#else
#define TR_TMAINMAXMS "Tmain max\005ms"
#endif
#define TR_T10MSUS "T10ms\007us"
#define TR_FREESTACKMINB "Free Stack\004b"
#define TR_MENUTORESET "[MENU] to reset"
@@ -423,7 +427,9 @@
#define TR_SPEAKER_VOLUME "Speaker Volume"
#define TR_OPTREX_DISPLAY "Optrex Display"
#define TR_BRIGHTNESS "Brightness"
#define TR_CPU_TEMP "CPU temp.\010>"
#define TR_CPU_TEMP "CPU Temp.\007>"
#define TR_CPU_CURRENT "Current\011>"
#define TR_CPU_MAH "Consumpt."
#define TR_CAPAWARNING "Capacity Warning"
#define TR_TEMPWARNING "Temp Warning"
#define TR_FUNC "Func"
+8 -2
View File
@@ -346,7 +346,11 @@
#define STR_US (STR_TMR1LATMAXUS+12)
#define TR_TMR1LATMINUS "Tmr1Lat min\003us"
#define TR_TMR1JITTERUS "Tmr1 Jitter\003us"
#define TR_TMAINMAXMS "Tmain max\005ms"
#if defined(PCBARM)
#define TR_TMAINMAXMS "Tmain max\004ms"
#else
#define TR_TMAINMAXMS "Tmain max\005ms"
#endif
#define TR_T10MSUS "T10ms\007us"
#define TR_FREESTACKMINB "Free Stack\004b"
#define TR_MENUTORESET "[MENU]pour reset"
@@ -421,7 +425,9 @@
#define TR_SPEAKER_VOLUME "Volume haut-p."
#define TR_OPTREX_DISPLAY "Afficheur Optrex"
#define TR_BRIGHTNESS "Luminosit\200"
#define TR_CPU_TEMP "Temp. CPU\010>"
#define TR_CPU_TEMP "Temp. CPU\007>"
#define TR_CPU_CURRENT "Courant\011>"
#define TR_CPU_MAH "Consomm."
#define TR_CAPAWARNING "Capacity Warning"
#define TR_TEMPWARNING "Alarme temp"
#define TR_FUNC "Fonc"
+8 -2
View File
@@ -348,7 +348,11 @@
#define STR_US (STR_TMR1LATMAXUS+12)
#define TR_TMR1LATMINUS "Tmr1Lat min\003us"
#define TR_TMR1JITTERUS "Tmr1 Jitter\003us"
#define TR_TMAINMAXMS "Tmain max\005ms"
#if defined(PCBARM)
#define TR_TMAINMAXMS "Tmain max\004ms"
#else
#define TR_TMAINMAXMS "Tmain max\005ms"
#endif
#define TR_T10MSUS "T10ms\007us"
#define TR_FREESTACKMINB "Free Stack\004b"
#define TR_MENUTORESET "[Men\200] x Azzerare"
@@ -422,7 +426,9 @@
#define TR_SPEAKER_VOLUME "Volume Audio"
#define TR_OPTREX_DISPLAY "Display Optrex"
#define TR_BRIGHTNESS "Luminosita'"
#define TR_CPU_TEMP "Temp CPU \010>"
#define TR_CPU_TEMP "Temp CPU \007>"
#define TR_CPU_CURRENT "Current\011>"
#define TR_CPU_MAH "Consumpt."
#define TR_CAPAWARNING "Capacity Warning"
#define TR_TEMPWARNING "Temp Warning"
#define TR_FUNC "Funz"
+8 -2
View File
@@ -345,7 +345,11 @@
#define STR_US (STR_TMR1LATMAXUS+12)
#define TR_TMR1LATMINUS "Tmr1Lat min\003us"
#define TR_TMR1JITTERUS "Tmr1 Jitter\003us"
#define TR_TMAINMAXMS "Tmain max\005ms"
#if defined(PCBARM)
#define TR_TMAINMAXMS "Tmain max\004ms"
#else
#define TR_TMAINMAXMS "Tmain max\005ms"
#endif
#define TR_T10MSUS "T10ms\007us"
#define TR_FREESTACKMINB "Free Stack\004b"
#define TR_MENUTORESET "[MENU] NOLLAR "
@@ -420,7 +424,9 @@
#define TR_SPEAKER_VOLUME "Speaker Volume"
#define TR_OPTREX_DISPLAY "Optrex Display"
#define TR_BRIGHTNESS "Brightness"
#define TR_CPU_TEMP "CPU temp.\010>"
#define TR_CPU_TEMP "CPU temp.\007>"
#define TR_CPU_CURRENT "Current\011>"
#define TR_CPU_MAH "Consumpt."
#define TR_CAPAWARNING "Capacity Warning"
#define TR_TEMPWARNING "Temp Warning"
#define TR_FUNC "Func"