diff options
| author | Riku Isokoski <riksu9000@gmail.com> | 2021-09-15 09:25:41 (GMT) |
|---|---|---|
| committer | Riku Isokoski <riksu9000@gmail.com> | 2021-09-15 09:25:41 (GMT) |
| commit | 8f0771183c3872343100a2e974f37c91237da277 (patch) | |
| tree | 5ffe399d1e672b17bd5e3a3ce877527ac826c682 /src/drivers/Cst816s.cpp | |
| parent | f221f5d7443aeac964615d43098dd6ed79ca62f0 (diff) | |
Fix Error screen and optimize GetTouchInfo
Diffstat (limited to 'src/drivers/Cst816s.cpp')
| -rw-r--r-- | src/drivers/Cst816s.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp index 5feb17b..49d6ed0 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/Cst816s.cpp @@ -71,6 +71,7 @@ bool Cst816S::Init() { Cst816S::TouchInfos Cst816S::GetTouchInfo() { Cst816S::TouchInfos info; + uint8_t touchData[7]; auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData)); if (ret != TwiMaster::ErrorCodes::NoError) { @@ -79,18 +80,16 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() { } // This can only be 0 or 1 - auto nbTouchPoints = touchData[touchPointNumIndex] & 0x0f; + uint8_t nbTouchPoints = touchData[touchPointNumIndex] & 0x0f; - auto xHigh = touchData[touchXHighIndex] & 0x0f; - auto xLow = touchData[touchXLowIndex]; - uint16_t x = (xHigh << 8) | xLow; + uint8_t xHigh = touchData[touchXHighIndex] & 0x0f; + uint8_t xLow = touchData[touchXLowIndex]; + info.x = (xHigh << 8) | xLow; - auto yHigh = touchData[touchYHighIndex] & 0x0f; - auto yLow = touchData[touchYLowIndex]; - uint16_t y = (yHigh << 8) | yLow; + uint8_t yHigh = touchData[touchYHighIndex] & 0x0f; + uint8_t yLow = touchData[touchYLowIndex]; + info.y = (yHigh << 8) | yLow; - info.x = x; - info.y = y; info.touching = (nbTouchPoints > 0); info.gesture = static_cast<Gestures>(touchData[gestureIndex]); |
