Section Place controls on the interface for monitoring and control Creating a Plot Object Control

Controls, such as text boxes, buttons, gauges and so on may be placed on the StampPlot background once the plot is resized.

!POBJ Clear

!PPER 70,80

!NEWP

A new plot object control is created by defining the type, naming it, setting the coordinates (the background is 0,0 to 100,100) and setting parameters.

To create a new meter the format is:

!POBJ oMeter.objName=L,T [,W,H,scale min, scale max,alarm min, alarm max]

Where oMeter means to use a meter control plot object. ObjName is what you want to name it.

L = Left Coordinate of meter.

T = Top Coordinate of meter. [ ] indicates these parameters are optional. W = Width of the meter. H = Height of the meter. Scale min = The minimum value of the meter. Scale Max = The maximum value of the meter. Alarm Min = The lower alarm set point. Alarm Max = The upper alarm set point.

So, to create a meter called meterl at 75 left and 50 top using default width and height, and range from 0 to 255 with alarm set points at 25 and 200 (ensure you run previous code first):

!POBJ oMeter.Meter1=75,50, ,,0,255,25,200

Meterl may be updated by giving it a new value (notice how its name is used):

!POBJ Meter1= 100

BASIC Stamp Code to run the meter may be as follows:

'Plot and use meter

PAUSE 1000

DEBUG

CR,"!POBJ Clear",

CR

DEBUG

"!NEWP",CR

DEBUG

"!PLOT ON",CR

DEBUG

"@TEXT 35a, 102a,

2,

(BLUE),

StampPlot Meters!"

, CR

' Size the plot DEBUG "!PPER 70,80",CR

' Size the plot DEBUG "!PPER 70,80",CR

' Create meter

DEBUG "!POBJ oMeter.Meter1=75,50,,,0,255,25,200",CR

RANDOM x ' Plot value DEBUG DEC x,CR

' Update meter

DEBUG "!O Meter1="

, DEC x,CR

PAUSE 500

LOOP

Notice the use of !O. This is short hand for !POBJ to save typing and code space. Also note the update string must be sent each time the value changes. This can be automated using an Update Value for the control object.

Solar Power

Solar Power

Start Saving On Your Electricity Bills Using The Power of the Sun And Other Natural Resources!

Get My Free Ebook


Post a comment