Пример #1
0
void hapticQueue::heartbeat()
{
#if defined(SIMU)
  return;
#else
  if (buzzTimeLeft > 0) {
    buzzTimeLeft--; // time gets counted down
#if defined(PCBSKY9X) || (defined(PCBTARANIS) && defined(REVPLUS))
    hapticOn(HAPTIC_STRENGTH() * 20);
#else
    if (hapticTick-- > 0) {
      HAPTIC_ON();
    }
    else {
      HAPTIC_OFF();
      hapticTick = HAPTIC_STRENGTH();
    }
#endif
  }
  else {
    HAPTIC_OFF();
    if (buzzPause > 0) {
      buzzPause--;
    }
    else if (t_queueRidx != t_queueWidx) {
      buzzTimeLeft = queueHapticLength[t_queueRidx];
      buzzPause = queueHapticPause[t_queueRidx];
      if (!queueHapticRepeat[t_queueRidx]--) {
        t_queueRidx = (t_queueRidx + 1) & (HAPTIC_QUEUE_LENGTH-1);
      }
    }
  }
#endif // defined(SIMU)
}
Пример #2
0
// heartbeat is responsibile for issueing the audio tones and general square waves
// it is essentially the life of the class.
// it is called every 10ms
void audioQueue::heartbeat()
{
  if (toneTimeLeft > 0) {
    toneTimeLeft--; //time gets counted down
    toneFreq += toneFreqIncr;
    if (toneHaptic){
      if (hapticTick-- > 0) {
        HAPTIC_ON(); // haptic output 'high'
      }
      else {
        HAPTIC_OFF(); // haptic output 'low'
        hapticTick = g_eeGeneral.hapticStrength;
      }
    }
  }
  else {
    SPEAKER_OFF;
    HAPTIC_OFF();

    //if (tonePause-- <= 0) {
    if (tonePause > 0) {
      tonePause--;
    } else  {  
      if (t_queueRidx != t_queueWidx) {
        toneFreq = queueToneFreq[t_queueRidx];
        toneTimeLeft = queueToneLength[t_queueRidx];
        toneFreqIncr = queueToneFreqIncr[t_queueRidx];
        tonePause = queueTonePause[t_queueRidx];
        toneHaptic = queueToneHaptic[t_queueRidx];
        hapticTick = 0;
        if (!queueToneRepeat[t_queueRidx]--) {
          t_queueRidx = (t_queueRidx + 1) % AUDIO_QUEUE_LENGTH;
        }
      }
    }
  }
}