Fixed Offset label in device editor. Added code to edit pin states for DS2408 and DS2413 1-wire devices.

Thu, 26 Mar 2015 20:34:53 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 26 Mar 2015 20:34:53 +0100
changeset 344
acd840c9fcc0
parent 343
ba3a2d27d59e
child 345
9894b559441c

Fixed Offset label in device editor. Added code to edit pin states for DS2408 and DS2413 1-wire devices.

thermferm/devices.c file | annotate | diff | comparison | revisions
thermferm/server.c file | annotate | diff | comparison | revisions
www-thermferm/devices.php file | annotate | diff | comparison | revisions
--- a/thermferm/devices.c	Thu Mar 26 16:40:53 2015 +0100
+++ b/thermferm/devices.c	Thu Mar 26 20:34:53 2015 +0100
@@ -302,8 +302,10 @@
 			    ndev->description = xstrcpy((char *)"DS18B20 Digital thermometer");
 			} else if (strcmp(buf, (char *)"29") == 0) {
 			    ndev->description = xstrcpy((char *)"DS2408 8 Channel addressable switch/LCD");
+			    ndev->direction = DEVDIR_IN_BIN;
 			} else if (strcmp(buf, (char *)"3a") == 0) {
 			    ndev->description = xstrcpy((char *)"DS2413 Dual channel addressable switch");
+			    ndev->direction = DEVDIR_IN_BIN;
 			} else if (strcmp(buf, (char *)"3b") == 0) {
 			    ndev->direction = DEVDIR_IN_ANALOG;
 			    ndev->description = xstrcpy((char *)"DS1825 Digital thermometer");
--- a/thermferm/server.c	Thu Mar 26 16:40:53 2015 +0100
+++ b/thermferm/server.c	Thu Mar 26 20:34:53 2015 +0100
@@ -668,11 +668,11 @@
 #endif
 		srv_send((char *)"213 Device record follows:");
 		srv_send((char *)"TYPE,%s", DEVTYPE[device->type]);
+		srv_send((char *)"ADDRESS,%s", device->address);
 		srv_send((char *)"DIRECTION,%s", DEVDIR[device->direction]);
 		srv_send((char *)"VALUE,%d", my_value);
 		srv_send((char *)"OFFSET,%d", device->offset);
 		srv_send((char *)"PRESENT,%s", DEVPRESENT[device->present]);
-		srv_send((char *)"ADDRESS,%s", device->address);
 		srv_send((char *)"SUBDEVICE,%d", device->subdevice);
 		srv_send((char *)"GPIOPIN,%d", device->gpiopin);
 		srv_send((char *)"DESCRIPTION,%s", device->description);
--- a/www-thermferm/devices.php	Thu Mar 26 16:40:53 2015 +0100
+++ b/www-thermferm/devices.php	Thu Mar 26 20:34:53 2015 +0100
@@ -1,6 +1,6 @@
 <?php
 /*****************************************************************************
- * Copyright (C) 2014
+ * Copyright (C) 2014-2015
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -272,12 +272,22 @@
 		 */
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Device Type</td>'.PHP_EOL;
-		if (($type == "W1") || ($type == "GPIO"))
+		if (($type == "W1") || ($type == "GPIO") || ($type == "SIM"))
 		    $outstr .= '        <td class="editfield"><input type="hidden" name="Type" value="'.$f[1].'">'.$f[1].'</td>'.PHP_EOL;
 		else
 		    $outstr .= '        <td class="editfield"><input type="text" name="Type" size="50" value="'.$f[1].'"></td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
+	    if ($f[0] == "ADDRESS") {
+		$address = $f[1];
+		$outstr .= '       <tr class="editor">'.PHP_EOL;
+		$outstr .= '        <td class="editname">Address</td>'.PHP_EOL;
+		if (($type == "W1") || ($type == "GPIO"))
+		    $outstr .= '        <td class="editfield"><input type="hidden" name="Address" value="'.$f[1].'">'.$f[1].'</td>'.PHP_EOL;
+		else
+		    $outstr .= '        <td class="editfield"><input type="text" name="Address" size="50" value="'.$f[1].'"></td>'.PHP_EOL;
+		$outstr .= '       </tr>'.PHP_EOL;
+	    }
 	    if ($f[0] == "DIRECTION") {
 		$direction = $f[1];
 		/*
@@ -285,9 +295,22 @@
 		 */
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">IO Direction and mode</td>'.PHP_EOL;
-		if ($type == "W1")
-		    $outstr .= '        <td class="editfield"><input type="hidden" name="Direction" value="'.$f[1].'">'.$f[1].'</td>'.PHP_EOL;
-		else {
+		if ($type == "W1") {
+		    if ((strncmp($address, "29", 2) == 0) || (strncmp($address, "3a", 2) == 0)) {
+			$outstr .= '        <td class="editfield"><select name="Direction">'.PHP_EOL;
+			$se = ($f[1] == "UNDEF")?" selected":"";
+			$outstr .= '         <option value="UNDEF"'.$se.'>Undefined</option>'.PHP_EOL;
+			$se = ($f[1] == "IN_BIN")?" selected":"";
+			$outstr .= '         <option value="IN_BIN"'.$se.'>Binary input</option>'.PHP_EOL;
+			$se = ($f[1] == "OUT_BIN")?" selected":"";
+			$outstr .= '         <option value="OUT_BIN"'.$se.'>Binary output</option>'.PHP_EOL;
+			$se = ($f[1] == "OUT_PWM")?" selected":"";
+			$outstr .= '         <option value="OUT_PWM"'.$se.'>PWM output</option>'.PHP_EOL;
+			$outstr .= '        </select></td>'.PHP_EOL;
+		    } else {
+			$outstr .= '        <td class="editfield"><input type="hidden" name="Direction" value="'.$f[1].'">'.$f[1].'</td>'.PHP_EOL;
+		    }
+		} else {
 		    $outstr .= '        <td class="editfield"><select name="Direction">'.PHP_EOL;
 		    if ($type == "GPIO") {
 			$se = ($f[1] == "UNDEF")?" selected":"";
@@ -319,6 +342,10 @@
 			$se = ($f[1] == "UNDEF")?" selected":"";
 			$outstr .= '         <option value="UNDEF"'.$se.'>Undefined</option>'.PHP_EOL;
 		    }
+		    if ($type == "SIM") {
+			$se = ($f[1] == "UNDEF")?" selected":"";
+			$outstr .= '         <option value="UNDEF"'.$se.'>Undefined</option>'.PHP_EOL;
+		    }
 		    $outstr .= '        </select></td>'.PHP_EOL;
 		}
 		$outstr .= '       </tr>'.PHP_EOL;
@@ -337,7 +364,7 @@
 	    }
 	    if ($f[0] == "OFFSET") {
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
-		$outstr .= '        <td class="editname">Value</td>'.PHP_EOL;
+		$outstr .= '        <td class="editname">Offset</td>'.PHP_EOL;
 		if ($direction == "IN_ANALOG")
 		    $outstr .= '        <td class="editfield"><input type="text" name="Offset" size="50" value="'.$f[1].'"></td>'.PHP_EOL;
 		else
@@ -366,15 +393,6 @@
 		}
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
-	    if ($f[0] == "ADDRESS") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
-		$outstr .= '        <td class="editname">Address</td>'.PHP_EOL;
-		if (($type == "W1") || ($type == "GPIO"))
-		    $outstr .= '        <td class="editfield"><input type="hidden" name="Address" value="'.$f[1].'">'.$f[1].'</td>'.PHP_EOL;
-		else
-		    $outstr .= '        <td class="editfield"><input type="text" name="Address" size="50" value="'.$f[1].'"></td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
-	    }
 	    if ($f[0] == "SUBDEVICE") {
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Subdevice</td>'.PHP_EOL;

mercurial