Skip to content

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
muzy committed Jul 25, 2011
1 parent b99a519 commit ec20dd3
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lcdtool

simple tool to get my lcd display to show what I want it to show ;-)
6 changes: 6 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#lcdtool config
name=PP
screen_name=info
heartbeat=off
host=127.0.0.1
port=13666
62 changes: 62 additions & 0 deletions lcdtool.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env perl
use strict;
use warnings;

use AnyEvent;
use AnyEvent::Handle;
use AnyEvent::Socket;
use Config::Tiny;
use Data::Dumper;
use IO::LCDproc;

my $config = Config::Tiny->read('config.ini');

my @lines;

my $client = IO::LCDproc::Client->new(name => $config->{_}->{name});
my $screen = IO::LCDproc::Screen->new(name => $config->{_}->{screen_name}, heartbeat => $config->{_}->{heartbeat});
$lines[1] = IO::LCDproc::Widget->new(
name => "first", align => "center", xPos => 1, yPos => 1
);
$lines[2] = IO::LCDproc::Widget->new(
name => "second", align => "center", xPos => 1, yPos => 2
);

$client->add( $screen );
$screen->add( $lines[1] $lines[2] );
$client->connect() or die "cannot connect: $!";
$client->initialize();

tcp_server(
$config->{_}->{host},
$config->{_}->{port},
sub {
my ($fh, $host, $port) = @_;
if (not $fh) {
die "cannot create listener";
return;
}

my $handle;
$handle = AnyEvent::Handle->new(
fh => $fh,
on_eof => sub { undef $handle },
on_error => sub { undef $handle },
);

$handle->push_read(line => sub { announce(@_); });
}
);

sub announce {
my ($handle,$command) = @_;
my ($line,$message) = split(/:/,$command,1);
print Dumper $line;
print Dumper $message;
$client->flushAnswers();
}


#$first->set( data => "First Line" );
#$second->set( data => "1234567890" );
AnyEvent->condvar->wait();
6 changes: 6 additions & 0 deletions push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

IP="127.0.0.1"
PORT="23427"

echo "$@" | nc -q 1 $IP $PORT

0 comments on commit ec20dd3

Please sign in to comment.