Some more optimizations on AUDIO. AUDIO option set to false by default.

This commit is contained in:
bsongis
2012-01-30 18:42:14 +00:00
parent 3c8475636c
commit 74e454cd0b
6 changed files with 55 additions and 65 deletions
+14 -13
View File
@@ -62,7 +62,7 @@ endif
# AUDIO Mods
# Values = YES, NO
AUDIO = YES
AUDIO = NO
# HAPTIC Mods
# Values = YES, NO
@@ -229,16 +229,6 @@ ifeq ($(SPLASH), YES)
CPPDEFS += -DSPLASH
endif
ifeq ($(AUDIO), YES)
CPPDEFS += -DAUDIO
CPPSRC += audio.cpp
ifeq ($(HAPTIC), YES)
CPPDEFS += -DHAPTIC
endif
else
CPPSRC += beeper.cpp
endif
# If ARDUPILOT-Support is enabled
ifeq ($(EXT), ARDUPILOT)
CPPDEFS += -DARDUPILOT
@@ -273,7 +263,8 @@ endif
ifeq ($(PCB), V4)
# V4 PCB, so ...
CPPDEFS += -DPCBV4
CPPDEFS += -DPCBV4 -DAUDIO
CPPSRC += audio.cpp
ifeq ($(NAVIGATION), RE1)
CPPDEFS += -DNAVIGATION_RE1
@@ -284,7 +275,7 @@ ifeq ($(PCB), V4)
CPPDEFS += -DLOGS
MODS:=${MODS}L
endif
ifeq ($(SOMO), YES)
CPPSRC += somo14d.cpp
CPPDEFS += -DSOMO
@@ -293,6 +284,16 @@ else
# STD PCB, so ...
CPPDEFS += -DPCBSTD
ifeq ($(AUDIO), YES)
CPPDEFS += -DAUDIO
CPPSRC += audio.cpp
ifeq ($(HAPTIC), YES)
CPPDEFS += -DHAPTIC
endif
else
CPPSRC += beeper.cpp
endif
# If BandGap is not rock solid
ifeq ($(BATT), UNSTABLE_BANDGAP)
CPPDEFS += -DBATT_UNSTABLE_BANDGAP
+2 -21
View File
@@ -52,30 +52,11 @@ bool audioQueue::freeslots(uint8_t slots)
}
*/
//heartbeat is responsibile for issueing the audio tones and general square waves
// heartbeat is responsibile for issueing the audio tones and general square waves
// it is essentially the life of the class.
// it is called every 10ms
void audioQueue::heartbeat()
{
#if defined(PCBSTD)
if (toneTimeLeft > 0) {
//square wave generator use for speaker mod
//simply generates a square wave for toneFreq for
//as long as the toneTimeLeft is more than 0
static uint8_t toneCounter;
toneCounter += toneFreq;
if ((toneCounter & 0x80) == 0x80)
PORTE |= (1 << OUT_E_BUZZER); // speaker output 'high'
else
PORTE &= ~(1 << OUT_E_BUZZER); // speaker output 'low'
}
static uint8_t cnt10ms = 77; // execute 10ms code once every 78 ISRs
if (cnt10ms-- == 0) // every 10ms ...
cnt10ms = 77;
else
return;
#endif
if (toneTimeLeft > 0) {
#if defined(PCBV4)
OCR0A = (5000 / toneFreq); // sticking with old values approx 20(abs. min) to 90, 60 being the default tone(?).
+20 -1
View File
@@ -166,6 +166,25 @@ void audioDefevent(uint8_t e);
#define AUDIO_MIX_WARNING_1() audioDefevent(AU_MIX_WARNING_1)
#define AUDIO_MIX_WARNING_3() audioDefevent(AU_MIX_WARNING_3)
#define AUDIO_HEARTBEAT() audio.heartbeat()
#if defined(PCBSTD)
#define AUDIO_HEARTBEAT() \
if (audio.toneTimeLeft > 0) { \
static uint8_t toneCounter; \
toneCounter += audio.toneFreq; \
if ((toneCounter & 0x80) == 0x80) \
PORTE |= (1 << OUT_E_BUZZER); \
else \
PORTE &= ~(1 << OUT_E_BUZZER); \
} \
static uint8_t cnt10ms = 77; \
if (cnt10ms-- == 0) \
cnt10ms = 77; \
else \
return; \
audio.heartbeat()
#else
#define AUDIO_HEARTBEAT() \
audio.heartbeat()
#endif
#endif // audio_h
+1
View File
@@ -26,6 +26,7 @@ uint8_t beepAgain = 0;
uint8_t beepAgainOrig = 0;
uint8_t beepOn = false;
bool warble = false;
bool warbleC;
// The various "beep" tone lengths
static prog_uint8_t APM beepTab[]= {
+18 -18
View File
@@ -27,29 +27,29 @@ extern uint8_t beepAgain;
extern uint8_t beepAgainOrig;
extern uint8_t beepOn;
extern bool warble;
extern bool warbleC;
extern void beep(uint8_t val);
#define AUDIO_KEYPAD_UP() beep(0)
#define AUDIO_KEYPAD_DOWN() beep(0)
#define AUDIO_MENUS() beep(0)
#define AUDIO_TRIM() beep(1)
#define AUDIO_WARNING2() beep(2)
#define AUDIO_WARNING1() beep(3)
#define AUDIO_ERROR() beep(4)
#define IS_AUDIO_BUSY() (g_beepCnt || beepAgain || beepOn)
#define AUDIO_TIMER_30() { beepAgain=2; beep(2); }
#define AUDIO_TIMER_20() { beepAgain=1; beep(2); }
#define AUDIO_TIMER_10() beep(2)
#define AUDIO_TIMER_LT3() beep(2)
#define AUDIO_MINUTE_BEEP() beep(2)
#define AUDIO_INACTIVITY() beep(3)
#define AUDIO_KEYPAD_UP() beep(0)
#define AUDIO_KEYPAD_DOWN() beep(0)
#define AUDIO_MENUS() beep(0)
#define AUDIO_TRIM() beep(1)
#define AUDIO_WARNING2() beep(2)
#define AUDIO_WARNING1() beep(3)
#define AUDIO_ERROR() beep(4)
#define AUDIO_TIMER_30() { beepAgain=2; beep(2); }
#define AUDIO_TIMER_20() { beepAgain=1; beep(2); }
#define AUDIO_TIMER_10() beep(2)
#define AUDIO_TIMER_LT3() beep(2)
#define AUDIO_MINUTE_BEEP() beep(2)
#define AUDIO_INACTIVITY() beep(3)
#define AUDIO_MIX_WARNING_1() beep(1)
#define AUDIO_MIX_WARNING_3() beep(1)
inline void AUDIO_HEARTBEAT()
#define IS_AUDIO_BUSY() (g_beepCnt || beepAgain || beepOn)
FORCEINLINE void AUDIO_HEARTBEAT()
{
//cnt >/=0
//beepon/off
@@ -77,7 +77,7 @@ inline void AUDIO_HEARTBEAT()
// G: use original external buzzer for beeps
if (beepOn) {
static bool warbleC;
//static bool warbleC;
warbleC = warble && !warbleC;
if (warbleC)
PORTE &= ~(1 << OUT_E_BUZZER); // speaker output 'low'
-12
View File
@@ -1778,14 +1778,6 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
AUDIO_HEARTBEAT();
#if defined (PCBSTD) && defined (AUDIO)
static uint8_t cnt10ms = 77; // execute 10ms code once every 78 ISRs
if (cnt10ms-- == 0) // BEGIN { ... every 10ms ... }
{
// Begin 10ms event
cnt10ms = 77;
#endif
#ifdef DEBUG
// Record start time from TCNT1 to record excution time
cli();
@@ -1807,10 +1799,6 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
uint16_t dt2 = TCNT1; // capture end time
sei();
g_time_per10 = dt2 - dt; // NOTE: These spike to nearly 65535 just now and then. Why? :/
#endif
#if defined (PCBSTD) && defined (AUDIO)
} // end 10ms event
#endif
cli();