[All] Code refactoring

- keys beep and haptic refactoring (not anymore audio events)
- trims move/mid/min/max refactoring (trim end splitted to trim min / trim max)
- S6R new alarms
- S6R servos/rx status displayed as a text (not an integer which has no sense)
- Timer countdown configuration
- The splash was not displayed (but the timeout was there) after the first calibration
This commit is contained in:
Bertrand Songis
2016-05-13 14:41:48 +02:00
parent 24abad55ca
commit 7908eaa406
82 changed files with 749 additions and 598 deletions
+88 -20
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -79,7 +79,7 @@ void audioQueue::heartbeat()
toneFreq = tone2Freq;
#endif
tone2TimeLeft--; //time gets counted down
}
}
else {
speakerOff();
}
@@ -128,7 +128,7 @@ void audioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tFlag
else {
tFlags++;
}
tFlags &= 0x0f;
if (tFlags) {
uint8_t next_queueWidx = (t_queueWidx + 1) & (AUDIO_QUEUE_LENGTH-1);
@@ -144,7 +144,7 @@ void audioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tFlag
}
}
void audioQueue::event(uint8_t e, uint8_t f)
void audioQueue::event(uint8_t e)
{
#if defined(HAPTIC)
haptic.event(e); //do this before audio to help sync timings
@@ -156,7 +156,7 @@ void audioQueue::event(uint8_t e, uint8_t f)
}
}
if (g_eeGeneral.beepMode>0 || (g_eeGeneral.beepMode==0 && e>=AU_TRIM_MOVE) || (g_eeGeneral.beepMode>=-1 && e<=AU_ERROR)) {
if (g_eeGeneral.beepMode >= e_mode_nokeys || (g_eeGeneral.beepMode >= e_mode_alarms && e <= AU_ERROR)) {
if (e < AU_SPECIAL_SOUND_FIRST || empty()) {
// TODO when VOICE enable some cases here are not needed!
switch (e) {
@@ -168,12 +168,6 @@ void audioQueue::event(uint8_t e, uint8_t f)
}
break;
#endif
case AU_TRIM_MOVE:
play(f, 6, 1, PLAY_NOW);
break;
case AU_TRIM_MIDDLE:
play(f, 10, 2, PLAY_NOW);
break;
case AU_SPECIAL_SOUND_RING:
play(BEEP_DEFAULT_FREQ+25, 5, 2, PLAY_REPEAT(10));
play(BEEP_DEFAULT_FREQ+25, 5, 10, PLAY_REPEAT(1));
@@ -214,22 +208,14 @@ void audioQueue::event(uint8_t e, uint8_t f)
static const pm_uint8_t singleSounds[] PROGMEM = {
70, 10, 2, PLAY_REPEAT(2)|PLAY_NOW, // INACTIVITY
BEEP_DEFAULT_FREQ, 40, 1, PLAY_NOW, // ERROR
BEEP_KEY_UP_FREQ, 10, 1, PLAY_NOW, // KEYPAD_UP
BEEP_KEY_DOWN_FREQ, 10, 1, PLAY_NOW, // KEYPAD_DOWN
BEEP_DEFAULT_FREQ, 10, 2, PLAY_NOW, // MENUS
0,0,0,0, // TRIM_MOVE
BEEP_DEFAULT_FREQ, 10, 1, PLAY_NOW, // WARNING1
BEEP_DEFAULT_FREQ, 20, 1, PLAY_NOW, // WARNING2
BEEP_DEFAULT_FREQ, 30, 1, PLAY_NOW, // WARNING3
0,0,0,0, // TRIM_MIDDLE
60, 10, 2, PLAY_NOW, // TRIM_MIDDLE
BEEP_DEFAULT_FREQ + 50, 10, 1, PLAY_NOW, // POT_STICK_MIDDLE
BEEP_DEFAULT_FREQ + 50, 6, 0, 0, // MIX_WARNING_1
BEEP_DEFAULT_FREQ + 52, 6, 3, PLAY_REPEAT(1), // MIX_WARNING_2
BEEP_DEFAULT_FREQ + 54, 6, 3, PLAY_REPEAT(2), // MIX_WARNING_3
BEEP_DEFAULT_FREQ + 50, 30, 3, PLAY_NOW, // TIMER_00
BEEP_DEFAULT_FREQ + 50, 15, 3, PLAY_NOW, // TIMER_LT10
BEEP_DEFAULT_FREQ + 50, 15, 3, PLAY_REPEAT(1)|PLAY_NOW, // TIMER_20
BEEP_DEFAULT_FREQ + 50, 15, 3, PLAY_REPEAT(2)|PLAY_NOW, // TIMER_30
BEEP_DEFAULT_FREQ, 10, 1, 0, // FRSKY_BEEP1
BEEP_DEFAULT_FREQ, 20, 1, 0, // FRSKY_BEEP2
BEEP_DEFAULT_FREQ, 30, 1, 0, // FRSKY_BEEP3
@@ -258,3 +244,85 @@ void audioDefevent(uint8_t e)
{
audio.event(e);
}
void audioKeyPress()
{
#if defined(AUDIO)
if (g_eeGeneral.beepMode == e_mode_all) {
audio.play(BEEP_DEFAULT_FREQ, 10, 1, PLAY_NOW);
}
#else
beep(0);
#endif
#if defined(HAPTIC)
if (g_eeGeneral.hapticMode == e_mode_all) {
haptic.play(5, 0, PLAY_NOW);
}
#endif
}
void audioTrimPress(int16_t value)
{
if (g_eeGeneral.beepMode >= e_mode_nokeys) {
#if defined(AUDIO)
value = limit(TRIM_MIN, value, TRIM_MAX);
value >>= 2;
value += 60;
audio.play(value, 6, 1, PLAY_NOW);
#else
warble = true;
beep(1);
#endif
}
}
void audioTimerCountdown(uint8_t timer, int value)
{
if (0) {
// pass
}
#if defined(CPUM2560)
if (g_model.timers[timer].countdownBeep == COUNTDOWN_VOICE) {
if (value >= 0 && value <= g_model.timers[timer].countdownStart) {
playNumber(value, 0, 0, 0);
}
else if (value == 30 || value == 20) {
playDuration(value, 0, 0);
}
}
#endif
#if defined(HAPTIC)
else if (g_model.timers[timer].countdownBeep == COUNTDOWN_HAPTIC) {
if (value == 0) {
haptic.play(15, 3, PLAY_NOW);
}
else if (value > 0 && value <= 10) {
haptic.play(5, 0, PLAY_NOW);
}
else if (value == 30) {
haptic.play(10, 3, PLAY_REPEAT(2) | PLAY_NOW);
}
else if (value == 20) {
haptic.play(10, 3, PLAY_REPEAT(1) | PLAY_NOW);
}
}
#endif
else {
if (value == 0) {
audio.play(BEEP_DEFAULT_FREQ + 50, 30, 3, PLAY_NOW);
}
else if (value > 0 && value <= 10) {
audio.play(BEEP_DEFAULT_FREQ + 50, 15, 3, PLAY_NOW);
}
else if (value == 30) {
audio.play(BEEP_DEFAULT_FREQ + 50, 15, 3, PLAY_REPEAT(2) | PLAY_NOW);
}
else if (value == 20) {
audio.play(BEEP_DEFAULT_FREQ + 50, 15, 3, PLAY_REPEAT(1) | PLAY_NOW);
}
}
}