#include "esp_mac.h" // required - exposes esp_mac_type_t values
#include "common.h"
//=======================================================================
void setup() {
Serial.begin(115200);
delay(250);
DEBUG_F("\r\n------ Booting ESP ------------------------------------\r\n");
DEBUG_F("Arduino IDE : %d.%d.%d \r\n", ARDUINO / 10000, ARDUINO % 10000 / 100,
ARDUINO % 100 / 10 ? ARDUINO % 100 : ARDUINO % 10);
DEBUG_F("Compiler ver. : %s \r\n", __VERSION__); // gcc version
DEBUG_F("On Board : %s \r\n", ARDUINO_BOARD);
DEBUG_F("Sketch name : %s \r\n", SKETCH_NAME.c_str());
DEBUG_F("Sketch ver. : %s \r\n", VERSION);
DEBUG_F("Build Date : %s \r\n", (__DATE__ ", " __TIME__)); // compilation date, time
DEBUG_F("Author : Kernel Panic\n\n");
PRINT_DASHED_LINES;
pinMode(My_BUTTON, INPUT_PULLUP);
pinMode(MY_LED, OUTPUT);
rgbLedWrite(MY_LED, 1, 1, 200);
printESPinfo();
// #if defined(DebugLevel == 0)
// DEBUG_F("\t #if defined DebugLevel = %d\n", DebugLevel);
// #endif
DEBUG_F("✅🆗 All systems initialized successfully!\n");
DEBUG_F(" - Time waiting for Boot : %.2f sec. -\r\n", (millis() / 1000.0));
PRINT_DASHED_LINES;
}
//=======================================================================
void loop() {
CheckButton();
}
/* === CheckButton ======================================================= */
void CheckButton() {
static bool button_state = false; // false = released | true = pressed
static uint32_t button_time_stamp = 0; // debouncing control
const uint32_t debouceTime = 200; // button debouncing time (ms)
// Check if the button has been pressed
if (digitalRead(My_BUTTON) == LOW && !button_state) {
// deals with button debouncing
button_time_stamp = millis(); // record the time while the button is pressed.
button_state = true; // pressed.
}
if (button_state && millis() - button_time_stamp > debouceTime) {
button_state = false; // released
DebugLevel = (DebugLevel + 1) % 6;
DEBUG_F("\tDebugLevel = %d\n", DebugLevel);
}
}
/*********************************
end of this page
**********************************/