Copyright update for 2011
[bcusdk.git] / contrib / eibdvis / send.php
blob6fe236e8591adf7d13749bd50dfd6128704c90fe
1 <?php
2 /*
3 EIBD client library examples
4 Copyright (C) 2005-2011 Martin Koegler <mkoegler@auto.tuwien.ac.at>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 include ("common.php");
23 html_header($config->title);
25 if ($_GET["addr"] != "" && $_GET["val"] != "" )
27 $addr = $_GET["addr"];
28 $typ = $_GET["typ"];
29 $value = $_GET["val"];
30 $res = -1;
32 $con = $config->connect ();
34 switch($typ)
36 case "small":
37 $res=groupswrite ($con, $addr, $value);
38 break;
40 case "p1":
41 if ($value < 0)
42 $value = 0;
43 if ($value > 100)
44 $value = 100;
45 $value = (int)(($value * 255) / 100 + 0.5);
46 $res=groupwrite ($con, $addr, array ($value & 0xff));
47 break;
49 case "b1":
50 $res=groupwrite ($con, $addr, array ($value & 0xff));
51 break;
53 case "b2":
54 $res=groupwrite ($con, $addr, array (($value >> 8) & 0xff, $value & 0xff));
55 break;
57 case "f2":
58 $res=groupwrite ($con, $addr, f2_encode($value));
59 break;
62 if($res == -1)
63 printf("<div class='result'>sending of %s to %s failed</div>", htmlentities($value), htmlentities($addr));
64 else
65 printf("<div class='result'>sent %s to %s </div>", htmlentities($value), htmlentities($addr));
68 html_end();