コード例 #1
0
void Sensor::update() {
  if (Serial1.available() > 0) {
     input = Serial1.read();
     if( input == 0 || input == 1 ) {
       if (forward = (input == 0)) {
          calcTiming();
          nextFrame();
          frameCounter++; 
        } else {
          frameCounter--;
        } 
     } else if ( input == 2) {
       if (forward) nextSceneCounter++;
       if (nextSceneCounter >= nextSceneThreshold) {
         nextScene();
         nextSceneCounter = 0;
       }
     } else if ( input == 3 ) {
       if (forward) endCounter++; else startCounter++;
       if (endCounter >= endThreshold) {
         endFilm();
         endCounter = startCounter = 0;
       } else if (startCounter >= startThreshold) {
         startFilm();
         endCounter = startCounter = 0;
       } 
     }
  }
}
コード例 #2
0
ファイル: Servo.cpp プロジェクト: MisterRager/Sming
bool Servo::removeChannel(ServoChannel* channel)
{
	if (channels.removeElement(channel)) {
		ETS_INTR_LOCK();
		getPins();
		calcTiming();
		ETS_INTR_UNLOCK();
		if (channels.size() == 0) {
			started = false;
			hardwareTimer.stop();
		}
		return true;
	}
	return false;
}
コード例 #3
0
ファイル: Servo.cpp プロジェクト: MisterRager/Sming
bool Servo::addChannel(ServoChannel* channel)
{
	uint8 channel_count = channels.size();
	if (channel_count > SERVO_CHANNEL_NUM_MAX) return false;
	channels.add(channel);

	ETS_INTR_LOCK();
	getPins();
	calcTiming();
	ETS_INTR_UNLOCK();

	if (!started) {
		started = true;
		hardwareTimer.initializeUs(100000,ServoTimerInt);
		hardwareTimer.startOnce();
	}
	return true;
}