diff --git a/src/audio.cpp b/src/audio.cpp index da7a14ade..857e64835 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -14,11 +14,20 @@ #include "open9x.h" + +#if defined(PCBV4) +#define SPEAKER_OFF TCCR0A &= ~(1< 0) { #if defined(PCBV4) OCR0A = (5000 / toneFreq); // sticking with old values approx 20(abs. min) to 90, 60 being the default tone(?). - TCCR0A |= (1<= 0) { + HAPTIC_ON; // haptic output 'high' + } + else { + HAPTIC_OFF; // haptic output 'low' + hapticTick = g_eeGeneral.hapticStrength; + } + } +#endif } else { -#if defined(PCBV4) - TCCR0A &= ~(1< 0) { - HAPTIC_ON; // haptic output 'high' - hapticTick++; - } - else { - HAPTIC_OFF; //haptic output low - hapticTick = 0; - } - } - else { - HAPTIC_OFF; // haptic output 'low' - } -#endif - inline uint8_t audioQueue::getToneLength(uint8_t tLen) { uint8_t result = tLen; // default @@ -128,9 +136,10 @@ void audioQueue::playNow(uint8_t tFreq, uint8_t tLen, uint8_t tPause, toneFreq = tFreq + g_eeGeneral.speakerPitch + BEEP_OFFSET; // add pitch compensator toneTimeLeft = getToneLength(tLen); tonePause = tPause; - #ifdef HAPTIC - t_queueToneHaptic = tHaptic; - #endif +#if defined(HAPTIC) + toneHaptic = tHaptic; + hapticTick = 0; +#endif toneFreqIncr = tFreqIncr; t_queueWidx = t_queueRidx; @@ -147,7 +156,7 @@ void audioQueue::playASAP(uint8_t tFreq, uint8_t tLen, uint8_t tPause, queueToneFreq[t_queueWidx] = tFreq + g_eeGeneral.speakerPitch + BEEP_OFFSET; // add pitch compensator queueToneLength[t_queueWidx] = getToneLength(tLen); queueTonePause[t_queueWidx] = tPause; -#ifdef HAPTIC +#if defined(HAPTIC) queueToneHaptic[t_queueWidx] = tHaptic; #endif queueToneRepeat[t_queueWidx] = tRepeat; diff --git a/src/audio.h b/src/audio.h index fde16cda3..e48c7066d 100644 --- a/src/audio.h +++ b/src/audio.h @@ -22,11 +22,6 @@ #define BEEP_KEY_UP_FREQ (BEEP_DEFAULT_FREQ+5) #define BEEP_KEY_DOWN_FREQ (BEEP_DEFAULT_FREQ-5) -// #define AUDIO_QUEUE_HEARTBEAT_XSHORT (30) //speaker timing [Norm] -// #define AUDIO_QUEUE_HEARTBEAT_SHORT (50) //speaker timing [Norm] -// #define AUDIO_QUEUE_HEARTBEAT_NORM (77) //speaker timing [Norm] -// #define AUDIO_QUEUE_HEARTBEAT_LONG (130) //speaker timing [Long] -// #define AUDIO_QUEUE_HEARTBEAT_XLONG (200) //speaker timing [xLong] #ifdef HAPTIC #define HAPTIC_ON PORTG |= (1<<2) #define HAPTIC_OFF PORTG &= ~(1<<2)