File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 2525#define PRR0 PRR
2626#endif
2727
28+ namespace DcsBios {
29+ const unsigned char PIN_NC = 0xFF ;
30+ }
31+
2832/*
2933The following is an ugly hack to work with the Arduino IDE's build system.
3034The DCS-BIOS Arduino Library is configured with #defines such as DCSBIOS_RS485_MASTER or DCSBIOS_RS485_SLAVE <address>.
Original file line number Diff line number Diff line change @@ -140,12 +140,17 @@ namespace DcsBios {
140140 char lastState_;
141141 bool reverse_;
142142 char readState () {
143- unsigned char i;
144- for (i=0 ; i<numberOfPins_; i++) {
145- if (digitalRead (pins_[i]) == LOW && reverse_ == false ) return i;
146- else if (digitalRead (pins_[i]) == HIGH && reverse_ == true ) return i;
143+ unsigned char ncPinIdx = lastState_;
144+ for (unsigned char i=0 ; i<numberOfPins_; i++) {
145+ if ( pins_[i] == PIN_NC)
146+ ncPinIdx = i;
147+ else
148+ {
149+ if (digitalRead (pins_[i]) == LOW && reverse_ == false ) return i;
150+ else if (digitalRead (pins_[i]) == HIGH && reverse_ == true ) return i;
151+ }
147152 }
148- return lastState_ ;
153+ return ncPinIdx ;
149154 }
150155 void resetState ()
151156 {
@@ -172,7 +177,8 @@ namespace DcsBios {
172177 numberOfPins_ = numberOfPins;
173178 unsigned char i;
174179 for (i=0 ; i<numberOfPins; i++) {
175- pinMode (pins[i], INPUT_PULLUP);
180+ if ( pins[i] != PIN_NC)
181+ pinMode (pins[i], INPUT_PULLUP);
176182 }
177183 lastState_ = readState ();
178184 }
You can’t perform that action at this time.
0 commit comments