Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Touch Adapter for M5 Core2s FT6366
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "M5TouchAdapter.h" | ||
|
||
// Emulates the native (resistive) TFT_eSPI touch interface using M5.Touch | ||
#define TOUCH M5Touch::instance | ||
|
||
uint8_t M5TouchAdapter::getTouchRaw(uint16_t *x, uint16_t *y) { | ||
return getTouch(x, y); | ||
} | ||
|
||
uint16_t M5TouchAdapter::getTouchRawZ(void) { | ||
return (TOUCH->ispressed()) ? 1000 : 0; | ||
} | ||
|
||
void M5TouchAdapter::convertRawXY(uint16_t *x, uint16_t *y) { return; } | ||
|
||
uint8_t M5TouchAdapter::getTouch(uint16_t *x, uint16_t *y, | ||
uint16_t threshold /* = 600 */) { | ||
TOUCH->read(); | ||
if (TOUCH->points) { | ||
*x = TOUCH->point[0].x; | ||
*y = TOUCH->point[0].y; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
void M5TouchAdapter::calibrateTouch(uint16_t *data, uint32_t color_fg, | ||
uint32_t color_bg, uint8_t size) { | ||
return; | ||
} | ||
|
||
void M5TouchAdapter::setTouch(uint16_t *data) { return; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include "M5Touch.h" | ||
|
||
class M5TouchAdapter { | ||
public: | ||
// Emulates the TFT_eSPI touch interface using M5.Touch | ||
uint8_t getTouchRaw(uint16_t *x, uint16_t *y); | ||
uint16_t getTouchRawZ(void); | ||
void convertRawXY(uint16_t *x, uint16_t *y); | ||
uint8_t getTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600); | ||
void calibrateTouch(uint16_t *data, uint32_t color_fg, uint32_t color_bg, | ||
uint8_t size); | ||
void setTouch(uint16_t *data); | ||
}; | ||
// #endif /* _M5DISPLAY_H_ */ |