aboutsummaryrefslogtreecommitdiffstats
path: root/nph-png
blob: 0240b64fb76736937486edc3069e23e802d3235d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl

use strict;
use vars qw ($file $DELAY);
########## CONFIG
  $file = "lcd4linux"; # .png is appended
  $DELAY = 0;          # delay in seconds
                       # if delay is zero, file is sent when modified.
#################

use CGI qw/:push -nph/;
$| = 1;
my ($mtime, $nmtime, $size, $nsize);
(undef, undef, undef, undef, undef, undef, undef, $size, undef,
   $mtime) = stat "$file.png";
print multipart_init(-boundary=>'----------------here we go!');
while (1) {
  print multipart_start(-type=>'image/png');
  undef $/;
  open(IN, "$file.png") or die("Can't read '$file.png'");
  $_ = <IN>;
  print $_;
  close(IN);
  print multipart_end;
  if ($DELAY) {
    sleep $DELAY;
  }  
  else {
    W: while (1) {
  #    sleep(1);
      (undef, undef, undef, undef, undef, undef, undef, $nsize, undef,
         $nmtime) = stat "$file.png";
      if($mtime != $nmtime || $size != $nsize) {	 
        $mtime = $nmtime;
	$size = $nsize;
	last W;
      }	
    }	 
  }	
}
class="w"> "debug.h" #include "qprintf.h" #include "cfg.h" #include "udelay.h" #include "drv_generic_i2c.h" static char *Driver = ""; static char *Section = ""; static int i2c_device; static void my_i2c_smbus_write_byte_data(const int device, const unsigned char data) { struct i2c_smbus_ioctl_data args; args.read_write = I2C_SMBUS_WRITE; args.command = data; args.size = I2C_SMBUS_BYTE; args.data = 0; ioctl(device, I2C_SMBUS, &args); } static void my_i2c_smbus_read_byte_data(const int device, const unsigned char data) { struct i2c_smbus_ioctl_data args; args.read_write = I2C_SMBUS_READ; args.command = data; args.size = I2C_SMBUS_BYTE; args.data = 0; ioctl(device, I2C_SMBUS, &args); } int drv_generic_i2c_open(const char *section, const char *driver) { int dev; char *bus, *device; //SIGNAL_ENABLE = 0x40; //SIGNAL_RW = 0x10; //SIGNAL_RS = 0x20; udelay_init(); Section = (char *) section; Driver = (char *) driver; bus = cfg_get(Section, "Port", NULL); device = cfg_get(Section, "Device", NULL); dev = atoi(device); info("%s: initializing I2C bus %s", Driver, bus); info("device %d", dev); if ((i2c_device = open(bus, O_WRONLY)) < 0) { error("%s: I2C bus %s open failed !\n", Driver, bus); return -1; } info("%s: initializing I2C slave device 0x%x", Driver, dev); if (ioctl(i2c_device, I2C_SLAVE, dev) < 0) { error("%s: error initializing device 0x%x\n", Driver, dev); close(i2c_device); return -1; } return 0; } int drv_generic_i2c_close(void) { close(i2c_device); return 0; } unsigned char drv_generic_i2c_wire(const char *name, const char *deflt) { unsigned char w; char wire[256]; char *s; qprintf(wire, sizeof(wire), "Wire.%s", name); s = cfg_get(Section, wire, deflt); if (strlen(s) == 3 && strncasecmp(s, "DB", 2) == 0 && s[2] >= '0' && s[2] <= '7') { w = s[2] - '0'; } else if (strcasecmp(s, "GND") == 0) { w = 0; } else { error("%s: unknown signal <%s> for wire <%s>", Driver, s, name); error("%s: should be DB0..7 or GND", Driver); return 0xff; } free(s); if (w == 0) { info("%s: wiring: [DISPLAY:%s]<==>[i2c:GND]", Driver, name); } else { info("%s: wiring: [DISPLAY:%s]<==>[i2c:DB%d]", Driver, name, w); } w = 1 << w; return w; } void drv_generic_i2c_data(const unsigned char data) { my_i2c_smbus_write_byte_data(i2c_device, data); }