Skip to content
Snippets Groups Projects
Commit cd81084b authored by Jan Grewe's avatar Jan Grewe
Browse files

print status on button click

parent 8fe1b256
Branches
No related tags found
No related merge requests found
......@@ -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
......@@ -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
......@@ -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();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment