|
TeensyNanoExoCode
|
Class to blink and LED in a specific pattern to syncronize the data from the microcontroler with optical tracking systems There will be _numStartStopBlinks high pulses at the begining and end of the sequence with each pulse lasting _sync_start_stop_half_period_us. In in between the start and stop it will blink with each high or low lasting _sync_half_period_us. The sequence is started and stopped using trigger(). More...
Go to the source code of this file.
Class to blink and LED in a specific pattern to syncronize the data from the microcontroler with optical tracking systems There will be _numStartStopBlinks high pulses at the begining and end of the sequence with each pulse lasting _sync_start_stop_half_period_us. In in between the start and stop it will blink with each high or low lasting _sync_half_period_us. The sequence is started and stopped using trigger().
This setup requires an external timer since the arduino ISR timers can't take in arguments like the class's self. The to change the LED's actual on/off state, updateLed must be called. A sample wrapper for the ISR for the timer:
void grossLedInteruptWrapper(void) { syncLed.syncLedHandler(); // calculate the LED state based on the timer, but don't change the actual LED state. syncTimer.begin(grossLedInteruptWrapper, syncLed.currentSyncPeriod); // update the timer period ideally we would only do this if it changed, might add a flag to syncLed if needed }
Then in the main loop or when you are recording data: int ledState = syncLed.updateLed(); // actually change the led state, and record the state in the data
The static state (not flashing) can be set to either HIGH or LOW
If you need the pin low to be LED on (like with a P channel mosfet) you can change that in the defines below.