diff --git a/src/audio.cpp b/src/audio.cpp index 17dabc74e..8bbb27a5a 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -43,6 +43,7 @@ audioQueue::audioQueue() #ifdef HAPTIC hapticTick = 0; + hapticSpinUpTime = 0; #endif } @@ -70,21 +71,25 @@ void audioQueue::heartbeat() toneTimeLeft = 0; //time gets counted down } - //this works - but really needs a delay added in. - // reason is because it takes time for the motor to spin up - // need to take this into account when the tone sent is really short! - // initial thoughts are a seconds queue to process haptic that gets - // fired from here. end result is haptic events run for mix of 2 seconds? #if defined(HAPTIC) + if (toneHaptic) { hapticOn((g_eeGeneral.hapticStrength * 2) * 10); + hapticSpinUpTime = HAPTIC_SPINUP; //min time haptic runs for. Might be worth a config option in system prefs to allow user to set to suit motor? } + #endif } else { - hapticOff(); +#if defined(HAPTIC) + if(hapticSpinUpTime > 0){ + hapticSpinUpTime--; + } else { + hapticOff(); + } +#endif if (tonePause) { if (queueTone(0, tonePause * 10, 0)) { diff --git a/src/audio.h b/src/audio.h index 3b43592eb..1647274e7 100644 --- a/src/audio.h +++ b/src/audio.h @@ -188,6 +188,7 @@ class audioQueue uint8_t toneHaptic; uint8_t hapticTick; uint8_t queueToneHaptic[AUDIO_QUEUE_LENGTH]; + uint8_t hapticSpinUpTime; #endif #if defined(PCBSTD) @@ -200,6 +201,8 @@ extern audioQueue audio; void audioDefevent(uint8_t e); +#define HAPTIC_SPINUP (10); + #define AUDIO_KEYPAD_UP() audioDefevent(AU_KEYPAD_UP) #define AUDIO_KEYPAD_DOWN() audioDefevent(AU_KEYPAD_DOWN) #define AUDIO_MENUS() audioDefevent(AU_MENUS) @@ -207,6 +210,7 @@ void audioDefevent(uint8_t e); #define AUDIO_WARNING2() audioDefevent(AU_WARNING2) #define AUDIO_ERROR() audioDefevent(AU_ERROR) + #define IS_AUDIO_BUSY() audio.busy() #define AUDIO_TIMER_30() audioDefevent(AU_TIMER_30)