diff --git a/platformio.ini b/platformio.ini index cc39e38c3259486c869e221f5e16864fdc6a758b..478c23fb2a444a536e08088e10d96749bc6cda92 100644 --- a/platformio.ini +++ b/platformio.ini @@ -25,3 +25,4 @@ lib_deps = AXP202X_Library@1.1.2 TinyGPSPlus@1.0.2 MCCI Arduino LoRaWAN Library@0.8.0 + OneButton@0.0.0-alpha+sha.eb583d713a diff --git a/src/config.h.sample b/src/config.h.sample index c6f45b771592ecf29c680b1215d648a42dc14204..a260387e173a42d5e4a73b83751f667e593a2951 100644 --- a/src/config.h.sample +++ b/src/config.h.sample @@ -6,3 +6,5 @@ #define TTN_DEVEUI { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 }; // LSB / little-endian / "byte order reversed" #define TTN_APPEUI { 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0xD5, 0xB3, 0x70 }; // LSB / little-endian / "byte order reversed" #define TTN_APPKEY { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; // MSB / big-endian / "byte order same as string" + +#define BUTTON_PIN 38 diff --git a/src/main.cpp b/src/main.cpp index b7168f382848b69ce889d303dfc50801db1594f4..3f531ce11fd5f351290bec442f956c27e313d290 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,7 @@ #include <hal/hal.h> #include <SPI.h> #include <TinyGPS++.h> +#include <OneButton.h> class cLoRaWAN : public Arduino_LoRaWAN_ttn { @@ -63,6 +64,7 @@ AXP20X_Class axp; HardwareSerial GPS(1); TinyGPSPlus gps; cLoRaWAN LoRaWAN{}; +OneButton btn = OneButton(BUTTON_PIN, true, true); static uint8_t mydata[] = "Hello, world!"; static osjob_t sendjob; @@ -101,7 +103,7 @@ void printStatus() { gps.encode(GPS.read()); } - Serial.println("**********************"); + Serial.println("##############################"); Serial.println("--- Power ---"); Serial.printf("DCDC1/OLED Status : %s\n", axp.isDCDC1Enable() ? "enabled" : "disabled"); Serial.printf("DCDC1/OLED Voltage : %g V\n", (float)axp.getDCDC1Voltage() / 1000); @@ -143,10 +145,14 @@ void printStatus() Serial.println(gps.time.second()); Serial.print("Speed : "); Serial.println(gps.speed.kmph()); - Serial.println("**********************"); + Serial.println("##############################"); axp.setChgLEDMode(AXP20X_LED_OFF); } +static void handleClick() { + printStatus(); +} + void do_send(osjob_t *j) { // Check if there is not a current TX/RX job running @@ -278,6 +284,7 @@ void setup() setupPower(); setupGps(); LoRaWAN.begin(pinMap); + btn.attachClick(handleClick); printStatus(); do_send(&sendjob); } @@ -285,6 +292,5 @@ void setup() void loop() { LoRaWAN.loop(); - //printStatus(); - //delay(1000); + btn.tick(); }