@@ -17,20 +17,7 @@ void Toggle::begin(uint8_t inA, uint8_t inB) {
1717 _inB = inB;
1818 us_timestamp = micros ();
1919 startUs = us_timestamp;
20- if (_inA != 255 ) {
21- if (_inputMode == inputMode::input_pullup) pinMode (_inA, INPUT_PULLUP);
22- else if (_inputMode == inputMode::input) pinMode (_inA, INPUT);
23- #if (defined(ESP32) || defined(ARDUINO_ARCH_ESP32))
24- else if (_inputMode == inputMode::input_pulldown) pinMode (_inA, INPUT_PULLDOWN);
25- #endif
26- }
27- if (_inB != 255 ) {
28- if (_inputMode == inputMode::input_pullup) pinMode (_inB, INPUT_PULLUP);
29- else if (_inputMode == inputMode::input) pinMode (_inB, INPUT);
30- #if (defined(ESP32) || defined(ARDUINO_ARCH_ESP32))
31- else if (_inputMode == inputMode::input_pulldown) pinMode (_inB, INPUT_PULLDOWN);
32- #endif
33- }
20+ setInputMode (inputMode::input_pullup);
3421 }
3522}
3623
@@ -51,6 +38,20 @@ void Toggle::poll(uint8_t bit) {
5138
5239void Toggle::setInputMode (inputMode inputMode) {
5340 _inputMode = inputMode;
41+ if (_inA != 255 ) {
42+ if (_inputMode == inputMode::input_pullup) pinMode (_inA, INPUT_PULLUP);
43+ else if (_inputMode == inputMode::input) pinMode (_inA, INPUT);
44+ #if (defined(ESP32) || defined(ARDUINO_ARCH_ESP32))
45+ else if (_inputMode == inputMode::input_pulldown) pinMode (_inA, INPUT_PULLDOWN);
46+ #endif
47+ }
48+ if (_inB != 255 ) {
49+ if (_inputMode == inputMode::input_pullup) pinMode (_inB, INPUT_PULLUP);
50+ else if (_inputMode == inputMode::input) pinMode (_inB, INPUT);
51+ #if (defined(ESP32) || defined(ARDUINO_ARCH_ESP32))
52+ else if (_inputMode == inputMode::input_pulldown) pinMode (_inB, INPUT_PULLDOWN);
53+ #endif
54+ }
5455}
5556
5657void Toggle::setSamplePeriodUs (uint16_t period) {
0 commit comments