Hardware Reference
In-Depth Information
mousePressed() checks to see
whether one of the buttons is
pressed. If so, it calls doButtonAction() ,
which sends the appropriate command
for each button to the SM130.
8
}
void mousePressed() {
// iterate over the buttons, activate the one pressed
for (int b = 0; b < buttons.size(); b++) {
Button thisButton = (Button)buttons.get(b);
if (thisButton.containsMouse()) {
doButtonAction(thisButton);
}
}
}
/*
if one of the command buttons is pressed, figure out which one
and take the appropriate action.
*/
void doButtonAction(Button thisButton) {
// figure out which button this is in the ArrayList:
int buttonNumber = buttons.indexOf(thisButton);
// do the right thing:
switch (buttonNumber) {
case 0: // set antenna power
if (myReader.getAntennaPower() < 1) {
myReader.setAntennaPower(0x01);
}
else {
myReader.setAntennaPower(0x00);
}
break;
case 1: // select tag
myReader.selectTag();
break;
case 2: // authenticate
myReader.authenticate(0x04, 0xFF);
break;
case 3: // read block
myReader.readBlock(0x04);
break;
case 4: // seek tag
myReader.seekTag();
break;
case 5: // write tag - must be 16 bytes or less
myReader.writeBlock(0x04, outputString);
outputString = "";
break;
case 6: // get reader firmware version
myReader.getFirmwareVersion();
break;
}
 
Search WWH ::




Custom Search