Interface
The core exposes a few functions which can be used to interact
with it. This is achieved with extern "C" methods so these functions are
callable from a C application as well. These are the functions currently:
void core_init(initObjectString, logFunction, delayFunction, randomFunction)This function needs to be called before anything else. This initializes the whole core library
- initObjectString: This is a string in JSON format. Currently only holds the LED strip length data
- logFunction: This is a pointer to a function which receives a string. This
function is called if something needs to be logged. For example this could
be a function that makes an
std::coutin C++ - delayFunction: This is a pointer to a function which is able to delay the execution of something. Since threads are not supported on all platforms(for example embedded systems) the built-in C++11 threads cannot be used in core. Instead it expects this function from the application
- randomFunction: This is a pointer to a function that returns a random number. It's also required because on different platforms the random number generation could be different
void core_addController(controllerObjectString, elapsedTime)This function needs to be called for adding a new effect to the controller. When a new effect is added the segments that are generated by the old effect are deleted except if they have properties which makes them not visible after some time. For example moving out of the strip or dimming away.
- controllerObjectString: The JSON descriptor of the new effect
- elapsedTime: The elapsed time at the moment of adding the controller and the starting of the application. This could be important because of initial actions that need to be executed instantly
void core_tick(elapsedTime, fillFunction, postFillFunction)This function needs to be called to start the Tick cycle. It should be called in the main loop of the application with a high refresh rate.
- elapsedTime: The elapsed time between calling the function and starting the application. This is needed to correctly update the segment attributes based on the time based properties
- fillFunction: This function is called for every LED of every strip to fill a buffer with colors that represent the segments
- postFillFunction: It's called once after the buffer filling process if finished for every LED
void core_startBeatSync(elapsedTime, trackObjectString)This function needs to be called to start a music synchronization process. This function can be called again to stop a previous synchronization and start a new one.
- elapsedTime: The elapsed time between calling the function and starting the application
- trackObjectString: It's a string in JSON format which contains the audio analysis result fetched from Spotify
void core_error(elapsedTime)This function can be called if an error occurred and needs a visualization with the help of the LEDs. This function makes all the LEDs turn red, indicating there was an error.
- elapsedTime: The elapsed time between calling the function and starting the application