I'm going to include this nice patch for the DS2408 LCD display.

I am a little concerned that the Honoff is a little confusing.

Any comments,

Paul Alfille

---------- Forwarded message ----------
From: Maxime Soulé <[EMAIL PROTECTED]>
Date: Tue, Sep 9, 2008 at 5:44 PM
Subject: owfs-2.7p4 and Hobbyboards LCD/DS2408 patch
To: [EMAIL PROTECTED]


Hello,

I just discovered owfs and I find it very useful! You did a great job,
congratulation!

As I own a hobbyboard LCD driver board, I added two nodes to the DS2408
source file.

The first is "LCD_H/screenyx". It is like "LCD_H/screen" one but the two
first characters of the passed string allow to position the cursor:
"\x02\x04string" perl string write "string" at line 2 (option base 1) column
4 (option base 1).

Last one is "LCD_H/onoff": an ored integer to switch display (0x04), cursor
(0x02) and blinking cursor (0x01) on/off.

Hope this patch will help you...

Best regards,

Max.

--- owfs-2.7p4/module/owlib/src/c/ow_2408.c.orig        2008-09-09
22:02:57.000000000 +0200
+++ owfs-2.7p4/module/owlib/src/c/ow_2408.c     2008-09-09
23:24:19.000000000 +0200
@@ -83,7 +83,9 @@
 WRITE_FUNCTION(FS_Hclear);
 WRITE_FUNCTION(FS_Hhome);
 WRITE_FUNCTION(FS_Hscreen);
+WRITE_FUNCTION(FS_Hscreenyx);
 WRITE_FUNCTION(FS_Hmessage);
+WRITE_FUNCTION(FS_Honoff);

 /* ------- Structures ----------- */

@@ -106,7 +108,9 @@
  {"LCD_H/clear", PROPERTY_LENGTH_YESNO, NULL, ft_yesno, fc_stable,
NO_READ_FUNCTION, FS_Hclear, {v:NULL},},
  {"LCD_H/home", PROPERTY_LENGTH_YESNO, NULL, ft_yesno, fc_stable,
NO_READ_FUNCTION, FS_Hhome, {v:NULL},},
  {"LCD_H/screen", 128, NULL, ft_ascii, fc_stable, NO_READ_FUNCTION,
FS_Hscreen, {v:NULL},},
+  {"LCD_H/screenyx", 128, NULL, ft_ascii, fc_stable, NO_READ_FUNCTION,
FS_Hscreenyx, {v:NULL},},
  {"LCD_H/message", 128, NULL, ft_ascii, fc_stable, NO_READ_FUNCTION,
FS_Hmessage, {v:NULL},},
+  {"LCD_H/onoff", PROPERTY_LENGTH_UNSIGNED, NULL, ft_unsigned, fc_stable,
NO_READ_FUNCTION, FS_Honoff, {v:NULL},}
 };

 DeviceEntryExtended(29, DS2408, DEV_alarm | DEV_resume | DEV_ovdr);
@@ -399,6 +403,54 @@
       return OW_w_pios(data, j, PN(owq)) ? -EINVAL : 0;
 }

+static int FS_Hscreenyx(struct one_wire_query *owq)
+{
+       char *buf = OWQ_buffer(owq);
+       size_t size = OWQ_size(owq);
+       BYTE data[2 * size + 2];
+       size_t i, j = 0;
+       u_char ua_tmp;
+
+       if (size < 2)
+         return -EINVAL;
+
+       if ((unsigned char)buf[1] > 20 || (unsigned char)buf[0] > 4)
+         return -EINVAL;
+
+       switch (buf[0])
+       {
+       default:
+         ua_tmp = 0x80;
+         break;
+       case 2:
+         ua_tmp = 0x80 | 0x40;
+         break;
+       case 3:
+         ua_tmp = 0x80 + 20;
+         break;
+       case 4:
+         ua_tmp = (0x80 | 0x40) + 20;
+         break;
+       }
+
+       ua_tmp += buf[1] - 1;
+
+       data[0] = (ua_tmp & 0xF0);
+       data[1] = (ua_tmp << 4) & 0xF0;
+
+       //printf("Hscreen test<%*s>\n",(int)size,buf) ;
+       for (i = 2, j = 2; i < size; ++i) {
+               if (buf[i]) {
+                       data[j++] = (buf[i] & 0xF0) | 0x08;
+                       data[j++] = ((buf[i] << 4) & 0xF0) | 0x08;
+               } else {                                //null byte becomes
space
+                       data[j++] = 0x28;
+                       data[j++] = 0x08;
+               }
+       }
+       return OW_w_pios(data, j, PN(owq)) ? -EINVAL : 0;
+}
+
 static int FS_Hmessage(struct one_wire_query *owq)
 {
       if (FS_Hclear(owq) || FS_Hhome(owq)
@@ -407,6 +459,21 @@
       return 0;
 }

+// 0x01 => blinking cursor on
+// 0x02 => cursor on
+// 0x04 => display on
+static int FS_Honoff(struct one_wire_query *owq)
+{
+       BYTE onoff[] = { 0x00, 0x00 };
+
+       onoff[1] = ((0x08 | OWQ_U(owq)) << 4) & 0xF0;
+
+       // onoff
+       if (OW_w_pios(onoff, 2, PN(owq)))
+               return -EINVAL;
+       return 0;
+}
+
 /* Read 6 bytes --
   0x88 PIO logic State
   0x89 PIO output Latch state
--- owfs-2.7p4/module/owlib/src/c/ow_2408.c.orig        2008-09-09 
22:02:57.000000000 +0200
+++ owfs-2.7p4/module/owlib/src/c/ow_2408.c     2008-09-09 23:24:19.000000000 
+0200
@@ -83,7 +83,9 @@
 WRITE_FUNCTION(FS_Hclear);
 WRITE_FUNCTION(FS_Hhome);
 WRITE_FUNCTION(FS_Hscreen);
+WRITE_FUNCTION(FS_Hscreenyx);
 WRITE_FUNCTION(FS_Hmessage);
+WRITE_FUNCTION(FS_Honoff);
 
 /* ------- Structures ----------- */
 
@@ -106,7 +108,9 @@
   {"LCD_H/clear", PROPERTY_LENGTH_YESNO, NULL, ft_yesno, fc_stable, 
NO_READ_FUNCTION, FS_Hclear, {v:NULL},},
   {"LCD_H/home", PROPERTY_LENGTH_YESNO, NULL, ft_yesno, fc_stable, 
NO_READ_FUNCTION, FS_Hhome, {v:NULL},},
   {"LCD_H/screen", 128, NULL, ft_ascii, fc_stable, NO_READ_FUNCTION, 
FS_Hscreen, {v:NULL},},
+  {"LCD_H/screenyx", 128, NULL, ft_ascii, fc_stable, NO_READ_FUNCTION, 
FS_Hscreenyx, {v:NULL},},
   {"LCD_H/message", 128, NULL, ft_ascii, fc_stable, NO_READ_FUNCTION, 
FS_Hmessage, {v:NULL},},
+  {"LCD_H/onoff", PROPERTY_LENGTH_UNSIGNED, NULL, ft_unsigned, fc_stable, 
NO_READ_FUNCTION, FS_Honoff, {v:NULL},}
 };
 
 DeviceEntryExtended(29, DS2408, DEV_alarm | DEV_resume | DEV_ovdr);
@@ -399,6 +403,54 @@
        return OW_w_pios(data, j, PN(owq)) ? -EINVAL : 0;
 }
 
+static int FS_Hscreenyx(struct one_wire_query *owq)
+{
+       char *buf = OWQ_buffer(owq);
+       size_t size = OWQ_size(owq);
+       BYTE data[2 * size + 2];
+       size_t i, j = 0;
+       u_char ua_tmp;
+
+       if (size < 2)
+         return -EINVAL;
+
+       if ((unsigned char)buf[1] > 20 || (unsigned char)buf[0] > 4)
+         return -EINVAL;
+
+       switch (buf[0])
+       {
+       default:
+         ua_tmp = 0x80;
+         break;
+       case 2:
+         ua_tmp = 0x80 | 0x40;
+         break;
+       case 3:
+         ua_tmp = 0x80 + 20;
+         break;
+       case 4:
+         ua_tmp = (0x80 | 0x40) + 20;
+         break;
+       }
+
+       ua_tmp += buf[1] - 1;
+
+       data[0] = (ua_tmp & 0xF0);
+       data[1] = (ua_tmp << 4) & 0xF0;
+
+       //printf("Hscreen test<%*s>\n",(int)size,buf) ;
+       for (i = 2, j = 2; i < size; ++i) {
+               if (buf[i]) {
+                       data[j++] = (buf[i] & 0xF0) | 0x08;
+                       data[j++] = ((buf[i] << 4) & 0xF0) | 0x08;
+               } else {                                //null byte becomes 
space
+                       data[j++] = 0x28;
+                       data[j++] = 0x08;
+               }
+       }
+       return OW_w_pios(data, j, PN(owq)) ? -EINVAL : 0;
+}
+
 static int FS_Hmessage(struct one_wire_query *owq)
 {
        if (FS_Hclear(owq) || FS_Hhome(owq)
@@ -407,6 +459,21 @@
        return 0;
 }
 
+// 0x01 => blinking cursor on
+// 0x02 => cursor on
+// 0x04 => display on
+static int FS_Honoff(struct one_wire_query *owq)
+{
+       BYTE onoff[] = { 0x00, 0x00 };
+
+       onoff[1] = ((0x08 | OWQ_U(owq)) << 4) & 0xF0;
+
+       // onoff
+       if (OW_w_pios(onoff, 2, PN(owq)))
+               return -EINVAL;
+       return 0;
+}
+
 /* Read 6 bytes --
    0x88 PIO logic State
    0x89 PIO output Latch state
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to