K8055.pm |
This is the mh client interface for my K8055 interface board daemon. Once you have created a K8055 object, you must tell it which input ports you are interested in using the doUpdate... methods.
$k8055 = new K8055;
if ($Reload) {
$k8055->doUpdateDigital(4);
$k8055->doUpdateAnalogue(2);
}
Whenever the value of these ports change, $k8055->state_now will return the name of the port that has changed (i.e. 'digital 4'). The state of each port is checked every 10 seconds (by default, can be changed).
Use the write... methods to change the value of the output ports.
K8055 daemon MisterHouse Interface http://www.velleman.be/ot/en/product/view/?id=351346
For one pass, will return the name of the input port that has just changed.
if ($state=$k8055->state_now()) {
if ($state eq 'digital 5') {
speak "The digital 5 port just changed value";
}
if ($state eq 'counter 1') {
speak "Counter number 1 just changed";
}
if ($state eq 'analogue 2') {
speak ("Analogue port 2 now reads ".$k8055->readAnalogue(2));
}
}
Returns the value of the given port as read on the last check.
# returns the last read value of digital port 4
$k8055->readDigital(4);
Sets the value of the output ports.
# sets analogue port 2 to 143/255 x 5V (i.e. 0=0 V, 255 = 5 V).
$k8055->writeAnalogue(2,143);
Resets the given counter.
# resets counter 2
$k8055->resetCounter(2);
Sets the debounce of each counter in milliseconds.
# sets the debounce of timer 1 to 350ms
$k8055->setDebounce(1,350);
Tells the object to care about the given port(s). If this command isn't called, then the corresponding read... method will always return -1 and the state variable will never be set.
# read and monitor digital ports 2, 3 and 5
$k8055->doUpdateDigital(2,5,3);
Sets how often we update the input port readings. Defaults to 10 seconds.
# input ports will be read every 2 seconds.
$k8055->setUpdatePeriod(2);
Gets the current auto update period in seconds.
print "current update period is ".$k8055->getUpdatePeriod()." seconds";
Immediate requests updated values from the ports that we are interested in. Note that the data will not immediately be available on return from this method as updates are asynchronous.
$k8055->update();
k8055_host - Hostname that is running k8055d.
k8055_port - Port on hostname to which daemon is listening.
Matthew Williams
NONE
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
K8055.pm |