#!/usr/bin/perl -w

use strict;
use utf8;

use Gtk2 '-init';
use Glib qw(TRUE FALSE);

use SCX::GUI;
use SCX::Track;
use SCX::Reader;

my $no_reader = 0;

my $gui = SCX::GUI->new;
my $track = SCX::Track->new({ gui => $gui });

if (!$no_reader) {
	my $reader = SCX::Reader->new({
		portname   => '/dev/ttyUSB0',
		logfile    => 'log',
		track      => $track,
	});

	Glib::IO->add_watch(fileno($reader->fh), 'in', \&scx_read, $reader);
}

$gui->show;

Gtk2->main();

exit 0;

sub quit {
	Gtk2->main_quit;
	return FALSE;
}

sub scx_read {
	my ($event, $reader) = @_;

	$reader->read();
	return TRUE;
}

