TCPmaker : Visual Tour Sending Messages to Screen Controls |
First of all, we make use of the optional sendButtons() function, which is present but commented out in file mtGen.c. Here is what we did with this function:
void sendButtons(void)
{
unsigned char myButton;
// On the PICDEM.net 2, BUTTON0_IO is the right-most button
myButton = !BUTTON0_IO;
if (myButton != BtnD) {
BtnD = myButton;
//BtnDTxFlag = 1; // Disabled: we aren't actually sending anything to the PC
if (BtnD)
HandleBtnD(); // Only call this when button goes down, not when released
}
// On the PICDEM.net 2, BUTTON1_IO button is 3rd from left
myButton = !BUTTON1_IO;
if (myButton != BtnC) {
BtnC = myButton;
//BtnCTxFlag = 1; // Disabled: we aren't actually sending anything to the PC
if (BtnC)
HandleBtnC(); // Only call this when button goes down, not when released
}
// On the PICDEM.net 2, BUTTON2_IO button is 2nd from left
// <Similar code here...>
// On the PICDEM.net 2, BUTTON3_IO is the left-most button
// <Similar code here...>
} // sendButtons()
That is, we don't actually send any values of variables BtnA ... BtnD (which we renamed from Btn0 ... Btn3 to avoid the confusion with Microchip's numbering of button #defines like BUTTON0_IO). Instead, we just call a special handler for each button, whenever the button is pressed down.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |