arduino-libraries / Arduino_MKRIoTCarrier

Use the features included with the Arduino MKR IoT Carrier
https://store.arduino.cc/mkr-iot-carrier
GNU Lesser General Public License v2.1
18 stars 11 forks source link

Use ints instead of enum class to identify touch buttons #56

Open alranel opened 2 years ago

alranel commented 2 years ago

As of now, touch buttons are identified using an enum class:

https://github.com/arduino-libraries/Arduino_MKRIoTCarrier/blob/4a894ad4910f121662ed54b0957002202cf732c8/src/Arduino_MKRIoTCarrier_Qtouch.h#L29-L35

This means that in order to iterate over all the buttons to find out which one was pressed, a cast to the touchButtons type must be used:

for (int i = 0; i <= 4; ++i) {
   if (carrier.Buttons.onTouchDown((touchButtons)i)) {
      Serial.print("Button pressed: ");
      Serial.println(i);
   }
}

Considering this type is not documented anywhere and probably not strictly necessary, can't we just allow plan ints as arguments and get rid of those TOUCHx constants?