Skip to content

Commit

Permalink
fix captouch issue with incorrect send pin
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Nov 28, 2023
1 parent 6d8f9ad commit be65a94
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions utility/CPlay_CapacitiveSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ CPlay_CapacitiveSensor::CPlay_CapacitiveSensor(uint8_t sendPin, uint8_t receiveP
if ((sendPin != 255) && (sendPin >= NUM_DIGITAL_PINS)) error = -3;
if (receivePin >= NUM_DIGITAL_PINS) error = -2;
#endif
if (sendPin != -1) { // sendpin to OUTPUT if we have one
if (sendPin != 255) { // sendpin to OUTPUT if we have one
#ifdef ARDUINO_TEEONARDU_FLORA // terrible hack!
DDRD |= _BV(5);
DDRD |= _BV(5);
#else
pinMode(sendPin, OUTPUT);
pinMode(sendPin, OUTPUT);
#endif
}
}

pinMode(receivePin, INPUT); // receivePin to INPUT

Expand All @@ -63,13 +63,13 @@ CPlay_CapacitiveSensor::CPlay_CapacitiveSensor(uint8_t sendPin, uint8_t receiveP
digitalWrite(sendPin, LOW);
#endif

if (sendPin != -1) {
send_outport = portOutputRegister(digitalPinToPort(sendPin));
send_mask = digitalPinToBitMask(sendPin);
} else {
send_outport = NULL;
send_mask = 0;
}
if (sendPin != 255) {
send_outport = portOutputRegister(digitalPinToPort(sendPin));
send_mask = digitalPinToBitMask(sendPin);
} else {
send_outport = NULL;
send_mask = 0;
}

recv_outport = portOutputRegister(digitalPinToPort(receivePin));
recv_inport = portInputRegister(digitalPinToPort(receivePin));
Expand Down Expand Up @@ -216,7 +216,7 @@ int CPlay_CapacitiveSensor::SenseOneCycle(void)
}
//Serial.print("SenseOneCycle(1): "); Serial.println(total);

if (total > CS_Timeout_Millis) {
if (total >= CS_Timeout_Millis) {
return -2; // total variable over timeout
}
}
Expand Down

0 comments on commit be65a94

Please sign in to comment.