Use Simple Event Handlers for Data From PC
Suppose you'd like to set things up so that when you click that button on your browser, a signal gets sent to your PIC board over the network (or over the web!) to light up an LED that is connected to pin RJ7 on the PIC18F97J60 EtherPIC on your device.
TCPmaker makes that really, really easy!
[video demo on receive event handlers]
- Create a Variable in TCPmaker 's Visual Page Designer .
- Associate this variable with a button on one of your pages. When TCPmaker generates code for your project, it will create a file called mtGen.c, which is where you'll customize your generated code. In this file, you'll find an event handler procedure for your variable. TCPmaker 's software framework will make sure that this event handler gets called any time the variable D1 gets changed. That will happen automatically whenever the user presses or releases the Pb1 button that you put in your layout.
- Add some code to the event handler for that variable, which TCPmaker created.
It's as simple as that!
Read more: Using simple event handlers >>
Use Other Types of TCPmaker Event Handlers
The TCPmaker Software Framework has other events, with corresponding event handlers that get called at other times. You use these mtServer events for things like:
- Initializing your device on power-up
- Telling the browser what the current state of your device is, when browser connects
- Doing some housekeeping when browser disconnects
- Sending data TO the browser
- Sending commands to specific controls on the browser
Read more: mtServer events >>
Send Data TO the PC Browser
TCPmaker also makes it very easy to send data from your PIC device to the PC browser as well.
Suppose you want to read a pushbutton that is connected to processor pin RB0 on your PIC board, send the button state to your browser, and use that to turn an Ld indicator (called Ld2) on or off on your TCPmaker display.
To do that, follow these simple steps:
- Create a variable in the Visual Page Designer to
- Associate this variable with a control on your layout. When TCPmaker generates your code, you will see a declaration for your variable, as well as a transmit flag for the variable.
- Add a couple of lines of code to give a value to your variable, and to set the variable's transmit flag to 1. Your device will then send the variable to the PC.
It's as easy as 1-2-3 !
Read more: Sending data to the PC browser >>
Make Context Sensitive Interactive Displays
If you think about it, every Windows program you have ever run has changed its appearance in subtle ways from one moment to the next, usually to guide your actions.
• Controls like buttons or text boxes will sometimes appear grayed out (disabled) in order to show you that it is not meaningful for you to click them right now.
• Menu items will appear or disappear at times, to restrict your choices.
• The color of some screen controls or text, to indicate a good or bad condition.
As a TCPmaker Pro developer, you can do those sorts of things as well. You can easily add a few lines to the code in your embedded web device to tell the TCPmaker controls on your browser screen to change their text, color, transparency, rotation, and so on.
Read more: Control Messages >>
Debug By Viewing Data Traffic to Your Device Alone
The code that TCPmaker generates is guaranteed to work, but sometimes during development you might add some code that isn't quite right. When that happens, you need to debug your device by looking at the data traffic to and from your device.
There are programs that will show you all the data on your network, but even a small home network has so much traffic on it that it is hard to find just which packets are going to and from your PIC device. It's also hard to understand the data that those programs show you.
To fix that problem, TCPmaker Pro gives you a simple but highly effective test program called mtDebug, which shows just the data going to and from your TCPmaker device, in a format that is easy to read and understand. mtDebug even lets you see your data while you control your device from your browser, so you can click whatever control makes the problem appear, and see from the data what happened.
[video demo of mtDebug]
RE-Generate Code Without Loss
TCPmaker projects are exceptionally easy to modify, when your boss or customer inevitably changes his mind. If it requires you to modify or add new TCPmaker Transfer Variables or screen controls or pages, just open your existing TCPmaker project file in TCPmaker , use the Visual Page Designer to make your changes, and re-generate code.
TCPmaker will save the existing versions of generated code files, the ones containing your code customizations, to files with new extensions, so you can copy your own code to the newly generated files. With an inexpensive differencing program like the exquisite [link] Beyond Compare from Scooter Software, the process of transferring from the old files to the new ones is a painless 15-minute job.
[video tutorial on using Beyond Compare to copy code snippets]
Next: Applications for TCPmaker >>