Hardware Reference
In-Depth Information
When you type something in
the sketch window, it's added
to a string. It's then sent to the RFID
tag when you command the SM130
to write to the tag. The keyTyped()
method attaches any keystrokes to the
output string.
8
}
/*
If a key is typed, either add it to the output string
or delete the string if it's a backspace:
*/
void keyTyped() {
switch (key) {
case BACKSPACE: // delete
outputString = "\0";
break;
default:
if (outputString.length() < 16) {
outputString += key;
}
else {
outputString = "output string can't be more than 16 characters";
}
}
8
The button functionality is handled
by a separate Java class in the sketch
called Button. There are also a few
methods for managing the list of
buttons, including makeButtons() ,
which creates them initially, and draw-
Buttons() , which draws and updates
them.
}
/*
initialize all the buttons
*/
void makeButtons() {
// Define and create rectangle button
for (int b = 0; b < buttonNames.length; b++) {
// create a new button with the next name in the list:
Button thisButton = new Button(400, 30 +b*30,
150, 20,
buttoncolor, highlight, buttonNames[b]);
buttons.add(thisButton);
}
}
/*
draw all the buttons
*/
void drawButtons() {
for (int b = 0; b < buttons.size(); b++) {
// get this button from the Arraylist:
Button thisButton = (Button)buttons.get(b);
// update its pressed status:
thisButton.update();
// draw the button:
thisButton.display();
}
 
Search WWH ::




Custom Search