Skip to content

Commit

Permalink
update demo example GT911 touch
Browse files Browse the repository at this point in the history
  • Loading branch information
puboy7 committed Apr 2, 2024
1 parent 0bed10e commit e51bfc9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
55 changes: 46 additions & 9 deletions examples/demo/demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
#include <SD.h>
#include "logo.h"
#include "pins.h"
#include <Wire.h>
#include <touch.h>
#include <TouchDrvGT911.hpp>

TouchDrvGT911 touch;


#if defined(T5_47_PLUS)
#include "pcf8563.h"
#include <Wire.h>
#endif


#if defined(T5_47_PLUS)
PCF8563_Class rtc;
#endif
Expand Down Expand Up @@ -74,13 +79,46 @@ void setup()
vref = adc_chars.vref;
}

char *string1 = "➸ 16 color grayscale 😀 \n";
const char *string2 = "➸ Use with 4.7\" EPDs 😍 \n";
const char *string3 = "➸ High-quality font rendering ✎🙋";
const char *string4 = "➸ ~630ms for full frame draw 🚀\n";
#if defined(T5_47_PLUS)
Wire.begin(TOUCH_SDA, TOUCH_SCL);
uint8_t touchAddress = 0;
Wire.beginTransmission(0x14);
if (Wire.endTransmission() == 0) {
touchAddress = 0x14;
}
Wire.beginTransmission(0x5D);
if (Wire.endTransmission() == 0) {
touchAddress = 0x5D;
}
if (touchAddress == 0) {
Serial.println("Failed to find GT911 - check your wiring!");
delay(1000);
string1 = "➸ Touch status: False \n";
}

touch.setPins(-1, TOUCH_INT);
if (!touch.begin(Wire,touchAddress,TOUCH_SDA, TOUCH_SCL)) {
Serial.println("Failed to find GT911 - check your wiring!");
delay(1000);
string1 = "➸ Touch status: False \n";
}
else
{
string1 = "➸ Touch status: True \n";
}
touch.setMaxCoordinates(EPD_WIDTH, EPD_HEIGHT);
touch.setSwapXY(true);
touch.setMirrorXY(false, true);
rtc.begin();
rtc.setDateTime(2022, 6, 30, 0, 0, 0);
#endif


epd_init();
epd_init(1);

Rect_t area = {
.x = 230,
Expand All @@ -99,10 +137,6 @@ void setup()
int cursor_x = 200;
int cursor_y = 250;

const char *string1 = "➸ 16 color grayscale 😀 \n";
const char *string2 = "➸ Use with 4.7\" EPDs 😍 \n";
const char *string3 = "➸ High-quality font rendering ✎🙋";
const char *string4 = "➸ ~630ms for full frame draw 🚀\n";

epd_poweron();

Expand All @@ -127,7 +161,7 @@ void setup()

epd_poweroff();
}

int16_t xx, yy;
void loop()
{
// When reading the battery voltage, POWER_EN must be turned on
Expand Down Expand Up @@ -156,7 +190,10 @@ void loop()
int cursor_y = 500;
epd_clear_area(area);
writeln((GFXfont *)&FiraSans, (char *)voltage.c_str(), &cursor_x, &cursor_y, NULL);

uint8_t touched = touch.getPoint(&xx, &yy);
if (touched) {
Serial.printf("X:%d Y:%d\n", xx, yy);
}

/**
* There are two ways to close
Expand All @@ -171,5 +208,5 @@ void loop()
*/
epd_poweroff_all();

delay(5000);
delay(500);
}
1 change: 1 addition & 0 deletions examples/demo/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#define TOUCH_SCL (17)
#define TOUCH_SDA (18)
#define TOUCH_RST (46)
#define TOUCH_INT (47)

#define GPIO_MISO (45)
Expand Down
3 changes: 3 additions & 0 deletions examples/demo/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
src_dir = .
lib_dir = ../..
boards_dir = ../../platformio/boards
default_envs = T5_4_7Inc_Plus


[env]
platform = [email protected]
Expand All @@ -31,3 +33,4 @@ board = lilygo-t5-47-plus

build_flags = -D CORE_DEBUG_LEVEL=3
lib_deps = https://github.com/lewisxhe/PCF8563_Library.git
lewisxhe/[email protected]

0 comments on commit e51bfc9

Please sign in to comment.