]> www.fi.muni.cz Git - slotcarman.git/blobdiff - SCX/Reader.pm
Lap/time counting, car icon displaing.
[slotcarman.git] / SCX / Reader.pm
index e3431ad425ad40e66acd33832eb2e73ed097082a..873ffa058a09a451b217df87ed47196bd1efc37a 100644 (file)
@@ -226,7 +226,19 @@ sub lap_time_packet {
                || $bytes[4] & 0x01
                || $bytes[5] & 0x01;
 
-       return $msg; # FIXME - to be implemented
+       my $car = $bytes[0];
+       my $round = 256*$bytes[1] + $bytes[2]
+               + ($bytes[3] & 2 ? 256 : 0)
+               + ($bytes[3] & 1 ? 1 : 0);
+       my $time = 256*$bytes[4] + $bytes[5]
+               + ($bytes[3] & 8 ? 256 : 0)
+               + ($bytes[3] & 4 ? 1 : 0);
+       $time *= 0.01024;
+
+       $self->track->car($car)->set_lap($round);
+       $self->track->car($car)->set_laptime($time);
+
+       return $msg;
 }