From 3e009decfbf2d6ef547ef66652dc947144d644b1 Mon Sep 17 00:00:00 2001 From: bsongis Date: Wed, 1 Feb 2012 18:55:08 +0000 Subject: [PATCH] HAPTIC is now able to work without AUDIO New function in function switches to play an Audio track Trims can be used to modify a mixer offset. Offsets for Frsky can go from -128 to +127 Vibrations motor on v4 (HAPTIC option too) --- src/audio.cpp | 13 +- src/audio.h | 74 +++++------- src/beeper.cpp | 3 + src/beeper.h | 21 +++- src/general_menus.cpp | 4 +- src/model_menus.cpp | 36 ++++-- src/myeeprom.h | 25 ++-- src/o9xstrings.cpp | 9 ++ src/o9xstrings.h | 6 +- src/open9x.cpp | 272 +++++++++++++++++++++++------------------- src/open9x.h | 35 +++++- src/translations/en.h | 11 +- src/translations/fr.h | 11 +- 13 files changed, 296 insertions(+), 224 deletions(-) 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