#include <SPI.h> // Arduino SPI library
#include "esp_mac.h" // required - exposes esp_mac_type_t values
#include "common.h"
//=======================================================================
void setup() {
vspi = new SPIClass(VSPI);
// hspi = new SPIClass(HSPI);
//alternatively route through GPIO pins of your choice
vspi->begin(VSPI_SCLK, VSPI_MISO, VSPI_MOSI, VSPI_SS); //SCLK, MISO, MOSI, SS
//alternatively route through GPIO pins
// hspi->begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI, HSPI_SS); //SCLK, MISO, MOSI, SS
//set up slave select pins as outputs as the Arduino API
//doesn't handle automatically pulling SS low
pinMode(vspi->pinSS(), OUTPUT); //VSPI SS
// pinMode(hspi->pinSS(), OUTPUT); //HSPI SS
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();
PRINT_DASHED_LINES;
DEBUG_F("\r\t- Time waiting for Boot : %.2f sec. -\r\n", (millis() / 1000.0));
}
//=======================================================================
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)
static uint8_t brightness, MaxBrightness = 255;
// 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
brightness = (brightness + 10) % MaxBrightness;
rgbLedWrite(MY_LED, brightness, 50, 10);
DEBUG_F("\tbrightness = %d\n", brightness);
}
}
/*********************************
end of this page
**********************************/
Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1