Skip to content

Commit

Permalink
Added button test
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Dec 13, 2024
1 parent 67a0ce4 commit 58ce7b3
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions examples/demo/demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* PSRAM:"OPI PSRAM"
* Upload Mode:"UART0/Hardware CDC"
* USB Mode:"Hardware CDC and JTAG"
*
*
*/

#ifndef BOARD_HAS_PSRAM
Expand All @@ -27,24 +27,31 @@
#include <SPI.h>
#include <SD.h>
#include "logo.h"

#include "Button2.h" //Arduino IDE -> Library manager -> Install Button2
#include <Wire.h>
#include <TouchDrvGT911.hpp> //Arduino IDE -> Library manager -> Install SensorLib v0.19
#include <SensorPCF8563.hpp>
#include <WiFi.h>
#include <esp_sntp.h>
#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";
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;
Expand Down Expand Up @@ -82,6 +89,14 @@ void timeavailable(struct timeval *t)
rtc.hwClockWrite();
}



void buttonPressed(Button2 &b)
{
Serial.println("Button Pressed!");
}


void setup()
{
Serial.begin(115200);
Expand Down Expand Up @@ -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);

}


Expand Down Expand Up @@ -411,5 +430,8 @@ void loop()
}
}

btn1.loop();
btn2.loop();

delay(2);
}

0 comments on commit 58ce7b3

Please sign in to comment.