diff --git a/src/audio.cpp b/src/audio.cpp index 338b89bf3..04d6a635c 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -14,13 +14,6 @@ #include "open9x.h" -#if defined(PCBV4) -#define SPEAKER_OFF TCCR0A &= ~(1< 0) { - switch (g_eeGeneral.speakerMode){ - case 0: - //stock beeper. simply turn port on for x time! - if (toneTimeLeft > 0){ - PORTE |= (1< 0) { + switch (g_eeGeneral.speakerMode) { + case 0: + // stock beeper. simply turn port on for x time! + if (toneTimeLeft > 0){ + PORTE |= (1< 0) { toneCounter += toneFreq; if ((toneCounter & 0x80) == 0x80) - PORTE |= (1 << OUT_E_BUZZER); + BUZZER_ON; else - PORTE &= ~(1 << OUT_E_BUZZER); + BUZZER_OFF; } } -#endif - #endif // heartbeat is responsibile for issueing the audio tones and general square waves diff --git a/src/beeper.cpp b/src/beeper.cpp index 7322bea5c..7ec0b4e83 100644 --- a/src/beeper.cpp +++ b/src/beeper.cpp @@ -27,6 +27,9 @@ uint8_t beepAgainOrig = 0; uint8_t beepOn = false; bool warble = false; bool warbleC; +#if defined(HAPTIC) +uint8_t hapticTick = 0; +#endif // The various "beep" tone lengths static prog_uint8_t APM beepTab[]= { diff --git a/src/beeper.h b/src/beeper.h index d874d4802..632d2db89 100644 --- a/src/beeper.h +++ b/src/beeper.h @@ -28,6 +28,9 @@ extern uint8_t beepAgainOrig; extern uint8_t beepOn; extern bool warble; extern bool warbleC; +#if defined(HAPTIC) +extern uint8_t hapticTick; +#endif extern void beep(uint8_t val); @@ -72,17 +75,25 @@ FORCEINLINE void AUDIO_HEARTBEAT() } } - // G: use original external buzzer for beeps if (beepOn) { - //static bool warbleC; warbleC = warble && !warbleC; if (warbleC) - PORTE &= ~(1 << OUT_E_BUZZER); // speaker output 'low' + BUZZER_OFF; else - PORTE |= (1 << OUT_E_BUZZER); // speaker output 'high' + BUZZER_ON; +#if defined(HAPTIC) + if (hapticTick-- > 0) { + HAPTIC_ON; // haptic output 'high' + } + else { + HAPTIC_OFF; // haptic output 'low' + hapticTick = g_eeGeneral.hapticStrength; + } +#endif } else { - PORTE &= ~(1 << OUT_E_BUZZER); // speaker output 'low' + BUZZER_OFF; + HAPTIC_OFF; } } diff --git a/src/general_menus.cpp b/src/general_menus.cpp index 03057c78e..d7e6c358a 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -95,7 +95,7 @@ void menuProcSetup(uint8_t event) #ifdef AUDIO if(s_pgOfs