summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-08-24 19:17:37 +1000
committerjacqueline <me@jacqueline.id.au>2023-08-24 19:17:37 +1000
commit58854bc55dc5aae4b144384d4916def930dd0262 (patch)
tree570561d434d7051d52dc3f0619e0a0e2ed77f747 /src/drivers
parentee949829d98c3b8df685319559a5798aad74bf13 (diff)
downloadtangara-fw-58854bc55dc5aae4b144384d4916def930dd0262.tar.gz
Improve centre button responsiveness
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/include/touchwheel.hpp3
-rw-r--r--src/drivers/touchwheel.cpp14
2 files changed, 14 insertions, 3 deletions
diff --git a/src/drivers/include/touchwheel.hpp b/src/drivers/include/touchwheel.hpp
index 38e8a9f1..9d002156 100644
--- a/src/drivers/include/touchwheel.hpp
+++ b/src/drivers/include/touchwheel.hpp
@@ -49,9 +49,12 @@ class TouchWheel {
CALIBRATE = 6,
RESET = 7,
LOW_POWER = 8,
+ RECALIBRATION_DELAY = 12,
SLIDER_OPTIONS = 14,
CHARGE_TIME = 15,
+ DETECT_THRESHOLD_BASE = 16,
KEY_CONTROL_BASE = 28,
+ PULSE_SCALE_BASE = 40,
};
void WriteRegister(uint8_t reg, uint8_t val);
diff --git a/src/drivers/touchwheel.cpp b/src/drivers/touchwheel.cpp
index 6b925055..14cfa689 100644
--- a/src/drivers/touchwheel.cpp
+++ b/src/drivers/touchwheel.cpp
@@ -46,15 +46,20 @@ TouchWheel::TouchWheel() {
WriteRegister(Register::KEY_CONTROL_BASE + 0, 0b100);
WriteRegister(Register::KEY_CONTROL_BASE + 1, 0b100);
WriteRegister(Register::KEY_CONTROL_BASE + 2, 0b100);
- // Centre button. Set to channel 1.
- WriteRegister(Register::KEY_CONTROL_BASE + 3, 0b100);
+ // Centre button. AKS disabled.
+ WriteRegister(Register::KEY_CONTROL_BASE + 3, 0b000);
// Touch guard. Set as a guard, in channel 1.
WriteRegister(Register::KEY_CONTROL_BASE + 4, 0b10100);
+ // It's normal to press the wheel for a long time. Disable auto recalibration
+ // so that the user's finger isn't calibrated away.
+ WriteRegister(Register::RECALIBRATION_DELAY, 0);
+
// Unused extra keys. All disabled.
for (int i = 5; i < 12; i++) {
WriteRegister(Register::KEY_CONTROL_BASE + i, 1);
}
+
}
TouchWheel::~TouchWheel() {}
@@ -67,7 +72,10 @@ void TouchWheel::WriteRegister(uint8_t reg, uint8_t val) {
.write_addr(kTouchWheelAddress, I2C_MASTER_WRITE)
.write_ack(reg, val)
.stop();
- transaction.Execute();
+ esp_err_t res = transaction.Execute();
+ if (res != ESP_OK) {
+ ESP_LOGW(kTag, "write failed: %s", esp_err_to_name(res));
+ }
}
uint8_t TouchWheel::ReadRegister(uint8_t reg) {