Skip to content

Instantly share code, notes, and snippets.

@vitiral
Last active January 15, 2016 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vitiral/10012338 to your computer and use it in GitHub Desktop.
Save vitiral/10012338 to your computer and use it in GitHub Desktop.
// Expose the things we want to access.
// Threads always need to be exposed if you want to schedule them
// Note: the order is important!
expose_threads(TH_T(blinky_thread), TH_T(blinky_thread)); // wrap threads in TH_T
expose_functions(UI_F(reinit)); // Wrap functions in UI_F
UI_V(v1, sub_time); // Variables have to be declared specially. Declare variable names first with UI_V
//UI_V(v2, othervar) -- if you had more variables, continue in this way
expose_variables(UI_VA(v1)); // Then wrap the variable names in UI_VA. Alot of things have to be done to take up
// zero RAM!
// The names have to be done similarily to variables
UI_STR(tn1, "led1");
UI_STR(tn2, "led2");
expose_thread_names(tn1, tn2); // no wrapping required here.
UI_STR(fn1, "reinit");
expose_function_names(fn1);
UI_STR(vn1, "sub");
expose_variable_names(vn1);
void setup() {
pinMode(LEDPIN, OUTPUT); // LED init
Serial.begin(57600);
Serial.println("\n\n######################### Start Setup");
Serial.println(freeMemory());
// This makes the names actually accessible to the threading module.
set_thread_names();
set_function_names();
set_variable_names();
// this must be called before any threading (except setting names)
setup_ui(200); // 200 == the amount of dynamic memory our threads can use.
// I recommend at least 100, more if you use alot of strings
// This has two purposes: it initilizes the values during setup, and it can be called
// by the user to reinitilize the values.
reinit(NULL); // Note: NULL is only used because the function doesn't actually use it's pthread input.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment