TCPmaker : Visual Tour Sending Messages to Screen Controls |
The code we have added to the Next variable's Receive Event handler is shown in blue boldface type below.
Note that when the user releases the mouse button on the Next button on our PC browser layout, the value 0 is assigned to the Next variable, which is then sent to the device, so this variable's Receive Event handler, eventNext(), is called again. The code we added tests for this, and only takes action when a non-zero value of this variable is received by the device.
// Event handler for variable: Next - Informs device that Next button was pressed
void eventNext(void)
{
// Variable has just arrived, so add your code to DO something with it here:
// Note that a Pb Pushbutton sends a 1 value when button goes DOWN,
// and a 0 value a short while later when the button goes UP.
//
// We only want to act when the button goes DOWN, so we test if (Next > 0)
if ( (PageNum < 4) && (Next > 0) )
{
PageNum++;
eventPageNum(); // Update the LCD display
mtGoToPage( PageIDs[PageNum] );
PageNumTxFlag = 1; // Tell mtServer to update the displays as well
}
}
When a non-zero value of variable Next is received by the device, it takes the following action:
The Back button works in a similar way, but in the eventBack() handler, the code we added decreases the value of the PageNum variable.
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 |