# example usage:
#
#   use lc20;
#   start();
#   adddot(0);
#   adddot(1);
#   adddot(0);
#   adddot(1);
#   adddot(0);
#   adddot(1); # and so on
#   stop();
#

my $device       = "/dev/plp";  # Parallel port device the lc-20 is attached to

my $escape       = chr(27);
my $devicehandle = 0;
my $buffer       = ();
my $bufferhandle = 0;

sub start {

  open $devicehandle,">$device" || die "Couldn't open $device for writing";

  print $devicehandle $escape."t".chr(0); # Standard mode (overrides 
DIP switch 2-1)
  print $devicehandle $escape."A".chr(1); # Set 1/72 inch linefeed

}

sub adddot {

  $buffer[$bufferhandle] = $_[0];
  $bufferhandle++;

  if ($bufferhandle > 479) {
   sendbuffer();
  }

}