LCD appmod with the javelin
I'm having trouble figuring out what exactly holds the values for when the buttons are pushed. for example with the example program when i press the left most button the character A shows up on the display. My question is where is that A so that i can change it to display a different variable, the variable will be a string.
is it something in this code, or in the LCDterminal class itself?
····· display.scroll(display.LINE1, msg);
····· display.write("Buttons:");
····· for(int i = 0; i < 150; i++) {
······· display.moveTo(display.LINE2, 2);
······· buttons = display.readButtons();
······· for (int mask, pos = 0x00; pos <= 0x03; pos += 1) {
········· mask = 0x001 << pos;
········· dispChar = ((buttons & mask) != 0) ? (65 + pos) : 45;
········· display.write(dispChar);}}
is it something in this code, or in the LCDterminal class itself?
····· display.scroll(display.LINE1, msg);
····· display.write("Buttons:");
····· for(int i = 0; i < 150; i++) {
······· display.moveTo(display.LINE2, 2);
······· buttons = display.readButtons();
······· for (int mask, pos = 0x00; pos <= 0x03; pos += 1) {
········· mask = 0x001 << pos;
········· dispChar = ((buttons & mask) != 0) ? (65 + pos) : 45;
········· display.write(dispChar);}}
Comments
dispChar = ((buttons & mask) != 0) ? (65 + pos) : 45;
which could also be written as
dispChar = ((buttons & mask) != 0) ? ('A' + pos) : 45;
When pos=1 then 'B' is displayed etc.
regards peter
····· display.scroll(display.LINE1, msg);
····· display.write("Buttons:");
····· for(int i = 0; i < 150; i++) {
······· display.moveTo(display.LINE2, 2);
······· buttons = display.readButtons();
······· for (int i=0; i<4; i++) {
··········int mask = buttons & (1<<i); //extract one bit each time
········· if (mask == 0) { //button pressed
··········· displayString(i);
·········· }
·········}
······· for (int mask, pos = 0x00; pos <= 0x03; pos += 1) {
········· mask = 0x001 << pos;
········· dispChar = ((buttons & mask) != 0) ? (65 + pos) : 45;
········· display.write(dispChar);}}
static String[noparse]/noparse myStrings = new String[noparse]/noparse{"btn0","btn1","btn2","btn3"};
static void displayString(int i) {
· int j=0;
· while (j < myStrings[noparse][[/noparse]i].length()) {
··· display.write(myStrings[noparse][[/noparse]i].charAt(j));
··· j++;
· }
}
regards peter