Beispiel #1
0
boolean MyTone::writeVal( HardwareTypeIdentifier type, HardwareCommandResult* result ) {
	if(type == HWType_tone && result != NULL && result->getUint16ListNum() > 0) {
		uint16_t length = result->getUint16List()[0];

		uint8_t tone = this->myTone;
		if(result->getUint16ListNum() > 1)
		tone = result->getUint16List()[1];

		write(tone);
		int num = timer.setTimeout(length, (timer_callback) &MyTone::stopOutputHook);
		timer.setCallbackContext(num, (void*) this);

		return true;
	}

	return false;
}
Beispiel #2
0
// Lower drill, outputs 2sec pulse to lowering pin
void LowerDrill(){
  DrillDown.on();
  timer.setTimeout(2000, StopDrillMove);
}
Beispiel #3
0
// Lift drill, outputs 2sec pulse to lifting pin.
void LiftDrill(){
  DrillUp.on();
  timer.setTimeout(2000, StopDrillMove);
}
// Function to protect bluetooth disconnection
void timer_init(void){
  BT_timer_id = timer.setTimeout(1000, terminate);  // Stop all the motors in two seconds after bluetooth is disconnected, setTimeout function will return the ID of the timer.
  timer.disable(BT_timer_id);                       // Disable to timer before connected to Android phone
}