From 58ce7b3975e16e799b96f02999a901d668b35075 Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Fri, 13 Dec 2024 14:42:38 +0800 Subject: [PATCH] Added button test --- examples/demo/demo.ino | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/examples/demo/demo.ino b/examples/demo/demo.ino index b7cdc04..c2a41a6 100644 --- a/examples/demo/demo.ino +++ b/examples/demo/demo.ino @@ -12,7 +12,7 @@ * PSRAM:"OPI PSRAM" * Upload Mode:"UART0/Hardware CDC" * USB Mode:"Hardware CDC and JTAG" - * + * */ #ifndef BOARD_HAS_PSRAM @@ -27,7 +27,7 @@ #include #include #include "logo.h" - +#include "Button2.h" //Arduino IDE -> Library manager -> Install Button2 #include #include //Arduino IDE -> Library manager -> Install SensorLib v0.19 #include @@ -35,9 +35,14 @@ #include #include "utilities.h" - +#ifndef WIFI_SSID #define WIFI_SSID "Your WiFi SSID" +#endif + +#ifndef WIFI_PASSWORD #define WIFI_PASSWORD "Your WiFi PASSWORD" +#endif + const char *ntpServer1 = "pool.ntp.org"; const char *ntpServer2 = "time.nist.gov"; @@ -45,6 +50,8 @@ const long gmtOffset_sec = 3600; const int daylightOffset_sec = 3600; const char *time_zone = "CST-8"; // TimeZone rule for Europe/Rome including daylight adjustment rules (optional) +Button2 btn1(BUTTON_1); +Button2 btn2(0); //BOOT PIN SensorPCF8563 rtc; TouchDrvGT911 touch; @@ -82,6 +89,14 @@ void timeavailable(struct timeval *t) rtc.hwClockWrite(); } + + +void buttonPressed(Button2 &b) +{ + Serial.println("Button Pressed!"); +} + + void setup() { Serial.begin(115200); @@ -255,10 +270,14 @@ void setup() write_mode((GFXfont *)&FiraSans, "Sleep", &x, &y, framebuffer, WHITE_ON_BLACK, NULL); epd_draw_grayscale_image(epd_full_screen(), framebuffer); - + epd_poweroff(); + + btn1.setPressedHandler(buttonPressed); + btn2.setPressedHandler(buttonPressed); + } @@ -411,5 +430,8 @@ void loop() } } + btn1.loop(); + btn2.loop(); + delay(2); }