Use spare TBeam GPIO for an alternate middle button - Issue#162
1.2-legacy
Kevin Hester 2020-06-23 15:42:19 -07:00 zatwierdzone przez GitHub
commit 58dbc3c702
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 26 dodań i 22 usunięć

Wyświetl plik

@ -67,7 +67,7 @@ debug_tool = jlink
lib_deps =
https://github.com/meshtastic/esp8266-oled-ssd1306.git ; ESP8266_SSD1306
SPI
; 1260 ; OneButton - not used yet
1260 ; OneButton library for non-blocking button debounce
1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib
Wire ; explicitly needed here because the AXP202 library forgets to add it
https://github.com/meshtastic/arduino-fsm.git
@ -98,6 +98,7 @@ board = ttgo-t-beam
lib_deps =
${env.lib_deps}
https://github.com/meshtastic/AXP202X_Library.git
build_flags =
${esp32_base.build_flags} -D TBEAM_V10

Wyświetl plik

@ -144,7 +144,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define I2C_SDA 21
#define I2C_SCL 22
#define BUTTON_PIN 38
#define BUTTON_PIN 38 // The middle button GPIO on the T-Beam
#define BUTTON_PIN_ALT 13 // Alternate GPIO for an external button if needed
#ifndef USE_JTAG
#define RESET_GPIO 14

Wyświetl plik

@ -38,6 +38,7 @@
#include "screen.h"
#include "sleep.h"
#include <Wire.h>
#include <OneButton.h>
// #include <driver/rtc_io.h>
#ifndef NO_ESP32
@ -125,6 +126,17 @@ static uint32_t ledBlinker()
Periodic ledPeriodic(ledBlinker);
// Prepare for button presses
#ifdef BUTTON_PIN
OneButton userButton;
#endif
#ifdef BUTTON_PIN_ALT
OneButton userButtonAlt;
#endif
void userButtonPressed() {
powerFSM.trigger(EVENT_PRESS);
}
#ifndef NO_ESP32
void initWifi()
{
@ -183,8 +195,12 @@ void setup()
// Buttons & LED
#ifdef BUTTON_PIN
pinMode(BUTTON_PIN, INPUT_PULLUP);
digitalWrite(BUTTON_PIN, 1);
userButton = OneButton(BUTTON_PIN, true, true);
userButton.attachClick(userButtonPressed);
#endif
#ifdef BUTTON_PIN_ALT
userButtonAlt = OneButton(BUTTON_PIN_ALT, true, true);
userButtonAlt.attachClick(userButtonPressed);
#endif
#ifdef LED_PIN
pinMode(LED_PIN, OUTPUT);
@ -322,24 +338,10 @@ void loop()
#endif
#ifdef BUTTON_PIN
// if user presses button for more than 3 secs, discard our network prefs and reboot (FIXME, use a debounce lib instead of
// this boilerplate)
static bool wasPressed = false;
if (!digitalRead(BUTTON_PIN)) {
if (!wasPressed) { // just started a new press
DEBUG_MSG("pressing\n");
// doLightSleep();
// esp_pm_dump_locks(stdout); // FIXME, do this someplace better
wasPressed = true;
powerFSM.trigger(EVENT_PRESS);
}
} else if (wasPressed) {
// we just did a release
wasPressed = false;
}
userButton.tick();
#endif
#ifdef BUTTON_PIN_ALT
userButtonAlt.tick();
#endif
// Show boot screen for first 3 seconds, then switch to normal operation.