mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-13 13:01:55 +03:00
Migrate from astyle to clang-format (#8464)
This commit is contained in:
committed by
Max Prokhorov
parent
46190b61f1
commit
19b7a29720
@ -58,7 +58,7 @@ SDFSConfig fileSystemConfig = SDFSConfig();
|
||||
|
||||
#ifndef STASSID
|
||||
#define STASSID "your-ssid"
|
||||
#define STAPSK "your-password"
|
||||
#define STAPSK "your-password"
|
||||
#endif
|
||||
|
||||
// Indicate which digital I/Os should be displayed on the chart.
|
||||
@ -110,9 +110,7 @@ void replyServerError(String msg) {
|
||||
bool handleFileRead(String path) {
|
||||
DBG_OUTPUT_PORT.println(String("handleFileRead: ") + path);
|
||||
|
||||
if (path.endsWith("/")) {
|
||||
path += "index.htm";
|
||||
}
|
||||
if (path.endsWith("/")) { path += "index.htm"; }
|
||||
|
||||
String contentType = mime::getContentType(path);
|
||||
|
||||
@ -122,9 +120,7 @@ bool handleFileRead(String path) {
|
||||
}
|
||||
if (fileSystem->exists(path)) {
|
||||
File file = fileSystem->open(path, "r");
|
||||
if (server.streamFile(file, contentType) != file.size()) {
|
||||
DBG_OUTPUT_PORT.println("Sent less data than expected!");
|
||||
}
|
||||
if (server.streamFile(file, contentType) != file.size()) { DBG_OUTPUT_PORT.println("Sent less data than expected!"); }
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
@ -139,11 +135,9 @@ bool handleFileRead(String path) {
|
||||
and if it fails, return a 404 page with debug information
|
||||
*/
|
||||
void handleNotFound() {
|
||||
String uri = ESP8266WebServer::urlDecode(server.uri()); // required to read paths with blanks
|
||||
String uri = ESP8266WebServer::urlDecode(server.uri()); // required to read paths with blanks
|
||||
|
||||
if (handleFileRead(uri)) {
|
||||
return;
|
||||
}
|
||||
if (handleFileRead(uri)) { return; }
|
||||
|
||||
// Dump debug data
|
||||
String message;
|
||||
@ -218,7 +212,7 @@ void setup(void) {
|
||||
////////////////////////////////
|
||||
// WEB SERVER INIT
|
||||
|
||||
//get heap status, analog input value and all GPIO statuses in one json call
|
||||
// get heap status, analog input value and all GPIO statuses in one json call
|
||||
server.on("/espData", HTTP_GET, []() {
|
||||
String json;
|
||||
json.reserve(88);
|
||||
@ -249,21 +243,18 @@ void setup(void) {
|
||||
DBG_OUTPUT_PORT.println(" 0 (OFF): outputs are off and hidden from chart");
|
||||
DBG_OUTPUT_PORT.println(" 1 (AUTO): outputs are rotated automatically every second");
|
||||
DBG_OUTPUT_PORT.println(" 2 (MANUAL): outputs can be toggled from the web page");
|
||||
|
||||
}
|
||||
|
||||
// Return default GPIO mask, that is all I/Os except SD card ones
|
||||
unsigned int defaultMask() {
|
||||
unsigned int mask = 0b11111111111111111;
|
||||
for (auto pin = 0; pin <= 16; pin++) {
|
||||
if (isFlashInterfacePin(pin)) {
|
||||
mask &= ~(1 << pin);
|
||||
}
|
||||
if (isFlashInterfacePin(pin)) { mask &= ~(1 << pin); }
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
int rgbMode = 1; // 0=off - 1=auto - 2=manual
|
||||
int rgbMode = 1; // 0=off - 1=auto - 2=manual
|
||||
int rgbValue = 0;
|
||||
esp8266::polledTimeout::periodicMs timeToChange(1000);
|
||||
bool modeChangeRequested = false;
|
||||
@ -278,28 +269,24 @@ void loop(void) {
|
||||
}
|
||||
|
||||
// see if one second has passed since last change, otherwise stop here
|
||||
if (!timeToChange) {
|
||||
return;
|
||||
}
|
||||
if (!timeToChange) { return; }
|
||||
|
||||
// see if a mode change was requested
|
||||
if (modeChangeRequested) {
|
||||
// increment mode (reset after 2)
|
||||
rgbMode++;
|
||||
if (rgbMode > 2) {
|
||||
rgbMode = 0;
|
||||
}
|
||||
if (rgbMode > 2) { rgbMode = 0; }
|
||||
|
||||
modeChangeRequested = false;
|
||||
}
|
||||
|
||||
// act according to mode
|
||||
switch (rgbMode) {
|
||||
case 0: // off
|
||||
case 0: // off
|
||||
gpioMask = defaultMask();
|
||||
gpioMask &= ~(1 << 12); // Hide GPIO 12
|
||||
gpioMask &= ~(1 << 13); // Hide GPIO 13
|
||||
gpioMask &= ~(1 << 15); // Hide GPIO 15
|
||||
gpioMask &= ~(1 << 12); // Hide GPIO 12
|
||||
gpioMask &= ~(1 << 13); // Hide GPIO 13
|
||||
gpioMask &= ~(1 << 15); // Hide GPIO 15
|
||||
|
||||
// reset outputs
|
||||
digitalWrite(12, 0);
|
||||
@ -307,14 +294,12 @@ void loop(void) {
|
||||
digitalWrite(15, 0);
|
||||
break;
|
||||
|
||||
case 1: // auto
|
||||
case 1: // auto
|
||||
gpioMask = defaultMask();
|
||||
|
||||
// increment value (reset after 7)
|
||||
rgbValue++;
|
||||
if (rgbValue > 7) {
|
||||
rgbValue = 0;
|
||||
}
|
||||
if (rgbValue > 7) { rgbValue = 0; }
|
||||
|
||||
// output new values
|
||||
digitalWrite(12, rgbValue & 0b001);
|
||||
@ -322,11 +307,10 @@ void loop(void) {
|
||||
digitalWrite(15, rgbValue & 0b100);
|
||||
break;
|
||||
|
||||
case 2: // manual
|
||||
case 2: // manual
|
||||
gpioMask = defaultMask();
|
||||
|
||||
// keep outputs unchanged
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user