Skip to content

Commit f4d35c3

Browse files
committed
Now using isFlashInterfacePin() no define default GPIO mask.
1 parent 93f00c2 commit f4d35c3

File tree

1 file changed

+26
-10
lines changed
  • libraries/ESP8266WebServer/examples/Graph

1 file changed

+26
-10
lines changed

libraries/ESP8266WebServer/examples/Graph/Graph.ino

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,8 @@ SDFSConfig fileSystemConfig = SDFSConfig();
6363

6464
// Indicate which digital I/Os should be displayed on the chart.
6565
// From GPIO16 to GPIO0, a '1' means the corresponding GPIO will be shown
66-
// Note: SD GPIOs are hidden by default:
67-
#define DEFAULT_GPIO_MASK 0b11111000000111111
68-
69-
unsigned int gpioMask = DEFAULT_GPIO_MASK;
66+
// e.g. 0b11111000000111111
67+
unsigned int gpioMask;
7068

7169
const char* ssid = STASSID;
7270
const char* password = STAPSK;
@@ -254,6 +252,17 @@ void setup(void) {
254252

255253
}
256254

255+
// Return default GPIO mask, that is all I/Os except SD card ones
256+
unsigned int defaultMask() {
257+
unsigned int mask = 0b11111111111111111;
258+
for (auto pin=0; pin <= 16; pin++) {
259+
if (isFlashInterfacePin(pin)) {
260+
mask &= ~(1<<pin);
261+
}
262+
}
263+
return mask;
264+
}
265+
257266
int rgbMode = 1; // 0=off - 1=auto - 2=manual
258267
int rgbValue = 0;
259268
long lastChangeTime = 0;
@@ -285,34 +294,41 @@ void loop(void) {
285294
// act according to mode
286295
switch (rgbMode) {
287296
case 0: // off
288-
gpioMask = 0b10100000000111111; // GPIOs 12-13-15 are hidden
289-
// output 0
297+
gpioMask = defaultMask();
298+
gpioMask &= ~(1<<12); // Hide GPIO 12
299+
gpioMask &= ~(1<<13); // Hide GPIO 13
300+
gpioMask &= ~(1<<15); // Hide GPIO 15
301+
302+
// reset outputs
290303
digitalWrite(12, 0);
291304
digitalWrite(13, 0);
292305
digitalWrite(15, 0);
293306
break;
294307

295308
case 1: // auto
296-
gpioMask = DEFAULT_GPIO_MASK;
309+
gpioMask = defaultMask();
310+
297311
// increment value (reset after 7)
298312
rgbValue++;
299313
if (rgbValue > 7) {
300314
rgbValue = 0;
301315
}
302316

303-
// output values
317+
// output new values
304318
digitalWrite(12, rgbValue & 0b001);
305319
digitalWrite(13, rgbValue & 0b010);
306320
digitalWrite(15, rgbValue & 0b100);
307321
break;
308322

309323
case 2: // manual
310-
gpioMask = DEFAULT_GPIO_MASK;
311-
// don't change values
324+
gpioMask = defaultMask();
325+
326+
// keep outputs unchanged
312327
break;
313328
}
314329

315330
// update last change time
316331
lastChangeTime = now;
317332
}
318333
}
334+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy