TinyWifiDongle 0.1.0
Header-only USB WiFi dongle for Arduino
Loading...
Searching...
No Matches
Board.h
Go to the documentation of this file.
1#pragma once
2#include <Arduino.h>
3
4namespace twd {
5
12class Board {
13 public:
15 static bool buttonPressedWithin(uint32_t ms) {
16#if defined(ESP32)
17 pinMode(0, INPUT_PULLUP); // BOOT button
18#endif
19 uint32_t start = millis();
20 while (millis() - start < ms) {
21#if defined(ESP32)
22 if (digitalRead(0) == LOW) return true;
23#else
24 if (BOOTSEL) return true;
25#endif
26 delay(10);
27 }
28 return false;
29 }
30
32 static void restart() {
33#if defined(ESP32)
34 ESP.restart();
35#else
36 rp2040.reboot();
37#endif
38 }
39};
40
41} // namespace twd
The few things that differ between the supported boards.
Definition Board.h:12
static bool buttonPressedWithin(uint32_t ms)
True if the BOOT button (ESP32) or the BOOTSEL button (Raspberry Pi Pico) is pressed at any time duri...
Definition Board.h:15
static void restart()
Restarts the board.
Definition Board.h:32