]> mj.ucw.cz Git - home-hw.git/blob - ir-probe/decode-klima
Auto: Meditation mode turned off
[home-hw.git] / ir-probe / decode-klima
1 #!/usr/bin/perl
2 use common::sense;
3
4 my %types;
5
6 while (<>) {
7         chomp;
8         my ($button, $timings) = split /\t/;
9         my @timings = split /\s+/, $timings;
10         pop @timings;
11         my $bit = 1;
12         my @out = ();
13         for my $t (@timings) {
14                 my $out = "<$bit:$t>";
15                 if ($bit) {
16                         if ($t >= 9000 && $t <= 9100) {
17                                 $out = "^";
18                         } elsif ($t >= 580 && $t <= 680) {
19                                 $out = "*";
20                         }
21                 } else {
22                         if ($t >= 4400 && $t <= 4500) {
23                                 $out = "#";
24                         } elsif ($t >= 450 && $t <= 550) {
25                                 $out = "A";
26                         } elsif ($t >= 1500 && $t <= 1700) {
27                                 $out = "B";
28                         }
29                 }
30                 $bit = 1 - $bit;
31                 push @out, $out;
32                 push @{$types{$out}}, $t;
33         }
34         print $button, "\t", join("", @out), "\n";
35 }
36
37 print "\n# Median timings [μs]\n\n";
38 for my $k (sort keys %types) {
39         my @v = sort @{$types{$k}};
40         print "$k\t", $v[@v/2], "\n";
41 }