JGAurora A5S & A1 touch support (#14768)

This commit is contained in:
pinchies
2019-07-31 08:08:11 +10:00
committed by Scott Lahteine
parent c1b99c43b6
commit d98b9d54f1
13 changed files with 131 additions and 115 deletions

View File

@ -63,9 +63,9 @@ void XPT2046::init(void) {
uint8_t XPT2046::read_buttons() {
int16_t tsoffsets[4] = { 0 };
static uint32_t timeout = 0;
if (PENDING(millis(), timeout)) return 0;
timeout = millis() + 250;
static uint32_t touchtimeout = 0;
if (PENDING(millis(), touchtimeout)) return 0;
touchtimeout = millis() + 80; // ideally want to set this lower for the games... 30 or 40.
if (tsoffsets[0] + tsoffsets[1] == 0) {
// Not yet set, so use defines as fallback...
@ -82,12 +82,11 @@ uint8_t XPT2046::read_buttons() {
y = uint16_t(((uint32_t(getInTouch(XPT2046_Y))) * tsoffsets[2]) >> 16) + tsoffsets[3];
if (!isTouched()) return 0; // Fingers must still be on the TS for a valid read.
if (y < 185 || y > 224) return 0;
if (WITHIN(x, 21, 98)) encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM) * ENCODER_PULSES_PER_STEP;
else if (WITHIN(x, 121, 198)) encoderDiff = ENCODER_STEPS_PER_MENU_ITEM * ENCODER_PULSES_PER_STEP;
else if (WITHIN(x, 221, 298)) return EN_C;
if (y < 175 || y > 234) return 0;
if (WITHIN(x, 11, 109)) encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM) * ENCODER_PULSES_PER_STEP;
else if (WITHIN(x, 111, 209)) encoderDiff = ENCODER_STEPS_PER_MENU_ITEM * ENCODER_PULSES_PER_STEP;
else if (WITHIN(x, 211, 309)) return EN_C;
return 0;
}
@ -96,7 +95,7 @@ bool XPT2046::isTouched() {
#if PIN_EXISTS(TOUCH_INT)
READ(TOUCH_INT_PIN) != HIGH
#else
getInTouch(XPT2046_Z1) >= XPT2046_Z1_TRESHHOLD
getInTouch(XPT2046_Z1) >= XPT2046_Z1_THRESHOLD
#endif
);
}

View File

@ -34,7 +34,9 @@ enum XPTCoordinate : uint8_t {
XPT2046_Z2 = 0x40
};
#define XPT2046_Z1_TRESHHOLD 10
#ifndef XPT2046_Z1_THRESHOLD
#define XPT2046_Z1_THRESHOLD 10
#endif
class XPT2046 {
public: