Tclhttpd webserver extended with page counter on parallel port LED displays

by Theo Verelst

Because I prototyped a parallel port interface on a PC running a webserver based on tclhttpd, and made some procedures for driving the display using the driver on the parallel port page, I though I'd not just make a Webserver combined with bwise, let the webserver drive the display so as to follow the hit-counts when the screen is not on, or in use for other things, or to see if it things still run.

I used my adapted tclhttpd script, which opens a console window, and used the following code in the console, so as to run this fun extension live, without interrupting the server. One day I might make a page on saving the state of tclhttpd as well, which can be done reasonably, too.

 load lpttcl
 set run_display 1
 proc disnum { {n} } {
   # the numbers 0-9 in the coding for how I connected up the segments to the bits
   set dis {192 252 146 152 172 137 129 220 128 136}
   set a [string index $n end-2]
   set b [string index $n end-1]
   set c [string index $n end]

   # 'open' our control register
   lpt_wrctrl 0
   # select the rightmost display unit to become active
   lpt_wrdata 32
   # 'open' the display channel(s)
   lpt_wrctrl 1
   # figure out but pattern for the rightmost digit
   if {$c=={}} { set o 255 } { set o [lindex $dis $c] }
   # And write it to the display memory
   lpt_wrdata $o

   lpt_wrctrl 0
   lpt_wrdata 64
   lpt_wrctrl 1
   if {$b=={}} { set o 255 } { set o [lindex $dis $b] }
   lpt_wrdata $o

   lpt_wrctrl 0
   lpt_wrdata 128
   lpt_wrctrl 1
   if {$a=={}} { set o 255 } { set o [lindex $dis $a] }
   lpt_wrdata $o
 # now let an update happen every 2 seconds
 proc show_hits {{t 2000}} {
   global run_display ::counter::T-urlhits

   disnum ${::counter::T-urlhits(N)}

   if {$run_display > 0} {after $t "show_hits $t"}

 # do it

I might these days (wrote this Dec 1 2003) leave the counter on a webcam during nights (Amsterdam time zone) if you want to check it out working 'live':   use 'open Url' in windows media player
 mms://    address for mplayer

I might want to make a blinking second dot as well, to see the server process is active.

The picture above is an actual digital photograph of the working display, except I would need more digits (only the lowest 3 significant are shown)...