Created
April 6, 2014 23:01
-
-
Save vitiral/10012327 to your computer and use it in GitHub Desktop.
ui_led_example5--p3.cpp
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
// This function can be called form the command line as "reinit" | |
// It resets all the settings. | |
uint8_t reinit(pthread *pt){ | |
thread *th; | |
// First we try to kill the threads. | |
// Note: TRY simply silences any error outputs. You still have to clear errors | |
// afterwards (if you don't clear errors, it can effect the next funciton call) | |
// Note: this also destroys all thread data. | |
TRY(set_thread_innactive(get_thread(LED1))); | |
clrerr(); | |
TRY(set_thread_innactive(get_thread(LED2))); | |
clrerr(); | |
// Note: setting threads innactive is not a good idea for threads | |
// that need to be killed gracefully. If your thread needs to do | |
// cleanup, use kill_thread and wait 1 loop cycle to re-schedule. | |
sub_time = 0; | |
// All threads have an attached protothread (pt). | |
// They have member functions. This lets us | |
// store inputs on a linked list. (slow access | |
// takes up very little memory) | |
th = get_thread(LED1); | |
th->pt.put_input(1000); | |
th = get_thread(LED2); | |
th->pt.put_input(900); | |
schedule_thread(LED1); | |
schedule_thread(LED2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment