-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlgfxtest.cpp
36 lines (35 loc) · 1.05 KB
/
lgfxtest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <linux/input.h>
#include <fcntl.h>
#include <unistd.h>
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>
int main(int argc, char *argv[])
{
LGFX lcd{240, 320};
lcd.init();
lcd.setColorDepth(16);
lcd.fillScreen(0);
lcd.setTextColor(TFT_WHITE, TFT_BLACK);
int fd{open("/dev/input/by-path/platform-fe205000.i2c-event", O_RDONLY)};
if (fd >= 0) {
int x{0}, y{0};
while (true) {
input_event e;
auto n{read(fd, &e, sizeof e)};
if (n == sizeof e) {
if (e.type == EV_KEY && e.code == KEY_LEFTMETA && e.value == 1) {
lcd.fillScreen(0);
} else if (e.type == EV_ABS && e.code == ABS_MT_POSITION_X) {
x = e.value;
} else if (e.type == EV_ABS && e.code == ABS_MT_POSITION_Y) {
y = e.value;
lcd.setColor(0xff0000U);
lcd.fillCircle (x, y, 10);
}
}
}
close(fd);
}
return 0;
}