TCPmaker : Visual Tour    Sending Messages to Screen Controls  

Then, in these functions like the HandleBtnA() function shown below, we add a switch statement to make the press of this button take a unique action on each page of our multi-page TCPmaker Pro layout.

BtnA is the left-most button of the 4 buttons on the demo board.  PageNum == 0 signifies the index or "home" page of our layout, which is the "Text" page of this demo project.

Pressing the left-most button (i.e. BtnA) on the "Text" page changes the text of the Tx control and all the other sample controls like buttons, sliders, gauges, etc. that are grouped at the bottom of this page.

PageNum == 1 is the second page of our layout, whose navigation button is labeled "Btns, LEDs". On this page, pressing the left button changes the mode of a Pb button between momentary and toggle modes.

You can see how this is done in the HandleBtnA() function shown below:

void HandleBtnA(void)
{
  // Handle a press of the left-most button on the PICDEM.net 2 demo board
  switch (PageNum)
  {
  case 0 :  // index page : modify text size, color, rotation
    // Cycle through text constants
    mtSetTextRom((rom char *)"tx12", (rom char *)TextStrings[StringIndex]);
    mtSetTextRom((rom char *)"hs1", (rom char *)TextStrings[StringIndex]);
    mtSetTextRom((rom char *)"hg1", (rom char *)TextStrings[StringIndex]);
    mtSetTextRom((rom char *)"vg1", (rom char *)TextStrings[StringIndex]);
    mtSetTextRom((rom char *)"ni1", (rom char *)TextStrings[StringIndex]);
    mtSetTextRom((rom char *)"pb8", (rom char *)TextStrings[StringIndex]);
    mtSetTextRom((rom char *)"it1", (rom char *)TextStrings[StringIndex]);
    StringIndex++;
    if (StringIndex >= NumOfStrings)
      StringIndex = 0;
    break; 
   
  case 1 :  // pg1 : modify buttons & LEDs
    // Cycle through button modes
    mtSetButtonMode((rom char *)"pb9", BtnModes[BtnModeIndex]);
    BtnModeIndex++;
    if (BtnModeIndex >= NumOfModes)
      BtnModeIndex = 0;
    break; 
   
  case 2 :  // pg2 : modify any control
    // Shift X position 
    // See project source code for details...
    break; 
   
  case 3 :  // pg3 : modify variables & associations
    // Change plot variable between Pot1 and Time
    // See project source code for details...
    break; 
   
  case 4 :  // pg4 : modify controls to show context
    // Change Plot var among 3 different possibilities 
    // See project source code for details...
    break; 
   
  }
}  // HandleBtnA()

 
  

29 of 33
Copyright Notice and Author Information