#!/usr/bin/perl -w # print out your LCD's charset to lcdproc # this program based upon examples/fortune.pl from the lcdproc distribution use IO::Socket; use Fcntl; # Host which runs lcdproc daemon (LCDd) $HOST = "localhost"; # Port on which LCDd listens to requests $PORT = "13666"; # Connect to the lcdproc server $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $HOST, PeerPort => $PORT, ) || die "Cannot connect to LCDproc port\n"; # Make sure our messages get there right away $remote->autoflush(1); sleep 1; # Give server plenty of time to notice us... print $remote "hello\n"; # Note: it's good practice to listen for a response after a print to the # server even if there isn't meant to be one. If you don't, you may find # your program crashes after running for a while when the buffers fill up: my $lcdresponse = <$remote>; # Turn off blocking mode... fcntl($remote, F_SETFL, O_NONBLOCK); # Set up some screen widgets... print $remote "client_set name {charmap.pl}\n"; $lcdresponse = <$remote>; print $remote "screen_add charmap\n"; $lcdresponse = <$remote>; print $remote "screen_set charmap name {charmap}\n"; $lcdresponse = <$remote>; print $remote "widget_add charmap title title\n"; $lcdresponse = <$remote>; print $remote "widget_set charmap title {charmap}\n"; $lcdresponse = <$remote>; print $remote "widget_add charmap text scroller\n"; $lcdresponse = <$remote>; for ($char=0; $char<=255; $char++) { $ascii = pack "C", $char; $text = "$char is $ascii"; # scroller format: left top right bottom direction speed text print $remote "widget_set charmap text 1 2 16 2 h 2 {$text}\n"; my $lcdresponse = <$remote>; sleep 1; } close ($remote) || die "close: $!"; exit;