Magic Poi Lite 0.1
IOT LED Poi
|
Public Member Functions | |
void | processTimelineData (const String &timelineData) |
Processes the timeline data received from the server. | |
int * | getColours () |
Returns the array of LED colors. | |
long * | getTimings () |
Returns the array of timings. | |
int | getMaxTimingsNum () |
Returns the maximum number of timings in the timeline. | |
String | loadTimeline () |
Loads the timeline data from the disk. | |
bool | setup () |
Sets up the playing process. | |
void | play () |
Plays the timeline data. | |
void | changeColours (int choice) |
Changes the colors of the RGB LED based on the provided choice. | |
void | useTimelineData () |
Uses the timeline data to change LED colors over time. | |
Private Attributes | |
int | maxTimingsNum = 50 |
Number of timings in the timeline. | |
String | timelineNumber = "0" |
Variable to use int tinelineFilePath. | |
String | timelineFilePath = "/timeline" + timelineNumber + ".txt" |
File path of the timeline file. | |
const char * | timeline_keys [50] |
Array of keys in the timeline JSON. | |
JsonVariant | redVal |
Red color value extracted from JSON. | |
JsonVariant | greenVal |
Green color value extracted from JSON. | |
JsonVariant | blueVal |
Blue color value extracted from JSON. | |
int | redInt = 1 |
Red color value as an integer. | |
int | greenInt = 1 |
Green color value as an integer. | |
int | blueInt = 1 |
Blue color value as an integer. | |
long | timings [50] |
Array storing timings extracted from JSON. | |
int | colours [50] |
Array storing colors extracted from JSON. | |
bool | already_got_data = false |
Flag indicating whether timeline data has been loaded. | |
long | playStartTime = 0 |
Timestamp when timeline playing started. | |
JsonObject | root |
JSON object root. | |
int | iter = 0 |
Iterator for timeline data. | |
uint8_t | signal |
Signal indicator. | |
long | previousMillis = 0 |
Timestamp of the last LED update. | |
long | currentMillis2 = 0 |
Current timestamp. | |
bool | playing = true |
Flag indicating whether playing is active. | |
int | runNum = 0 |
Run number. | |
int | currentIndex = 0 |
Current index in the timeline data arrays. | |
void Playing::changeColours | ( | int | choice | ) |
Changes the colors of the RGB LED based on the provided choice.
This method changes the colors of the RGB LED based on the provided choice.
choice | An integer representing the color choice:
|
References blueLEDPin, greenLEDPin, and redLEDPin.
Referenced by useTimelineData().
int * Playing::getColours | ( | ) |
Returns the array of LED colors.
This method returns a pointer to the array containing LED colors extracted from the timeline data.
References colours.
int Playing::getMaxTimingsNum | ( | ) |
Returns the maximum number of timings in the timeline.
This method returns the maximum number of timings available in the timeline data.
References maxTimingsNum.
long * Playing::getTimings | ( | ) |
Returns the array of timings.
This method returns a pointer to the array containing timings extracted from the timeline data.
References timings.
String Playing::loadTimeline | ( | ) |
Loads the timeline data from the disk.
This method loads the timeline data from the disk using the LittleFS (Little File System). If LittleFS initialization succeeds and the file exists, the method reads the data from the file, processes it using the processTimelineData() method, and returns the timeline data as a string. If the file doesn't exist or if there's any failure during the file system operation, an empty string is returned.
References processTimelineData(), and timelineFilePath.
Referenced by setup().
void Playing::play | ( | ) |
Plays the timeline data.
This method plays the timeline data by repeatedly calling the useTimelineData() method, which changes LED colors over time according to the timeline data.
References useTimelineData().
Referenced by loop().
void Playing::processTimelineData | ( | const String & | timelineData | ) |
Processes the timeline data received from the server.
This method processes the timeline data received from the server. It deserializes the JSON data, extracts key-value pairs, and stores the LED colors and timings for each event in the timeline.
timelineData | The timeline data received from the server. |
References already_got_data, blueInt, blueVal, colours, greenInt, greenVal, iter, led, maxTimingsNum, playStartTime, redInt, redVal, root, timeline_keys, and timings.
Referenced by loadTimeline(), and setup().
bool Playing::setup | ( | ) |
Sets up the playing process.
This method sets up the playing process by initializing necessary components, loading timeline data from the disk, and processing it.
References led, loadTimeline(), and processTimelineData().
Referenced by handleAuthenticationAndLoading().
void Playing::useTimelineData | ( | ) |
Uses the timeline data to change LED colors over time.
This method uses the timeline data to change LED colors over time. It checks if it's time to change colors based on the timings in the timeline data. If it's time, it changes the colors according to the current index in the timeline data and moves to the next index. If the end of the timeline data is reached, it loops back to the beginning.
References changeColours(), colours, currentIndex, currentMillis2, maxTimingsNum, previousMillis, and timings.
Referenced by play().
|
private |
Number of timings in the timeline.
This variable stores the maximum number of timings in the timeline. It is used to limit the size of the timings array.
Referenced by getMaxTimingsNum(), processTimelineData(), and useTimelineData().
|
private |
Array of keys in the timeline JSON.
This array stores the keys extracted from the timeline JSON data.
Referenced by processTimelineData().
|
private |
File path of the timeline file.
This variable stores the file path of the timeline data file.
Referenced by loadTimeline().
|
private |
Variable to use int tinelineFilePath.
This variable is a number which allows mulitple timelines to be stored in sequence.