I follow that.
Now, my question has to do with displaying it inside an application (Android Reef Angel Status).
The libraries do a bitRead on the port to get the value. I have things separated out in the application and perform the same action. So if the value is 1 for the channel, I return true (same as 1) otherwise I return false (same as 0).
On my I/O page, I have a label set to be OFF if the value is 1 and ON if the value is 0. Is this correct or should I have things flipped?
Here's my code in question:
Code: Select all
public static boolean getIOChannel ( short ioChannels, byte channel ) {
// channel is 0 based
int v = (1 << channel);
int w = (ioChannels & v);
boolean f = w == v;
return f;
}
//... other code goes here.
if ( Controller.getIOChannel( ioports, channel ) ) {
s = getString( R.string.labelOFF );
} else {
s = getString( R.string.labelON );
}
I just want to make sure that I have it coded and displaying properly for people using the I/O module.
Lastly, I'm adding in notifications and if getIOChannel returns true (or 1), I'm going to return 1 for comparison just like the other code samples are shown.