Shouldn't the SW1 button act like all the other GPIO's?
If you start out by using the SW1 for input, but later on decides to use another pin for the button, it wouldn't be good to require further code changes.
The way the button is wired (Pull-Up scenario) is pretty common, and having all GPIO's "inverted" wouldn't be fun is you ask me.
I'd say that a LOW signal on a pin should be FALSE, and a HIGH signal should be TRUE - Including the SW1 input.
Just my 5 cents...
/Thomas
You can make a good case for either option. I think the real problem is that a Port is fairly generic, while connecting a switch to an input port is a specific use case.
A couple of suggestions:
1. Define a new switch-specific enumeration, so that ON corresponds to boolean false, and OFF corresponds to boolean true.
2. Derive a Switch class from the InputPort class, and give the Switch class semantics that make sense for a switch (reading the state as being On/Off, Open/Closed, etc.).
Option 1 is probably simpler, while option 2 may be a "next version" type of thing.
Thanks,
-David