From 577ec25e300df789a91995f4493d852a606b7e34 Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Fri, 14 Jun 2019 17:12:26 +0800 Subject: [PATCH] fix btn error --- T22_TBeam.ino | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/T22_TBeam.ino b/T22_TBeam.ino index 7f410a2..a0cf914 100644 --- a/T22_TBeam.ino +++ b/T22_TBeam.ino @@ -3,6 +3,7 @@ #include #include "axp20x.h" #include +#include #define AXP192_SLAVE_ADDRESS 0x34 SSD1306_OBJECT(); @@ -27,6 +28,7 @@ Button2 *pBtns = nullptr; uint8_t g_btns[] = BUTTONS_MAP; #define ARRARY_SIZE(a) (sizeof(a) / sizeof(a[0])) +Ticker btnTick; /************************************ * BUTTON @@ -197,7 +199,7 @@ void setup() } else { Serial.println("AXP192 Begin FAIL"); } - + // axp.setChgLEDMode(LED_BLINK_4HZ); Serial.printf("DCDC1: %s\n", axp.isDCDC1Enable() ? "ENABLE" : "DISABLE"); @@ -251,6 +253,8 @@ void setup() #ifdef ENABLE_LOAR lora_init(); #endif + + btnTick.attach_ms(20, button_loop); } @@ -364,17 +368,18 @@ void loop() recv += (char)LoRa.read(); } if (!ssd1306_found) { - Serial.printf("Lora Received:%s - rssi:%d\n", recv, LoRa.packetRssi()); + Serial.printf("Lora Received:%s - rssi:%d\n", recv.c_str(), LoRa.packetRssi()); } } else { - if (!ssd1306_found) { - Serial.println("Wait for received message"); - delay(500); - } + // if (!ssd1306_found) { + // Serial.println("Wait for received message"); + // delay(500); + // } } snprintf(buff[1], sizeof(buff[1]), "rssi:%d", LoRa.packetRssi()); break; } + /* if (ssd1306_found) { if (ui.update()) { button_loop(); @@ -382,6 +387,11 @@ void loop() } else { button_loop(); } + */ + if (ssd1306_found) { + if (ui.update()) { + } + } } void scanI2Cdevice(void)