Files
ESPGadget/00_prologue.ino

58 lines
1.2 KiB
C++

/*
* Libraries and global scope code
*/
struct Settings {
String name = "";
String ip = "";
} settings;
time_t now;
/*
* Modules will plug in to this thing via function pointers
*/
// see also http://www.gammon.com.au/forum/?id=12607
//void module_message(const String& shorttopic, const String& message) { //@@@@FIXME@@@@ instead of brightness, adjust mode?
//void module_message(const String& shorttopic, const String& message) {
//
//}
/*
* 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")