No more alert for EEPROM overflow

Trims buttons don't modify trim position on release
[ersky9x] Audio stopped sometimes without reason
This commit is contained in:
bsongis
2012-07-10 13:37:55 +00:00
parent dba6841815
commit fa4e1e4fc0
10 changed files with 254 additions and 164 deletions
+2 -1
View File
@@ -476,9 +476,10 @@ void RlcFile::nextWriteStep()
} }
if (s_write_err == ERR_FULL) { if (s_write_err == ERR_FULL) {
alert(STR_EEPROMWARN, STR_EEPROMOVERFLOW); s_global_warning = STR_EEPROMOVERFLOW;
m_write_step = 0; m_write_step = 0;
m_write_len = 0; m_write_len = 0;
m_cur_rlc_len = 0;
} }
if (!s_sync_write) if (!s_sync_write)
+151 -122
View File
@@ -157,7 +157,7 @@ extern uint16_t Sine_values[];
#define CODEC_ID_PCM_S16LE 1 #define CODEC_ID_PCM_S16LE 1
#define CODEC_ID_PCM_ALAW 6 #define CODEC_ID_PCM_ALAW 6
uint8_t pcmCodec; uint8_t pcmCodec;
uint16_t pcmFreq = 8000; uint32_t pcmFreq = 8000;
void audioTask(void* pdata) void audioTask(void* pdata)
{ {
@@ -183,119 +183,128 @@ void AudioQueue::wakeup()
#endif #endif
if (prioIdx >= 0) { if (prioIdx >= 0) {
ridx = prioIdx;
prioIdx = -1;
toneStop();
nextAudioData = NULL;
memset(&current, 0, sizeof(current)); memset(&current, 0, sizeof(current));
if (state == AUDIO_PLAYING_WAV) { background.duration = 0;
state = AUDIO_RESUMING;
CoSetTmrCnt(audioTimer, 5/*10ms*/ + (WAV_BUFFER_SIZE * 1000) / pcmFreq, 0);
CoStartTmr(audioTimer);
}
else if (state == AUDIO_PLAYING_TONE) {
state = AUDIO_RESUMING;
CoSetTmrCnt(audioTimer, 5/*10ms*/, 0);
CoStartTmr(audioTimer);
}
else {
CoSetFlag(audioFlag);
}
} }
#if defined(SDCARD) && !defined(SIMU) #if defined(SDCARD) && !defined(SIMU)
else if (current.file[0]) { if (current.file[0]) {
FRESULT result = FR_OK; if (!nextAudioData || DACC->DACC_ISR & DACC_ISR_TXBUFE) {
UINT read = 0; FRESULT result = FR_OK;
if (current.file[1]) { UINT read = 0;
pcmFreq = 8000; if (current.file[1]) {
wavSamplesBuffer = wavSamplesArray; result = f_open(&wavFile, current.file, FA_OPEN_EXISTING | FA_READ);
result = f_open(&wavFile, current.file, FA_OPEN_EXISTING | FA_READ); current.file[1] = 0;
if (result == FR_OK) { if (result == FR_OK) {
result = f_read(&wavFile, (uint8_t *)wavSamplesArray, WAV_HEADER_SIZE, &read); result = f_read(&wavFile, (uint8_t *) wavSamplesBuffer,
if (result == FR_OK && read == WAV_HEADER_SIZE && !memcmp(wavSamplesArray, "RIFF", 4)) { WAV_HEADER_SIZE, &read);
pcmCodec = wavSamplesArray[10]; if (result == FR_OK && read == WAV_HEADER_SIZE
pcmFreq = wavSamplesArray[12]; && !memcmp(wavSamplesBuffer, "RIFF", 4)) {
if (pcmCodec != CODEC_ID_PCM_S16LE) { pcmCodec = wavSamplesBuffer[10];
result = f_read(&wavFile, (uint8_t *)wavSamplesArray, 12, &read); pcmFreq = wavSamplesBuffer[12];
if (pcmCodec != CODEC_ID_PCM_S16LE) {
result = f_read(&wavFile, (uint8_t *) wavSamplesBuffer, 12,
&read);
}
setFrequency(pcmFreq);
}
else {
result = FR_DENIED;
} }
} }
}
read = 0;
uint16_t bufsize = (pcmCodec == CODEC_ID_PCM_S16LE ? WAV_BUFFER_SIZE * sizeof(uint16_t) : WAV_BUFFER_SIZE);
if (result == FR_OK) {
result = f_read(&wavFile, (uint8_t *) wavSamplesBuffer, bufsize, &read);
}
if (result != FR_OK) {
toneStop();
current.file[0] = 0;
f_close(&wavFile);
CoSetTmrCnt(audioTimer, (WAV_BUFFER_SIZE * 1000) / pcmFreq, 0);
CoClearFlag(audioFlag);
CoStartTmr(audioTimer);
state = AUDIO_RESUMING;
}
else {
if (read != bufsize) {
current.file[0] = 0;
f_close(&wavFile);
}
if (pcmCodec == CODEC_ID_PCM_S16LE) {
read /= 2;
uint32_t i = 0;
for (; i < read; i++)
wavSamplesBuffer[i] = ((uint16_t) 0x8000 + ((int16_t) (wavSamplesBuffer[i]))) >> 4;
for (; i < WAV_BUFFER_SIZE; i++)
wavSamplesBuffer[i] = 0x8000;
}
else if (pcmCodec == CODEC_ID_PCM_ALAW) {
int32_t i;
for (i = read - 1; i >= 0; i--)
wavSamplesBuffer[i] = alawTable[((uint8_t *) wavSamplesBuffer)[i]];
for (i = read; i < WAV_BUFFER_SIZE; i++)
wavSamplesBuffer[i] = 0x8000;
}
read /= 2;
register Dacc *dacptr = DACC;
if (read) {
state = AUDIO_PLAYING_WAV;
if (dacptr->DACC_ISR & DACC_ISR_TXBUFE) {
dacptr->DACC_TPR = CONVERT_PTR(wavSamplesBuffer);
dacptr->DACC_TCR = read;
nextAudioData = NULL; // TODO possible?
CoSetFlag(audioFlag);
}
else if (dacptr->DACC_TNCR == 0) {
dacptr->DACC_TNPR = CONVERT_PTR(wavSamplesBuffer);
dacptr->DACC_TNCR = read;
nextAudioData = NULL; // TODO possible?
CoSetFlag(audioFlag);
}
else {
nextAudioSize = read;
nextAudioData = wavSamplesBuffer;
toneStart();
CoSetTmrCnt(audioTimer, (WAV_BUFFER_SIZE * 500) / pcmFreq, 0);
CoStartTmr(audioTimer);
}
wavSamplesBuffer += WAV_BUFFER_SIZE;
if (wavSamplesBuffer >= wavSamplesArray + 3 * WAV_BUFFER_SIZE)
wavSamplesBuffer = wavSamplesArray;
}
else { else {
result = FR_DENIED; CoSetFlag(audioFlag);
state = AUDIO_SLEEPING;
toneStop();
} }
} }
} }
else { else {
wavSamplesBuffer += WAV_BUFFER_SIZE; CoSetTmrCnt(audioTimer, 5/*10ms*/, 0);
if (wavSamplesBuffer >= wavSamplesArray + 3*WAV_BUFFER_SIZE)
wavSamplesBuffer = wavSamplesArray;
}
read = 0;
uint16_t bufsize = (pcmCodec == CODEC_ID_PCM_S16LE ? WAV_BUFFER_SIZE*sizeof(uint16_t) : WAV_BUFFER_SIZE);
if (result != FR_OK || f_read(&wavFile, (uint8_t *)wavSamplesBuffer, bufsize, &read) != FR_OK || read == 0) {
toneStop();
current.file[0] = 0;
current.file[1] = 0;
f_close(&wavFile);
CoSetTmrCnt(audioTimer, (WAV_BUFFER_SIZE * 1000) / pcmFreq, 0);
CoStartTmr(audioTimer); CoStartTmr(audioTimer);
} }
if (pcmCodec == CODEC_ID_PCM_S16LE) {
read /= 2;
uint32_t i = 0;
for (; i<read; i++)
wavSamplesBuffer[i] = ((uint16_t)0x8000 + ((int16_t)(wavSamplesBuffer[i]))) >> 4;
for (; i<WAV_BUFFER_SIZE; i++)
wavSamplesBuffer[i] = 0x8000;
}
else if (pcmCodec == CODEC_ID_PCM_ALAW) {
int32_t i;
for (i=read-1; i>=0; i--)
wavSamplesBuffer[i] = alawTable[((uint8_t *)wavSamplesBuffer)[i]];
for (i=read; i<WAV_BUFFER_SIZE; i++)
wavSamplesBuffer[i] = 0x8000;
}
read /= 2;
register Dacc *dacptr = DACC;
if (current.file[1]) {
state = AUDIO_PLAYING_WAV;
setFrequency(pcmFreq);
dacptr->DACC_TPR = CONVERT_PTR(wavSamplesBuffer);
dacptr->DACC_TCR = read;
current.file[1] = 0;
CoSetFlag(audioFlag);
}
else if (read) {
if (dacptr->DACC_TNCR == 0) {
dacptr->DACC_TNPR = CONVERT_PTR(wavSamplesBuffer);
dacptr->DACC_TNCR = read;
CoSetFlag(audioFlag);
}
else {
nextAudioSize = read;
nextAudioData = wavSamplesBuffer;
toneStart();
}
}
} }
else
#endif #endif
else if (current.duration > 0) { if (current.duration > 0) {
if (state != AUDIO_PLAYING_TONE) { state = AUDIO_PLAYING_TONE;
state = AUDIO_PLAYING_TONE;
register Dacc *dacptr = DACC; register Dacc *dacptr = DACC;
dacptr->DACC_TPR = CONVERT_PTR(Sine_values); dacptr->DACC_TPR = CONVERT_PTR(Sine_values);
dacptr->DACC_TNPR = CONVERT_PTR(Sine_values); dacptr->DACC_TNPR = CONVERT_PTR(Sine_values);
dacptr->DACC_TCR = 50 ; // words, 100 16 bit values dacptr->DACC_TCR = 50 ; // words, 100 16 bit values
dacptr->DACC_TNCR = 50 ; // words, 100 16 bit values dacptr->DACC_TNCR = 50 ; // words, 100 16 bit values
}
setFrequency(current.freq * 6100 / 2); setFrequency(current.freq * 6100 / 2);
if (current.freqIncr) { if (current.freqIncr) {
CoSetTmrCnt(audioTimer, 5/*10ms*/, 0); CoSetTmrCnt(audioTimer, 2, 0);
current.freq += current.freqIncr; current.freq += current.freqIncr;
current.duration--; current.duration--;
} }
@@ -304,6 +313,7 @@ void AudioQueue::wakeup()
current.duration = 0; current.duration = 0;
} }
toneStart(); toneStart();
CoClearFlag(audioFlag);
CoStartTmr(audioTimer); CoStartTmr(audioTimer);
} }
else if (current.pause > 0) { else if (current.pause > 0) {
@@ -311,16 +321,10 @@ void AudioQueue::wakeup()
CoSetTmrCnt(audioTimer, current.pause*2, 0); CoSetTmrCnt(audioTimer, current.pause*2, 0);
current.pause = 0; current.pause = 0;
toneStop(); toneStop();
CoClearFlag(audioFlag);
CoStartTmr(audioTimer); CoStartTmr(audioTimer);
} }
else if (ridx != widx) { else if (ridx == widx && prioIdx < 0 && background.duration > 0) {
memcpy(&current, &fragments[ridx], sizeof(current));
if (!fragments[ridx].repeat--) {
ridx = (ridx + 1) % AUDIO_QUEUE_LENGTH;
}
CoSetFlag(audioFlag);
}
else if (background.duration > 0) {
if (state != AUDIO_PLAYING_TONE) { if (state != AUDIO_PLAYING_TONE) {
state = AUDIO_PLAYING_TONE; state = AUDIO_PLAYING_TONE;
register Dacc *dacptr = DACC; register Dacc *dacptr = DACC;
@@ -333,17 +337,49 @@ void AudioQueue::wakeup()
background.duration = 0; background.duration = 0;
setFrequency(background.freq * 6100 / 2); setFrequency(background.freq * 6100 / 2);
toneStart(); toneStart();
CoClearFlag(audioFlag);
CoStartTmr(audioTimer); CoStartTmr(audioTimer);
} }
else { else {
#ifndef SIMU
CoEnterMutexSection(audioMutex); CoEnterMutexSection(audioMutex);
#endif
state = AUDIO_SLEEPING; if (ridx != widx) {
#ifndef SIMU if (prioIdx >= 0) {
ridx = prioIdx;
prioIdx = -1;
toneStop();
CoClearFlag(audioFlag);
nextAudioData = NULL;
memset(&current, 0, sizeof(current));
if (state == AUDIO_PLAYING_WAV) {
state = AUDIO_RESUMING;
CoSetTmrCnt(audioTimer, 1/*2ms*/ + (WAV_BUFFER_SIZE * 1000) / pcmFreq, 0);
CoStartTmr(audioTimer);
}
else if (state == AUDIO_PLAYING_TONE) {
state = AUDIO_RESUMING;
CoSetTmrCnt(audioTimer, 1/*2ms*/, 0);
CoStartTmr(audioTimer);
}
else {
CoSetFlag(audioFlag);
}
}
else {
CoSetFlag(audioFlag);
}
memcpy(&current, &fragments[ridx], sizeof(current));
if (!fragments[ridx].repeat--) {
ridx = (ridx + 1) % AUDIO_QUEUE_LENGTH;
}
}
else {
state = AUDIO_SLEEPING;
toneStop();
}
CoLeaveMutexSection(audioMutex); CoLeaveMutexSection(audioMutex);
#endif
toneStop();
} }
} }
@@ -370,9 +406,7 @@ extern OS_MutexID audioMutex;
void AudioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tFlags, int8_t tFreqIncr) void AudioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tFlags, int8_t tFreqIncr)
{ {
#ifndef SIMU
CoEnterMutexSection(audioMutex); CoEnterMutexSection(audioMutex);
#endif
if (tFlags & PLAY_SOUND_VARIO) { if (tFlags & PLAY_SOUND_VARIO) {
background.freq = tFreq; background.freq = tFreq;
@@ -408,19 +442,17 @@ void AudioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tFlag
} }
} }
#ifndef SIMU
CoLeaveMutexSection(audioMutex); CoLeaveMutexSection(audioMutex);
#endif
} }
void AudioQueue::playFile(const char *filename, uint8_t flags) void AudioQueue::playFile(const char *filename, uint8_t flags)
{ {
#ifdef SIMU #ifdef SIMU
printf("playFile(\"%s\"\n", filename); fflush(stdout); printf("playFile(\"%s\")\n", filename); fflush(stdout);
#else
CoEnterMutexSection(audioMutex);
#endif #endif
CoEnterMutexSection(audioMutex);
uint8_t next_widx = (widx + 1) % AUDIO_QUEUE_LENGTH; uint8_t next_widx = (widx + 1) % AUDIO_QUEUE_LENGTH;
if (next_widx != ridx) { if (next_widx != ridx) {
AudioFragment & fragment = fragments[widx]; AudioFragment & fragment = fragments[widx];
@@ -436,9 +468,7 @@ void AudioQueue::playFile(const char *filename, uint8_t flags)
} }
} }
#ifndef SIMU
CoLeaveMutexSection(audioMutex); CoLeaveMutexSection(audioMutex);
#endif
} }
void audioEvent(uint8_t e, uint8_t f) void audioEvent(uint8_t e, uint8_t f)
@@ -640,5 +670,4 @@ void pushPrompt(uint16_t prompt)
audioQueue.playFile(filename); audioQueue.playFile(filename);
#endif #endif
} }
+13 -15
View File
@@ -37,22 +37,22 @@
volatile uint8_t Buzzer_count ; volatile uint8_t Buzzer_count ;
// Must NOT be in flash, PDC needs a RAM source. // Must NOT be in flash, PDC needs a RAM source.
// Amplitude reduced to 30% to allow for voice volume
uint16_t Sine_values[] = uint16_t Sine_values[] =
{ {
2048,2173,2298,2422,2545,2666,2784,2899,3011,3119, 2048,2085,2123,2160,2197,2233,2268,2303,2336,2369,
3223,3322,3417,3505,3589,3666,3736,3800,3857,3907, 2400,2430,2458,2485,2510,2533,2554,2573,2590,2605,
3950,3985,4012,4032,4044,4048,4044,4032,4012,3985, 2618,2629,2637,2643,2646,2648,2646,2643,2637,2629,
3950,3907,3857,3800,3736,3666,3589,3505,3417,3322, 2618,2605,2590,2573,2554,2533,2510,2485,2458,2430,
3223,3119,3011,2899,2784,2666,2545,2422,2298,2173, 2400,2369,2336,2303,2268,2233,2197,2160,2123,2085,
2048,1922,1797,1673,1550,1429,1311,1196,1084, 976, 2048,2010,1972,1935,1898,1862,1826,1792,1758,1726,
872, 773, 678, 590, 506, 429, 359, 295, 238, 188, 1695,1665,1637,1610,1585,1562,1541,1522,1505,1490,
145, 110, 83, 63, 51, 48, 51, 63, 83, 110, 1477,1466,1458,1452,1448,1448,1448,1452,1458,1466,
145, 188, 238, 295, 359, 429, 506, 590, 678, 773, 1477,1490,1505,1522,1541,1562,1585,1610,1637,1665,
872, 976,1084,1196,1311,1429,1550,1673,1797,1922 1695,1726,1758,1792,1826,1862,1898,1935,1972,2010
} ; };
// Sound routines // Sound routines
void startSound() void startSound()
{ {
register Pio *pioptr ; register Pio *pioptr ;
@@ -179,9 +179,6 @@ extern "C" void DAC_IRQHandler()
DACC->DACC_TNPR = CONVERT_PTR(nextAudioData); DACC->DACC_TNPR = CONVERT_PTR(nextAudioData);
DACC->DACC_TNCR = nextAudioSize; DACC->DACC_TNCR = nextAudioSize;
nextAudioData = NULL; nextAudioData = NULL;
CoEnterISR(); // Enter the interrupt
CoSetFlag(audioFlag);
CoExitISR(); // Exit the interrupt
} }
else { else {
toneStop(); toneStop();
@@ -196,6 +193,7 @@ extern "C" void DAC_IRQHandler()
void end_sound() void end_sound()
{ {
DACC->DACC_IDR = DACC_IDR_ENDTX ; DACC->DACC_IDR = DACC_IDR_ENDTX ;
DACC->DACC_IDR = DACC_IDR_TXBUFE ;
NVIC_DisableIRQ(DACC_IRQn) ; NVIC_DisableIRQ(DACC_IRQn) ;
TWI0->TWI_IDR = TWI_IDR_TXCOMP ; TWI0->TWI_IDR = TWI_IDR_TXCOMP ;
NVIC_DisableIRQ(TWI0_IRQn) ; NVIC_DisableIRQ(TWI0_IRQn) ;
+23 -6
View File
@@ -77,6 +77,11 @@ void menuMainView(uint8_t event)
uint8_t view = g_eeGeneral.view; uint8_t view = g_eeGeneral.view;
uint8_t view_base = view & 0x0f; uint8_t view_base = view & 0x0f;
uint8_t _event = event;
if (s_global_warning) {
event = 0;
}
switch(event) switch(event)
{ {
/* TODO if timer2 is OFF, it's possible to use this timer2 as in er9x... /* TODO if timer2 is OFF, it's possible to use this timer2 as in er9x...
@@ -147,9 +152,12 @@ void menuMainView(uint8_t event)
if(s_timerState[0]==TMR_BEEPING) { if(s_timerState[0]==TMR_BEEPING) {
s_timerState[0] = TMR_STOPPED; s_timerState[0] = TMR_STOPPED;
} }
else if (s_global_warning) {
s_global_warning = NULL;
}
#if defined(ROTARY_ENCODERS) #if defined(ROTARY_ENCODERS)
else if (s_warning) { else if (s_inflight_enable) {
s_warning = NULL; s_inflight_enable = false;
} }
#endif #endif
else if (view == e_timer2) { else if (view == e_timer2) {
@@ -174,8 +182,8 @@ void menuMainView(uint8_t event)
case EVT_KEY_LONG(BTN_REb): case EVT_KEY_LONG(BTN_REb):
if (navigationRotaryEncoder(event)) { if (navigationRotaryEncoder(event)) {
killEvents(event); killEvents(event);
if (s_inflight_value && !s_warning) { if (s_inflight_value && !s_inflight_enable) {
s_warning = s_inflight_label; s_inflight_enable = true;
s_editMode = 1; s_editMode = 1;
break; break;
} }
@@ -183,7 +191,7 @@ void menuMainView(uint8_t event)
// no break // no break
case EVT_KEY_BREAK(BTN_REa): case EVT_KEY_BREAK(BTN_REa):
case EVT_KEY_BREAK(BTN_REb): case EVT_KEY_BREAK(BTN_REb):
s_warning = NULL; s_inflight_enable = false;
break; break;
#endif #endif
} }
@@ -345,15 +353,24 @@ void menuMainView(uint8_t event)
// lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s // lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s
} }
if (s_global_warning) {
s_warning = s_global_warning;
displayWarning(_event);
if (!s_warning) s_global_warning = NULL;
s_warning = NULL;
}
#if defined(ROTARY_ENCODERS) #if defined(ROTARY_ENCODERS)
check_rotary_encoder(); check_rotary_encoder();
if (s_warning) { if (s_inflight_enable && !s_warning) {
int8_t value = (((uint8_t)(*s_inflight_value)) >> s_inflight_bitshift) - s_inflight_shift; int8_t value = (((uint8_t)(*s_inflight_value)) >> s_inflight_bitshift) - s_inflight_shift;
if (p1valdiff) { if (p1valdiff) {
value = checkIncDecModel(event, value, s_inflight_min, s_inflight_max); value = checkIncDecModel(event, value, s_inflight_min, s_inflight_max);
*s_inflight_value = (((uint8_t)(*s_inflight_value)) & ((1 << s_inflight_bitshift) - 1)) + ((s_inflight_shift + value) << s_inflight_bitshift); *s_inflight_value = (((uint8_t)(*s_inflight_value)) & ((1 << s_inflight_bitshift) - 1)) + ((s_inflight_shift + value) << s_inflight_bitshift);
} }
s_warning = s_inflight_label;
displayBox(); displayBox();
s_warning = 0;
lcd_outdezAtt(16, 4*FH, value, LEFT); lcd_outdezAtt(16, 4*FH, value, LEFT);
} }
#endif #endif
+4 -2
View File
@@ -492,7 +492,7 @@ void popMenu()
void chainMenu(MenuFuncP newMenu) void chainMenu(MenuFuncP newMenu)
{ {
#if defined(ROTARY_ENCODERS) #if defined(ROTARY_ENCODERS)
s_warning = NULL; s_inflight_enable = false;
#endif #endif
g_menuStack[g_menuStackPtr] = newMenu; g_menuStack[g_menuStackPtr] = newMenu;
(*newMenu)(EVT_ENTRY); (*newMenu)(EVT_ENTRY);
@@ -502,7 +502,7 @@ void chainMenu(MenuFuncP newMenu)
void pushMenu(MenuFuncP newMenu) void pushMenu(MenuFuncP newMenu)
{ {
#if defined(ROTARY_ENCODERS) #if defined(ROTARY_ENCODERS)
s_warning = NULL; s_inflight_enable = false;
#endif #endif
g_menuPos[g_menuStackPtr] = m_posVert; g_menuPos[g_menuStackPtr] = m_posVert;
@@ -519,6 +519,7 @@ void pushMenu(MenuFuncP newMenu)
(*newMenu)(EVT_ENTRY); (*newMenu)(EVT_ENTRY);
} }
const pm_char * s_global_warning = 0;
const pm_char * s_warning = 0; const pm_char * s_warning = 0;
const pm_char * s_warning_info; const pm_char * s_warning_info;
uint8_t s_warning_info_len; uint8_t s_warning_info_len;
@@ -657,6 +658,7 @@ void drawStatusLine()
#endif #endif
#if defined(ROTARY_ENCODERS) #if defined(ROTARY_ENCODERS)
bool s_inflight_enable = false;
int8_t *s_inflight_value = NULL; int8_t *s_inflight_value = NULL;
int8_t s_inflight_min; int8_t s_inflight_min;
int8_t s_inflight_max; int8_t s_inflight_max;
+2
View File
@@ -120,6 +120,7 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
var = checkIncDecGen(event,var,min,max) var = checkIncDecGen(event,var,min,max)
#if defined(ROTARY_ENCODERS) #if defined(ROTARY_ENCODERS)
extern bool s_inflight_enable;
extern int8_t *s_inflight_value; extern int8_t *s_inflight_value;
extern const pm_char *s_inflight_label; extern const pm_char *s_inflight_label;
extern int8_t s_inflight_min; extern int8_t s_inflight_min;
@@ -184,6 +185,7 @@ if (!check_submenu_simple(event,(lines_count)-1)) return;
SIMPLE_SUBMENU_NOTITLE(lines_count); \ SIMPLE_SUBMENU_NOTITLE(lines_count); \
TITLE(title) TITLE(title)
extern const pm_char * s_global_warning;
extern const pm_char * s_warning; extern const pm_char * s_warning;
extern const pm_char * s_warning_info; extern const pm_char * s_warning_info;
extern uint8_t s_warning_info_len; extern uint8_t s_warning_info_len;
+2 -2
View File
@@ -2305,7 +2305,7 @@ void menuProcFunctionSwitches(uint8_t event)
break; break;
} }
else if (sd->func == FUNC_PLAY_VALUE) { else if (sd->func == FUNC_PLAY_VALUE) {
val_max = NUM_XCHNPLAY; val_max = NUM_XCHNPLAY-1;
putsChnRaw(17*FW, y, val_displayed+1, attr); putsChnRaw(17*FW, y, val_displayed+1, attr);
} }
#endif #endif
@@ -2320,7 +2320,7 @@ void menuProcFunctionSwitches(uint8_t event)
lcd_outdezAtt(21*FW, y, val_displayed, attr); lcd_outdezAtt(21*FW, y, val_displayed, attr);
} }
else if (sd->func == FUNC_PLAY_VALUE) { else if (sd->func == FUNC_PLAY_VALUE) {
val_max = NUM_XCHNPLAY; val_max = NUM_XCHNPLAY-1;
putsChnRaw(17*FW, y, val_displayed+1, attr); putsChnRaw(17*FW, y, val_displayed+1, attr);
} }
#endif #endif
+38 -12
View File
@@ -1084,12 +1084,12 @@ uint8_t checkTrim(uint8_t event)
{ {
int8_t k = (event & EVT_KEY_MASK) - TRM_BASE; int8_t k = (event & EVT_KEY_MASK) - TRM_BASE;
int8_t s = g_model.trimInc; int8_t s = g_model.trimInc;
if (k>=0 && k<8) { if (k>=0 && k<8 && !IS_KEY_BREAK(event)) {
#else #else
void checkTrims() void checkTrims()
{ {
uint8_t event = getEvent(true); uint8_t event = getEvent(true);
if (event) { if (event && !IS_KEY_BREAK(event)) {
int8_t k = (event & EVT_KEY_MASK) - TRM_BASE; int8_t k = (event & EVT_KEY_MASK) - TRM_BASE;
int8_t s = g_model.trimInc; int8_t s = g_model.trimInc;
#endif #endif
@@ -1597,19 +1597,37 @@ void playValue(uint8_t idx)
att |= PREC1; att |= PREC1;
} }
} }
playNumber(converted_value, UNIT_VOLTS, att); playNumber(converted_value, 1+UNIT_VOLTS, att);
break; break;
} }
case NUM_XCHNRAW+TELEM_CELL-1: case NUM_XCHNRAW+TELEM_CELL-1:
playNumber(val, UNIT_VOLTS, PREC2); playNumber(val, 1+UNIT_VOLTS, PREC2);
break;
case NUM_XCHNRAW+TELEM_VFAS-1:
case NUM_XCHNRAW+TELEM_CELLS_SUM-1:
playNumber(val, 1+UNIT_VOLTS, PREC1);
break;
case NUM_XCHNRAW+TELEM_CURRENT-1:
case NUM_XCHNRAW+TELEM_MAX_CURRENT-1:
playNumber(val, 1+UNIT_AMPS, PREC1);
break; break;
case NUM_XCHNRAW+TELEM_ACCx-1: case NUM_XCHNRAW+TELEM_ACCx-1:
case NUM_XCHNRAW+TELEM_ACCy-1: case NUM_XCHNRAW+TELEM_ACCy-1:
case NUM_XCHNRAW+TELEM_ACCz-1: case NUM_XCHNRAW+TELEM_ACCz-1:
case NUM_XCHNRAW+TELEM_VSPD-1: case NUM_XCHNRAW+TELEM_VSPD-1:
playNumber(val, UNIT_RAW, PREC2); playNumber(val, 0, PREC2);
break;
case NUM_XCHNRAW+TELEM_CONSUMPTION-1:
playNumber(val, 1+UNIT_MAH);
break;
case NUM_XCHNRAW+TELEM_POWER-1:
playNumber(val, 1+UNIT_WATTS);
break; break;
case NUM_XCHNRAW+TELEM_RSSI_TX-1: case NUM_XCHNRAW+TELEM_RSSI_TX-1:
@@ -1617,27 +1635,35 @@ void playValue(uint8_t idx)
playNumber(val); playNumber(val);
break; break;
#if defined(IMPERIAL_UNITS) #if defined(IMPERIAL_UNITS)
case NUM_XCHNRAW+TELEM_ALT-1: case NUM_XCHNRAW+TELEM_ALT-1:
case NUM_XCHNRAW+TELEM_MIN_ALT-1: case NUM_XCHNRAW+TELEM_MIN_ALT-1:
case NUM_XCHNRAW+TELEM_MAX_ALT-1: case NUM_XCHNRAW+TELEM_MAX_ALT-1:
if (g_model.frsky.usrProto == USR_PROTO_WS_HOW_HIGH) { if (g_model.frsky.usrProto == USR_PROTO_WS_HOW_HIGH) {
playNumber(val, UNIT_FEET); playNumber(val, 1+UNIT_FEET);
break; break;
} }
// no break // no break
#endif #endif
default: default:
{ {
uint8_t unit; uint8_t unit;
if (idx >= NUM_XCHNRAW && idx <= NUM_XCHNRAW+TELEM_GPSALT-1) if (idx >= NUM_XCHNRAW+TELEM_ALT-1 && idx <= NUM_XCHNRAW+TELEM_GPSALT-1)
unit = idx - NUM_XCHNRAW - 6; unit = idx - (NUM_XCHNRAW+TELEM_ALT-1);
else if (idx >= NUM_XCHNRAW+TELEM_MAX_T1-1 && idx <= NUM_XCHNRAW+TELEM_MAX_DIST-1) else if (idx >= NUM_XCHNRAW+TELEM_MAX_T1-1 && idx <= NUM_XCHNRAW+TELEM_MAX_DIST-1)
unit = idx - NUM_XCHNRAW - 22; unit = 3 + idx - (NUM_XCHNRAW+TELEM_MAX_T1-1);
else else
unit = 1; unit = 1;
playNumber(val, pgm_read_byte(bchunit_ar+unit)); unit = pgm_read_byte(bchunit_ar+unit);
#if !defined(IMPERIAL_UNITS)
if (unit == UNIT_KTS) {
// kts to km/h
unit = UNIT_KMH;
val = (val * 46) / 25;
}
#endif
playNumber(val, unit == UNIT_RAW ? 0 : unit+1);
break; break;
} }
} }
+3
View File
@@ -296,10 +296,13 @@ void eeprom_read_block (void *pointer_ram,
#define board_init() #define board_init()
#define CoSetFlag(...) #define CoSetFlag(...)
#define CoClearFlag(...)
#define CoSetTmrCnt(...) #define CoSetTmrCnt(...)
#define CoEnterISR(...) #define CoEnterISR(...)
#define CoExitISR(...) #define CoExitISR(...)
#define CoStartTmr(...) #define CoStartTmr(...)
#define CoWaitForSingleFlag(...) #define CoWaitForSingleFlag(...)
#define CoEnterMutexSection(...)
#define CoLeaveMutexSection(...)
#endif #endif
+16 -4
View File
@@ -64,6 +64,10 @@ enum EnglishPrompts {
PROMPT_DEGREES = PROMPT_UNITS_BASE+UNIT_DEGREES, PROMPT_DEGREES = PROMPT_UNITS_BASE+UNIT_DEGREES,
PROMPT_PERCENT = PROMPT_UNITS_BASE+UNIT_PERCENT, PROMPT_PERCENT = PROMPT_UNITS_BASE+UNIT_PERCENT,
PROMPT_MILLIAMPS = PROMPT_UNITS_BASE+UNIT_MILLIAMPS, PROMPT_MILLIAMPS = PROMPT_UNITS_BASE+UNIT_MILLIAMPS,
PROMPT_MAH = PROMPT_UNITS_BASE+UNIT_MAH,
PROMPT_WATTS = PROMPT_UNITS_BASE+UNIT_WATTS,
PROMPT_FEET = PROMPT_UNITS_BASE+UNIT_FEET,
PROMPT_KTS = PROMPT_UNITS_BASE+UNIT_KTS,
}; };
#if defined(SOMO) || defined(PCBARM) #if defined(SOMO) || defined(PCBARM)
@@ -79,27 +83,35 @@ void playNumber(int16_t number, uint8_t unit, uint8_t att)
prompts.extend(self.getNumberPrompt(temp_digit)) prompts.extend(self.getNumberPrompt(temp_digit))
prompts.append(Prompt(GUIDE_00_MILLION, dir=2)) prompts.append(Prompt(GUIDE_00_MILLION, dir=2))
*/ */
if (number < 0) {
pushPrompt(PROMPT_MINUS);
number = -number;
}
if (number >= 1000) { if (number >= 1000) {
playNumber(number / 1000); playNumber(number / 1000);
pushPrompt(PROMPT_THOUSAND); pushPrompt(PROMPT_THOUSAND);
number %= 1000; number %= 1000;
if (number == 0) if (number == 0)
return; number = -1;
} }
if (number >= 100) { if (number >= 100) {
pushPrompt(PROMPT_ZERO + number/100); pushPrompt(PROMPT_ZERO + number/100);
pushPrompt(PROMPT_HUNDRED); pushPrompt(PROMPT_HUNDRED);
number %= 100; number %= 100;
if (number == 0) if (number == 0)
return; number = -1;
} }
if (number >= 20) { if (number >= 20) {
pushPrompt(PROMPT_TWENTY + (number-20)/10); pushPrompt(PROMPT_TWENTY + (number-20)/10);
number %= 10; number %= 10;
if (number == 0) if (number == 0)
return; number = -1;
}
if (number >= 0) {
pushPrompt(PROMPT_ZERO+number);
} }
pushPrompt(PROMPT_ZERO+number);
if (unit) { if (unit) {
pushPrompt(PROMPT_UNITS_BASE+unit-1); pushPrompt(PROMPT_UNITS_BASE+unit-1);