Created
March 3, 2012 20:52
-
-
Save tomgco/1968167 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | |
timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); //run event handler on the default global queue | |
dispatch_time_t now = dispatch_walltime(DISPATCH_TIME_NOW, 0); | |
dispatch_source_set_timer(timer, now, 140ull * NSEC_PER_MSEC, 5000ull); | |
dispatch_source_set_event_handler(timer, ^{ | |
[self sendPacket:CHANNEL1 yaw:[yaw intValue] pitch:[pitch intValue] throttle:[throttleJoystick intValue] trimAdjust:[trim intValue]]; | |
// NSLog(@"%d %d %d %d", [yaw intValue], [pitch intValue], [throttleJoystick intValue], [trim intValue]); | |
if ([[NSApp delegate] isSerialPortConnected] == YES) { | |
// set Status to green. | |
} else { | |
[self stopTimer]; | |
// set status to red. | |
} | |
}); | |
// now that our timer is all set to go, start it | |
dispatch_resume(timer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment