Magic Poi Lite 0.1
IOT LED Poi
|
Main program file. More...
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <EEPROM.h>
#include "secrets.h"
#include "Authentication.h"
#include "Loading.h"
#include "Playing.h"
Macros | |
#define | led D4 |
Pin number for the built-in LED. | |
Functions | |
void ICACHE_RAM_ATTR | handleUpdateInterrupt () |
Interrupt service routine for handling update button press. | |
void | handleAuthenticationAndLoading () |
Handles authentication and loading of timeline data. | |
void | setup () |
Sets up the system including WiFi connection, authentication, and loading and playing timeline data. | |
void | loop () |
Main loop of the program. | |
Variables | |
Authentication | authentication |
Instance of the Authentication class. | |
Loading | loading |
Instance of the Loading class. | |
Playing | playing |
Instance of the Playing class. | |
const int | blueLEDPin = D5 |
Pin number for the blue LED. | |
const int | greenLEDPin = D6 |
Pin number for the green LED. | |
const int | redLEDPin = D7 |
Pin number for the red LED. | |
const int | btnUpdatePin = D1 |
Pin number for the update Button. | |
const int | btnStartPin = D2 |
Pin number for the start Button. | |
ESP8266WiFiMulti | WiFiMulti |
WiFi multi-client manager for ESP8266. | |
volatile bool | updateRequested = false |
Flag indicating whether an update is requested. | |
Main program file.
The main program - includes setup() and loop(). Currently set to connect to Magic Poi Lite API on startup and fetch the current timeline. Then display the timeline on RGB LEDs according to timings.
#define led D4 |
Pin number for the built-in LED.
This constant represents the pin number for the built-in LED on the D1 Mini.
Referenced by Playing::processTimelineData(), setup(), and Playing::setup().
void handleAuthenticationAndLoading | ( | ) |
Handles authentication and loading of timeline data.
This function performs the process of checking for saved authentication tokens, handling authentication, and loading timeline data. It prints messages to indicate the status of these operations.
References Authentication::authenticate(), authentication, Authentication::checkSavedToken(), Loading::load(), loading, playing, and Playing::setup().
Referenced by loop(), and setup().
void ICACHE_RAM_ATTR handleUpdateInterrupt | ( | ) |
Interrupt service routine for handling update button press.
This function sets the updateRequested flag to true when the update button is pressed.
References updateRequested.
Referenced by setup().
void loop | ( | ) |
Main loop of the program.
This function is the main loop of the program. It checks for update requests and calls handleAuthenticationAndLoading() if an update is requested. It also calls the play function to execute the playing process, which involves changing LED colors over time according to the timeline data. Additionally, it adds a delay of 5 seconds between each play iteration to control the timing of the LED color changes.
References handleAuthenticationAndLoading(), Playing::play(), playing, and updateRequested.
void setup | ( | ) |
Sets up the system including WiFi connection, authentication, and loading and playing timeline data.
This function initializes the system by establishing a WiFi connection, setting up interrupt for update button, and calling handleAuthenticationAndLoading() to handle authentication and loading processes.
References blueLEDPin, btnUpdatePin, greenLEDPin, handleAuthenticationAndLoading(), handleUpdateInterrupt(), led, redLEDPin, and WiFiMulti.
Authentication authentication |
Instance of the Authentication class.
This object is used for handling authentication operations.
Referenced by handleAuthenticationAndLoading().
const int blueLEDPin = D5 |
Pin number for the blue LED.
This constant represents the pin number for the blue LED.
Referenced by Playing::changeColours(), and setup().
const int btnStartPin = D2 |
Pin number for the start Button.
This constant represents the pin number for the start Button.
const int btnUpdatePin = D1 |
Pin number for the update Button.
This constant represents the pin number for the update Button. Used for fetching content from the web.
Referenced by setup().
const int greenLEDPin = D6 |
Pin number for the green LED.
This constant represents the pin number for the green LED.
Referenced by Playing::changeColours(), and setup().
Loading loading |
Instance of the Loading class.
This object is used for loading timeline data.
Referenced by handleAuthenticationAndLoading().
Playing playing |
Instance of the Playing class.
This object is used for playing timeline data.
Referenced by handleAuthenticationAndLoading(), and loop().
const int redLEDPin = D7 |
Pin number for the red LED.
This constant represents the pin number for the red LED.
Referenced by Playing::changeColours(), and setup().
volatile bool updateRequested = false |
Flag indicating whether an update is requested.
This flag is set to true when an update is requested via the update button interrupt.
Referenced by handleUpdateInterrupt(), and loop().
ESP8266WiFiMulti WiFiMulti |
WiFi multi-client manager for ESP8266.
This object is used for managing multiple WiFi connections on ESP8266.
Referenced by setup().