Skip to content

Commit 4d49de1

Browse files
committed
Fixing all of @vkichline's Oct 11 issues.
1 parent 7f8c539 commit 4d49de1

File tree

8 files changed

+159
-105
lines changed

8 files changed

+159
-105
lines changed

examples/Touch/events_buttons_gestures_rotation/events_buttons_gestures_rotation.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <M5Core2.h>
22

33
// Defines gestures
4-
Gesture swipeRight("swipe right", 160, RIGHT, 30, true);
5-
Gesture swipeDown("swipe down", 120, DOWN, 30, true);
6-
Gesture swipeLeft("swipe left", 160, LEFT, 30, true);
7-
Gesture swipeUp("swipe up", 120, UP, 30, true);
4+
Gesture swipeRight("swipe right", 160, DIR_RIGHT, 30, true);
5+
Gesture swipeDown("swipe down", 120, DIR_DOWN, 30, true);
6+
Gesture swipeLeft("swipe left", 160, DIR_LEFT, 30, true);
7+
Gesture swipeUp("swipe up", 120, DIR_UP, 30, true);
88

99
// Defines the buttons. Colors in format {bg, text, outline}
1010
ButtonColors on_clrs = {RED, WHITE, WHITE};

keywords.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ E_PRESSING LITERAL1
8383
E_LONGPRESSED LITERAL1
8484
E_LONGPRESSING LITERAL1
8585

86-
UP LITERAL1
87-
DOWN LITERAL1
88-
LEFT LITERAL1
89-
RIGHT LITERAL1
86+
DIR_UP LITERAL1
87+
DIR_DOWN LITERAL1
88+
DIR_LEFT LITERAL1
89+
DIR_RIGHT LITERAL1
9090

9191
# Button
9292
Button KEYWORD1
@@ -177,6 +177,7 @@ GRAY LITERAL1
177177
RED LITERAL1
178178
BLUE LITERAL1
179179
GREEN LITERAL1
180+
YELLOW LITERAL1
180181
NODRAW LITERAL1
181182

182183
# Core2 only

src/M5Touch.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,6 @@ bool M5Touch::read() {
120120
return true;
121121
}
122122

123-
Point M5Touch::stale() {
124-
Point s;
125-
uint8_t data[5];
126-
ft6336(0x02, 5, data);
127-
s.x = ((data[1] << 8) | data[2]) & 0x0fff;
128-
s.y = ((data[3] << 8) | data[4]) & 0x0fff;
129-
return s;
130-
}
131-
132123
Point M5Touch::getPressPoint() {
133124
read();
134125
return point[0];

src/M5Touch.h

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
4444
void loop() {
4545
M5.update();
46-
Event& e = M5.Events.event;
46+
Event& e = M5.Buttons.event;
4747
if (e & (E_MOVE | E_RELEASE)) circle(e & E_MOVE ? e.from : e.to, WHITE);
4848
if (e & (E_TOUCH | E_MOVE)) circle(e.to, e.finger ? BLUE : RED);
4949
}
@@ -63,15 +63,17 @@
6363
or an area on the screen. You can
6464
6565
Point(x, y)
66-
Holds a point on the screen. Has members x and y that hold the
67-
coordinates of a touch. Values -1 for x and y indicate an invalid value,
66+
67+
Holds a point on the screen. Has members x and y that hold the coordinates
68+
of a touch. Values INVALID_VALUE for x and y indicate an invalid value,
6869
and that's what a point starts out with if you declare it without
6970
parameters. The 'valid()' method tests if a point is valid. If you
7071
explicitly evaluate a Point as a boolean ("if (p) ..."), you also get
7172
whether the point is valid, so this is equivalent to writing "if
7273
(p.valid()) ...".
7374
7475
Zone(x, y, w, h)
76+
7577
Holds a rectangular area on the screen. Members x, y, w and h are for the
7678
x and y coordinate of the top-left corner and the width and height of the
7779
rectangle.
@@ -89,10 +91,8 @@
8991
9092
== Basic Touch API ==
9193
92-
The basic API provides a way to read the data from the touch sensor. While
93-
you may want to use this directly. But you may want to skip using this API
94-
as even for simple applications the more advanced ways of using the touch
95-
sensor are easier.
94+
The basic touch API provides a way to read the data from the touch sensor.
95+
9696
9797
M5.update()
9898
In the loop() part of your sketch, call "M5.update()". This will in turn
@@ -127,13 +127,13 @@
127127
128128
== Buttons, Gestures, Events ==
129129
130-
Note tha you may not want to use any of the above directly. The M5Buttons
131-
library provides Button, Gesture and Events objects that allow you to
132-
quickly create reactive visual buttons on the screen and react differently
133-
based on whether a button was clicked, tapped, or double-tapped. Have a
134-
look at the documentation for that, which is in the M5Button.h file in the
135-
src/utility directory of this repository. The example under File / Examples
136-
/ M5Core2 / Basics / touch in your Arduino environment should give you an
130+
Note that you may not want to use any of the above directly. The M5Buttons
131+
library provides button, gestures and events that allow you to quickly
132+
create reactive visual buttons on the screen and react differently based on
133+
whether a button was clicked, tapped, or double-tapped. Have a look at the
134+
documentation for that, which is in the M5Button.h file in the src/utility
135+
directory of this repository. The examples under "File / Examples
136+
/ M5Core2 / Touch" in your Arduino environment should give you an
137137
idea of what's possible.
138138
139139
@@ -216,10 +216,10 @@
216216
It may sound complicated when you read it all in this document, but it's
217217
all made to be easy to use.
218218
219-
Under File / Examples / M5Core2 / Basics / touch in your Arduino
220-
environment is an example sketch called "touch" that shows both this
221-
library and M5Button in action. Please have a look at it to understand how
222-
this all works and run the sketch to see all the events printed to the
219+
Under File / Examples / M5Core2 / Touch in your Arduino environment is an
220+
example sketch called "events_buttons_gestures_rotation" that shows both
221+
this library and M5Button in action. Please have a look at it to understand
222+
how this all works and run the sketch to see all the events printed to the
223223
serial port. It shows buttons, gestures and events and should be pretty
224224
self-explanatory.
225225
@@ -256,14 +256,13 @@ class M5Touch {
256256
bool read();
257257
bool ispressed();
258258
void dump();
259-
Point stale();
260259
Point getPressPoint();
261260
uint8_t points;
262261
bool changed, wasRead;
263262
Point point[2];
264263
uint8_t point0finger;
265264

266-
private:
265+
protected:
267266
uint8_t _interval;
268267
uint32_t _lastRead;
269268
};

src/utility/M5Button.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ int16_t Button::instanceIndex() {
9494

9595
bool Button::read(bool manualRead /* = true */) {
9696
if (manualRead) _manuallyRead = true;
97+
event = Event();
9798
if (_changed) {
9899
_changed = false;
99100
_lastChange = _time;

0 commit comments

Comments
 (0)