コード例 #1
0
// Stops a waveform on a pin
int stopWaveform(uint8_t pin) {
  // Can't possibly need to stop anything if there is no timer active
  if (!timerRunning) {
    return false;
  }

  for (size_t i = 0; i < countof(waveform); i++) {
    if (!waveform[i].enabled) {
      continue; // Skip fast to next one, can't need to stop this one since it's not running
    }
    if (((pin == 16) && waveform[i].gpio16Mask) || ((pin != 16) && (waveform[i].gpioMask == 1<<pin))) {
      // Note that there is no interrupt unsafety here.  The IRQ can only ever change .enabled from 1->0
      // We're also doing that, so even if an IRQ occurred it would still stay as 0.
      waveform[i].enabled = 0;
      int cnt = timer1CB ? 1 : 0;
      for (size_t i = 0; (cnt == 0) && (i < countof(waveform)); i++) {
        cnt += waveform[i].enabled ? 1 : 0;
      }
      if (!cnt) {
        deinitTimer();
      }
      return true;
    }
  }
  return false;
}
コード例 #2
0
void VideoConverter::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/)
{
	deinitTimer();

	if (QFile::exists(videoItem->getVideoFileSavedTo()))
	{
		QFile output(videoItem->getVideoFileSavedTo());
		// has been converted?!
		if (output.size() == 0) // no
			{
				QFile::remove(videoItem->getVideoFileSavedTo());
				videoItem->setVideoFileSavedTo(videoItem->getVideoFile(), this);
			}
		else // yes
			if (deleteOriginalVideo)
				QFile::remove(videoItem->getVideoFile());
	}
	else
		videoItem->setVideoFileSavedTo(videoItem->getVideoFile(), this);

	videoItem->setAsConverted(this);
	videoItem->unlock(this);

	emit conversionFinished(videoItem);
}
コード例 #3
0
// Set a callback.  Pass in NULL to stop it
void setTimer1Callback(uint32_t (*fn)()) {
  timer1CB = fn;
  if (!timerRunning && fn) {
    initTimer();
  } else if (timerRunning && !fn) {
    int cnt = 0;
    for (size_t i = 0; i < countof(waveform); i++) {
      cnt += waveform[i].enabled ? 1 : 0;
    }
    if (!cnt) {
      deinitTimer();
    }
  }
  ReloadTimer(MicrosecondsToCycles(1)); // Cause an interrupt post-haste
}