Improve centre button responsiveness

custom
jacqueline 2 years ago
parent ee949829d9
commit 58854bc55d
  1. 3
      src/drivers/include/touchwheel.hpp
  2. 14
      src/drivers/touchwheel.cpp

@ -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);

@ -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) {

Loading…
Cancel
Save