From: Martin Mares Date: Wed, 10 Jul 2019 08:15:05 +0000 (+0200) Subject: ir-remote X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=fd1245f652ddae7123a2872cfd1251d5c25263fb;p=home-hw.git ir-remote --- diff --git a/ir-remote/Makefile b/ir-remote/Makefile new file mode 100644 index 0000000..6c8a968 --- /dev/null +++ b/ir-remote/Makefile @@ -0,0 +1,8 @@ +PC := pkg-config +UCW_CFLAGS := $(shell $(PC) --cflags libucw) +UCW_LDFLAGS := $(shell $(PC) --libs libucw) + +CFLAGS=-std=gnu99 -Wall -Wextra -Wno-parentheses $(UCW_CFLAGS) +LDFLAGS=$(UCW_LDFLAGS) + +all: decode diff --git a/ir-remote/decode.c b/ir-remote/decode.c new file mode 100644 index 0000000..1abe049 --- /dev/null +++ b/ir-remote/decode.c @@ -0,0 +1,55 @@ +#include +#include +#include + +#include + +int main(void) +{ + struct fastbuf *f = bfdopen_shared(0, 4096); + + byte hdr[48]; + breadb(f, hdr, sizeof(hdr)); + + uint i = 0; + int last = -1; + uint lasti = 0; + for (;;) { + byte x[2]; + if (!bread(f, x, 2)) + break; + int a = (s16) get_u16_le(x); + int boo = (a >= 8000); + if (boo != last) { + if (last >= 0) { + uint len = i - lasti; +#if 0 + printf("%d\t%d\t%6.3f\n", last, len, (double)len / 44100 * 1000); +#else + if (!last) { + if (len > 2000) { + putchar('\n'); + } else if (len >= 26 && len <= 32) { + } else { + printf("<%d>", len); + } + } else { + if (len >= 18 && len <= 24) { + putchar('0'); + } else if (len >= 68 && len <= 72) { + putchar('1'); + } else if (len >= 194 && len <= 200) { + putchar('^'); + } else { + printf("[%d]", len); + } + } +#endif + } + last = boo; + lasti = i; + } + i++; + } + putchar('\n'); +}