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) )
    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:

  • Advances the value of the PageNum variable
  • Calls the eventPageNum() event handler to display this value on the LCD
  • Calls the mtGoToPage() function to send a Control Message to command the PC browser to go to the correct page, whose id is stored in the array of strings PageIDs[ ]
  • Sends the new value of PageNum to the PC browser. This will ensure that the correct button on the navigation panel will light up: the button whose rb property matches the new value of the PageNum variable.

The Back button works in a similar way, but in the eventBack() handler, the code we added decreases the value of the PageNum variable.


12 of 33
Copyright Notice and Author Information