aboutsummaryrefslogtreecommitdiffstats
path: root/src/drivers/Cst816s.cpp
diff options
context:
space:
mode:
authorJF002 <JF002@users.noreply.github.com>2021-04-26 21:10:11 +0200
committerGitHub <noreply@github.com>2021-04-26 21:10:11 +0200
commit4706c99db4c1e05f9dd90f152f2dea08d8f22ab2 (patch)
treecf2bea6d67e8d91a7d6222b8e0b55a0075575003 /src/drivers/Cst816s.cpp
parente56ebb8bd621cc8838e86fa032d680a6e7a35ffc (diff)
parent69898545193a82f7d72c9f47c9d9de36167b157b (diff)
Merge pull request #293 from Avamander/patch-5
Reformatted all the files according to clang-format style
Diffstat (limited to 'src/drivers/Cst816s.cpp')
-rw-r--r--src/drivers/Cst816s.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp
index e3a37b1b..fd9792b3 100644
--- a/src/drivers/Cst816s.cpp
+++ b/src/drivers/Cst816s.cpp
@@ -7,14 +7,14 @@
using namespace Pinetime::Drivers;
/* References :
- * This implementation is based on this article : https://medium.com/@ly.lee/building-a-rust-driver-for-pinetimes-touch-controller-cbc1a5d5d3e9
- * Touch panel datasheet (weird chinese translation) : https://wiki.pine64.org/images/5/51/CST816S%E6%95%B0%E6%8D%AE%E6%89%8B%E5%86%8CV1.1.en.pdf
+ * This implementation is based on this article :
+ * https://medium.com/@ly.lee/building-a-rust-driver-for-pinetimes-touch-controller-cbc1a5d5d3e9 Touch panel datasheet (weird chinese
+ * translation) : https://wiki.pine64.org/images/5/51/CST816S%E6%95%B0%E6%8D%AE%E6%89%8B%E5%86%8CV1.1.en.pdf
*
* TODO : we need a complete datasheet and protocol reference!
* */
-Cst816S::Cst816S(TwiMaster &twiMaster, uint8_t twiAddress) : twiMaster{twiMaster}, twiAddress{twiAddress} {
-
+Cst816S::Cst816S(TwiMaster& twiMaster, uint8_t twiAddress) : twiMaster {twiMaster}, twiAddress {twiAddress} {
}
void Cst816S::Init() {
@@ -32,7 +32,7 @@ void Cst816S::Init() {
vTaskDelay(5);
twiMaster.Read(twiAddress, 0xa7, &dummy, 1);
vTaskDelay(5);
-
+
/*
[2] EnConLR - Continuous operation can slide around
[1] EnConUD - Slide up and down to enable continuous operation
@@ -40,23 +40,22 @@ void Cst816S::Init() {
*/
static constexpr uint8_t motionMask = 0b00000101;
twiMaster.Write(twiAddress, 0xEC, &motionMask, 1);
-
}
-
Cst816S::TouchInfos Cst816S::GetTouchInfo() {
Cst816S::TouchInfos info;
auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData));
- if(ret != TwiMaster::ErrorCodes::NoError) return {};
+ if (ret != TwiMaster::ErrorCodes::NoError)
+ return {};
auto nbTouchPoints = touchData[2] & 0x0f;
uint8_t i = 0;
uint8_t pointId = (touchData[touchIdIndex + (touchStep * i)]) >> 4;
- if(nbTouchPoints == 0 && pointId == lastTouchId) return info;
-
+ if (nbTouchPoints == 0 && pointId == lastTouchId)
+ return info;
info.isTouch = true;