Magic Poi Lite 0.1
IOT LED Poi
Loading...
Searching...
No Matches
Playing.h
Go to the documentation of this file.
1#ifndef PLAYING_H
2#define PLAYING_H
3
4#include <Arduino.h>
5#include <ArduinoJson.h>
6
7/**
8 * @file Playing.h
9 * @brief Declaration of the Playing class.
10 */
11
13{
14public:
15 Playing(); // Constructor declaration
16 void processTimelineData(const String &timelineData);
17 int *getColours();
18 long *getTimings();
19 int getMaxTimingsNum();
20 String loadTimeline();
21 bool setup();
22 void play();
23 void changeColours(int choice);
24 void useTimelineData();
25
26private:
27 /**
28 * @brief Number of timings in the timeline.
29 *
30 * This variable stores the maximum number of timings in the timeline.
31 * It is used to limit the size of the timings array.
32 */
33 int maxTimingsNum = 50;
34
35 /**
36 * @brief Variable to use int tinelineFilePath.
37 *
38 * This variable is a number which allows mulitple timelines to be stored in sequence.
39 */
40 String timelineNumber = "0";
41
42 /**
43 * @brief File path of the timeline file.
44 *
45 * This variable stores the file path of the timeline data file.
46 */
47
48 String timelineFilePath = "/timeline" + timelineNumber + ".txt";
49
50 /**
51 * @brief Array of keys in the timeline JSON.
52 *
53 * This array stores the keys extracted from the timeline JSON data.
54 */
55 const char *timeline_keys[50]; // array for keys
56
57 /**
58 * @brief Red color value extracted from JSON.
59 */
60 JsonVariant redVal;
61
62 /**
63 * @brief Green color value extracted from JSON.
64 */
65 JsonVariant greenVal;
66
67 /**
68 * @brief Blue color value extracted from JSON.
69 */
70 JsonVariant blueVal;
71
72 /**
73 * @brief Red color value as an integer.
74 */
75 int redInt = 1;
76
77 /**
78 * @brief Green color value as an integer.
79 */
80 int greenInt = 1;
81
82 /**
83 * @brief Blue color value as an integer.
84 */
85 int blueInt = 1;
86
87 /**
88 * @brief Array storing timings extracted from JSON.
89 */
90 long timings[50];
91
92 /**
93 * @brief Array storing colors extracted from JSON.
94 */
95 int colours[50];
96
97 /**
98 * @brief Flag indicating whether timeline data has been loaded.
99 */
100 bool already_got_data = false;
101
102 /**
103 * @brief Timestamp when timeline playing started.
104 */
106
107 /**
108 * @brief JSON object root.
109 */
110 JsonObject root;
111
112 /**
113 * @brief Iterator for timeline data.
114 */
115 int iter = 0;
116
117 /**
118 * @brief Signal indicator.
119 */
120 uint8_t signal;
121
122 /**
123 * @brief Timestamp of the last LED update.
124 */
126
127 /**
128 * @brief Current timestamp.
129 */
131
132 /**
133 * @brief Flag indicating whether playing is active.
134 */
135 bool playing = true;
136
137 /**
138 * @brief Run number.
139 */
140 int runNum = 0;
141
142 /**
143 * @brief Current index in the timeline data arrays.
144 */
146};
147
148#endif
Definition Playing.h:13
JsonVariant redVal
Red color value extracted from JSON.
Definition Playing.h:60
bool playing
Flag indicating whether playing is active.
Definition Playing.h:135
long * getTimings()
Returns the array of timings.
Definition Playing.cpp:143
void play()
Plays the timeline data.
Definition Playing.cpp:402
long previousMillis
Timestamp of the last LED update.
Definition Playing.h:125
int maxTimingsNum
Number of timings in the timeline.
Definition Playing.h:33
int colours[50]
Array storing colors extracted from JSON.
Definition Playing.h:95
long currentMillis2
Current timestamp.
Definition Playing.h:130
uint8_t signal
Signal indicator.
Definition Playing.h:120
void processTimelineData(const String &timelineData)
Processes the timeline data received from the server.
Definition Playing.cpp:41
long timings[50]
Array storing timings extracted from JSON.
Definition Playing.h:90
int runNum
Run number.
Definition Playing.h:140
void useTimelineData()
Uses the timeline data to change LED colors over time.
Definition Playing.cpp:300
const char * timeline_keys[50]
Array of keys in the timeline JSON.
Definition Playing.h:55
String timelineFilePath
File path of the timeline file.
Definition Playing.h:48
bool setup()
Sets up the playing process.
Definition Playing.cpp:204
int getMaxTimingsNum()
Returns the maximum number of timings in the timeline.
Definition Playing.cpp:155
int greenInt
Green color value as an integer.
Definition Playing.h:80
JsonObject root
JSON object root.
Definition Playing.h:110
int * getColours()
Returns the array of LED colors.
Definition Playing.cpp:131
int currentIndex
Current index in the timeline data arrays.
Definition Playing.h:145
JsonVariant blueVal
Blue color value extracted from JSON.
Definition Playing.h:70
JsonVariant greenVal
Green color value extracted from JSON.
Definition Playing.h:65
bool already_got_data
Flag indicating whether timeline data has been loaded.
Definition Playing.h:100
long playStartTime
Timestamp when timeline playing started.
Definition Playing.h:105
int blueInt
Blue color value as an integer.
Definition Playing.h:85
String timelineNumber
Variable to use int tinelineFilePath.
Definition Playing.h:40
int iter
Iterator for timeline data.
Definition Playing.h:115
void changeColours(int choice)
Changes the colors of the RGB LED based on the provided choice.
Definition Playing.cpp:233
int redInt
Red color value as an integer.
Definition Playing.h:75
String loadTimeline()
Loads the timeline data from the disk.
Definition Playing.cpp:171