Files
ESPGadget/00_prologue.ino
Florian Overkamp 1d6201eb25 Adding to repo
2019-03-30 08:39:24 +01:00

66 lines
1.3 KiB
C++

/*
* Libraries and global scope code
*/
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <time.h>
BearSSL::WiFiClientSecure net;
time_t now;
unsigned long lastMillis = 0;
String devname; // Device identifier for MQTT
struct Settings {
String name = "";
String ip = "";
uint8_t mode = 0, // Current animation effect
offset = 0,
brightness = 20; // Default brightness (range 0-255)
long color = 0x00A4B3; // Starting color
} settings;
struct State {
String text = "";
uint8_t mode = 0;
long color = 0x00A4B3; // Starting color
} state;
/*
* Debugging might be nice sometimes
*/
#define USE_SERIAL //uncomment for Serial debugging statements
bool serialinitialised = false;
char printbuffer[100];
void PRINT_SERIAL(const String& line) {
#ifdef USE_SERIAL
if(!serialinitialised){
Serial.begin(115200);
serialinitialised = true;
}
Serial.print(settings.ip + " " + settings.name + " ");
Serial.print(line);
#endif
}
void APPEND_SERIAL(const String& line) {
#ifdef USE_SERIAL
Serial.print(line);
#endif
}
void PRINTLN_SERIAL(const String& line) {
#ifdef USE_SERIAL
PRINT_SERIAL(line);
Serial.println();
#endif
}
void APPENDLN_SERIAL(const String& line) {
#ifdef USE_SERIAL
Serial.println(line);
#endif
}
#define NOP __asm__ __volatile__ ("nop\n")