Some more optimizations on AUDIO. AUDIO option set to false by default.
This commit is contained in:
+13
-12
@@ -62,7 +62,7 @@ endif
|
|||||||
|
|
||||||
# AUDIO Mods
|
# AUDIO Mods
|
||||||
# Values = YES, NO
|
# Values = YES, NO
|
||||||
AUDIO = YES
|
AUDIO = NO
|
||||||
|
|
||||||
# HAPTIC Mods
|
# HAPTIC Mods
|
||||||
# Values = YES, NO
|
# Values = YES, NO
|
||||||
@@ -229,16 +229,6 @@ ifeq ($(SPLASH), YES)
|
|||||||
CPPDEFS += -DSPLASH
|
CPPDEFS += -DSPLASH
|
||||||
endif
|
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
|
# If ARDUPILOT-Support is enabled
|
||||||
ifeq ($(EXT), ARDUPILOT)
|
ifeq ($(EXT), ARDUPILOT)
|
||||||
CPPDEFS += -DARDUPILOT
|
CPPDEFS += -DARDUPILOT
|
||||||
@@ -273,7 +263,8 @@ endif
|
|||||||
|
|
||||||
ifeq ($(PCB), V4)
|
ifeq ($(PCB), V4)
|
||||||
# V4 PCB, so ...
|
# V4 PCB, so ...
|
||||||
CPPDEFS += -DPCBV4
|
CPPDEFS += -DPCBV4 -DAUDIO
|
||||||
|
CPPSRC += audio.cpp
|
||||||
|
|
||||||
ifeq ($(NAVIGATION), RE1)
|
ifeq ($(NAVIGATION), RE1)
|
||||||
CPPDEFS += -DNAVIGATION_RE1
|
CPPDEFS += -DNAVIGATION_RE1
|
||||||
@@ -293,6 +284,16 @@ else
|
|||||||
# STD PCB, so ...
|
# STD PCB, so ...
|
||||||
CPPDEFS += -DPCBSTD
|
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
|
# If BandGap is not rock solid
|
||||||
ifeq ($(BATT), UNSTABLE_BANDGAP)
|
ifeq ($(BATT), UNSTABLE_BANDGAP)
|
||||||
CPPDEFS += -DBATT_UNSTABLE_BANDGAP
|
CPPDEFS += -DBATT_UNSTABLE_BANDGAP
|
||||||
|
|||||||
+2
-21
@@ -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 essentially the life of the class.
|
||||||
|
// it is called every 10ms
|
||||||
void audioQueue::heartbeat()
|
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 (toneTimeLeft > 0) {
|
||||||
#if defined(PCBV4)
|
#if defined(PCBV4)
|
||||||
OCR0A = (5000 / toneFreq); // sticking with old values approx 20(abs. min) to 90, 60 being the default tone(?).
|
OCR0A = (5000 / toneFreq); // sticking with old values approx 20(abs. min) to 90, 60 being the default tone(?).
|
||||||
|
|||||||
+20
-1
@@ -166,6 +166,25 @@ void audioDefevent(uint8_t e);
|
|||||||
#define AUDIO_MIX_WARNING_1() audioDefevent(AU_MIX_WARNING_1)
|
#define AUDIO_MIX_WARNING_1() audioDefevent(AU_MIX_WARNING_1)
|
||||||
#define AUDIO_MIX_WARNING_3() audioDefevent(AU_MIX_WARNING_3)
|
#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
|
#endif // audio_h
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ uint8_t beepAgain = 0;
|
|||||||
uint8_t beepAgainOrig = 0;
|
uint8_t beepAgainOrig = 0;
|
||||||
uint8_t beepOn = false;
|
uint8_t beepOn = false;
|
||||||
bool warble = false;
|
bool warble = false;
|
||||||
|
bool warbleC;
|
||||||
|
|
||||||
// The various "beep" tone lengths
|
// The various "beep" tone lengths
|
||||||
static prog_uint8_t APM beepTab[]= {
|
static prog_uint8_t APM beepTab[]= {
|
||||||
|
|||||||
+18
-18
@@ -27,29 +27,29 @@ extern uint8_t beepAgain;
|
|||||||
extern uint8_t beepAgainOrig;
|
extern uint8_t beepAgainOrig;
|
||||||
extern uint8_t beepOn;
|
extern uint8_t beepOn;
|
||||||
extern bool warble;
|
extern bool warble;
|
||||||
|
extern bool warbleC;
|
||||||
|
|
||||||
extern void beep(uint8_t val);
|
extern void beep(uint8_t val);
|
||||||
|
|
||||||
#define AUDIO_KEYPAD_UP() beep(0)
|
#define AUDIO_KEYPAD_UP() beep(0)
|
||||||
#define AUDIO_KEYPAD_DOWN() beep(0)
|
#define AUDIO_KEYPAD_DOWN() beep(0)
|
||||||
#define AUDIO_MENUS() beep(0)
|
#define AUDIO_MENUS() beep(0)
|
||||||
#define AUDIO_TRIM() beep(1)
|
#define AUDIO_TRIM() beep(1)
|
||||||
#define AUDIO_WARNING2() beep(2)
|
#define AUDIO_WARNING2() beep(2)
|
||||||
#define AUDIO_WARNING1() beep(3)
|
#define AUDIO_WARNING1() beep(3)
|
||||||
#define AUDIO_ERROR() beep(4)
|
#define AUDIO_ERROR() beep(4)
|
||||||
|
#define AUDIO_TIMER_30() { beepAgain=2; beep(2); }
|
||||||
#define IS_AUDIO_BUSY() (g_beepCnt || beepAgain || beepOn)
|
#define AUDIO_TIMER_20() { beepAgain=1; beep(2); }
|
||||||
|
#define AUDIO_TIMER_10() beep(2)
|
||||||
#define AUDIO_TIMER_30() { beepAgain=2; beep(2); }
|
#define AUDIO_TIMER_LT3() beep(2)
|
||||||
#define AUDIO_TIMER_20() { beepAgain=1; beep(2); }
|
#define AUDIO_MINUTE_BEEP() beep(2)
|
||||||
#define AUDIO_TIMER_10() beep(2)
|
#define AUDIO_INACTIVITY() beep(3)
|
||||||
#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_1() beep(1)
|
||||||
#define AUDIO_MIX_WARNING_3() 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
|
//cnt >/=0
|
||||||
//beepon/off
|
//beepon/off
|
||||||
@@ -77,7 +77,7 @@ inline void AUDIO_HEARTBEAT()
|
|||||||
|
|
||||||
// G: use original external buzzer for beeps
|
// G: use original external buzzer for beeps
|
||||||
if (beepOn) {
|
if (beepOn) {
|
||||||
static bool warbleC;
|
//static bool warbleC;
|
||||||
warbleC = warble && !warbleC;
|
warbleC = warble && !warbleC;
|
||||||
if (warbleC)
|
if (warbleC)
|
||||||
PORTE &= ~(1 << OUT_E_BUZZER); // speaker output 'low'
|
PORTE &= ~(1 << OUT_E_BUZZER); // speaker output 'low'
|
||||||
|
|||||||
@@ -1778,14 +1778,6 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
|
|||||||
|
|
||||||
AUDIO_HEARTBEAT();
|
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
|
#ifdef DEBUG
|
||||||
// Record start time from TCNT1 to record excution time
|
// Record start time from TCNT1 to record excution time
|
||||||
cli();
|
cli();
|
||||||
@@ -1809,10 +1801,6 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
|
|||||||
g_time_per10 = dt2 - dt; // NOTE: These spike to nearly 65535 just now and then. Why? :/
|
g_time_per10 = dt2 - dt; // NOTE: These spike to nearly 65535 just now and then. Why? :/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (PCBSTD) && defined (AUDIO)
|
|
||||||
} // end 10ms event
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cli();
|
cli();
|
||||||
#if defined (PCBV4)
|
#if defined (PCBV4)
|
||||||
TIMSK2 |= (1<<OCIE2A);
|
TIMSK2 |= (1<<OCIE2A);
|
||||||
|
|||||||
Reference in New Issue
Block a user