From ee559cd72288053e263c473a7d60c279b6bc65a1 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 2 May 2023 16:01:41 +1000 Subject: [PATCH] Give the touchwheel a little more juice for debugging --- src/drivers/include/touchwheel.hpp | 1 + src/drivers/touchwheel.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/drivers/include/touchwheel.hpp b/src/drivers/include/touchwheel.hpp index 3dfa182b..fae4b237 100644 --- a/src/drivers/include/touchwheel.hpp +++ b/src/drivers/include/touchwheel.hpp @@ -40,6 +40,7 @@ class TouchWheel { RESET = 0x7, LOW_POWER = 0x8, SLIDER_OPTIONS = 0x14, + CHARGE_TIME = 0x15, }; void WriteRegister(uint8_t reg, uint8_t val); diff --git a/src/drivers/touchwheel.cpp b/src/drivers/touchwheel.cpp index 51a67187..d47b19a1 100644 --- a/src/drivers/touchwheel.cpp +++ b/src/drivers/touchwheel.cpp @@ -35,6 +35,10 @@ TouchWheel::TouchWheel() { vTaskDelay(pdMS_TO_TICKS(1)); WriteRegister(Register::SLIDER_OPTIONS, 0b11000000); WriteRegister(Register::CALIBRATE, 1); + // Confusingly-named; this sets to max-power max-response-time. + WriteRegister(Register::LOW_POWER, 1); + // TODO(jacqueline): Temp to debug touchwheel responsiveness. + WriteRegister(Register::CHARGE_TIME, 8); } TouchWheel::~TouchWheel() {} @@ -78,6 +82,10 @@ void TouchWheel::Update() { // Still calibrating. return; } + if (status & 0b01000000) { + // Probably okay, but we should keep an eye on this for development. + ESP_LOGW(kTag, "touchwheel acquisition >16ms"); + } if (status & 0b10) { // Slider detect. data_.wheel_position = ReadRegister(Register::SLIDER_POSITION); @@ -85,6 +93,10 @@ void TouchWheel::Update() { if (status & 0b1) { // Key detect. // TODO(daniel): implement me + // Ensure we read all status registers -- even if we're not using them -- to + // ensure that INT can float high again. + ReadRegister(Register::KEY_STATUS_A); + ReadRegister(Register::KEY_STATUS_B); } }