|
43 | 43 |
|
44 | 44 | void loop() { |
45 | 45 | M5.update(); |
46 | | - Event& e = M5.Events.event; |
| 46 | + Event& e = M5.Buttons.event; |
47 | 47 | if (e & (E_MOVE | E_RELEASE)) circle(e & E_MOVE ? e.from : e.to, WHITE); |
48 | 48 | if (e & (E_TOUCH | E_MOVE)) circle(e.to, e.finger ? BLUE : RED); |
49 | 49 | } |
|
63 | 63 | or an area on the screen. You can |
64 | 64 |
|
65 | 65 | 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, |
68 | 69 | and that's what a point starts out with if you declare it without |
69 | 70 | parameters. The 'valid()' method tests if a point is valid. If you |
70 | 71 | explicitly evaluate a Point as a boolean ("if (p) ..."), you also get |
71 | 72 | whether the point is valid, so this is equivalent to writing "if |
72 | 73 | (p.valid()) ...". |
73 | 74 |
|
74 | 75 | Zone(x, y, w, h) |
| 76 | +
|
75 | 77 | Holds a rectangular area on the screen. Members x, y, w and h are for the |
76 | 78 | x and y coordinate of the top-left corner and the width and height of the |
77 | 79 | rectangle. |
|
89 | 91 |
|
90 | 92 | == Basic Touch API == |
91 | 93 |
|
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 | +
|
96 | 96 |
|
97 | 97 | M5.update() |
98 | 98 | In the loop() part of your sketch, call "M5.update()". This will in turn |
|
127 | 127 |
|
128 | 128 | == Buttons, Gestures, Events == |
129 | 129 |
|
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 |
137 | 137 | idea of what's possible. |
138 | 138 |
|
139 | 139 |
|
|
216 | 216 | It may sound complicated when you read it all in this document, but it's |
217 | 217 | all made to be easy to use. |
218 | 218 |
|
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 |
223 | 223 | serial port. It shows buttons, gestures and events and should be pretty |
224 | 224 | self-explanatory. |
225 | 225 |
|
@@ -256,14 +256,13 @@ class M5Touch { |
256 | 256 | bool read(); |
257 | 257 | bool ispressed(); |
258 | 258 | void dump(); |
259 | | - Point stale(); |
260 | 259 | Point getPressPoint(); |
261 | 260 | uint8_t points; |
262 | 261 | bool changed, wasRead; |
263 | 262 | Point point[2]; |
264 | 263 | uint8_t point0finger; |
265 | 264 |
|
266 | | - private: |
| 265 | + protected: |
267 | 266 | uint8_t _interval; |
268 | 267 | uint32_t _lastRead; |
269 | 268 | }; |
|
0 commit comments