Programming - First steps
P.
82 of 349
This is our task
A global Mbutton
with 3 elements
These variables simplify
programming
State 0 of mbutton() means: The
user has operated the listbox.
Adjusting the display: If any
information changes, call display().
One call for all changes.
Therefore, the following task presents itself to the programmer:
A)
Find out which element of the listbox is active.
This takes place with the aid of
mbutton()
(see below)
B)
Switching the control element by means of
display()
C)
Find out if the button has been activated.
Again, this takes place with the aid of
mbutton()
(see below)
D)
Updating the display via
display()
The function
mbutton(
ID{u08},selection{u08})
is designed for the evaluation of the listbox.
If the listbox is changed in such a way that the element with the index
selection
is changed, the
function returns 255, and if the button is pressed, the value index of the
selection
. We want to
exemplify this. At first, we have to add the element
mbutton
(for its syntax, see page 275) to our web
server.
To this end, we complete our configuration:
[WebServer]
// Page 1
page(CentralHeatingRoomPageID)[$Basement$,$Heating$]
button(LightID)[LIGHT]$All lights$ button(PlugID)[LIGHT]$Sockets$
mbutton(mPlugID)[SWITCH][$1.Socket$,$2.Socket$,$3.Socket$]$MultiSwitch$
// Page 2
page(2)[$2nd floor$,$Bedroom$]
button(LightID)[LIGHT]$All lights$ button(PlugID)[LIGHT]$Sockets$
In this manner, we have added the global web element
mbutton
. Similarly, we could have defined a
local element (
mpbutton
).
How do we address the element?
To this, we add the following lines to the program:
mPlugID=1
mPlug1=1
mPlug2=2
mPlug3=3
mText=$AUS$
mICON=SWITCH
mState=ACTIVE
mDeco=GREY
mChoice=1
// Querying the listbox
if mbutton(mPlugID,mPlug1)==255 then {
mChoice=1
} endif
if mbutton(mPlugID,mPlug2)==255 then {
mChoice=2
} endif
if mbutton(mPlugID,mPlug3)==255 then {
mChoice=3
} endif
// Adjusting the display
if change(mText) or change(mICON) or change(mState) or change(mDeco) or change(mChoice) then {
display(mPlugID,mText,mICON,mState,mDeco,mChoice)
} endif
Now the user already can operate the listbox, and the Enertex® EibPC „memorizes“ this setting.
What is yet missing is task D) and E) of the explanations above.
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]