From 446ab81da2e70ea02e607418b74b1286546bd37a Mon Sep 17 00:00:00 2001 From: dakkar Date: Mon, 8 Oct 2012 12:49:20 +0100 Subject: usb-ir-toy --- additions/SW/usb-ir-toy-lirc/JessH.patch | 44 +++++++++++ additions/SW/usb-ir-toy-lirc/lircrc | 90 ++++++++++++++++++++++ additions/SW/usb-ir-toy-lirc/send | 33 +++++++++ src/SW/usb-ir-toy-lirc/.gitignore | 2 + src/SW/usb-ir-toy-lirc/document.en.rest.txt | 108 +++++++++++++++++++++++++++ src/SW/usb-ir-toy-lirc/document.it.rest.txt | 111 ++++++++++++++++++++++++++++ src/SW/usb-ir-toy-lirc/du2html.xsl | 1 + 7 files changed, 389 insertions(+) create mode 100644 additions/SW/usb-ir-toy-lirc/JessH.patch create mode 100644 additions/SW/usb-ir-toy-lirc/lircrc create mode 100644 additions/SW/usb-ir-toy-lirc/send create mode 100644 src/SW/usb-ir-toy-lirc/.gitignore create mode 100644 src/SW/usb-ir-toy-lirc/document.en.rest.txt create mode 100644 src/SW/usb-ir-toy-lirc/document.it.rest.txt create mode 120000 src/SW/usb-ir-toy-lirc/du2html.xsl diff --git a/additions/SW/usb-ir-toy-lirc/JessH.patch b/additions/SW/usb-ir-toy-lirc/JessH.patch new file mode 100644 index 0000000..798314b --- /dev/null +++ b/additions/SW/usb-ir-toy-lirc/JessH.patch @@ -0,0 +1,44 @@ +Index: pic_bootloader.cpp +=================================================================== +--- pic_bootloader.cpp (revision 2023) ++++ pic_bootloader.cpp (working copy) +@@ -187,7 +187,7 @@ + switch (memory) + { + case MEM_FLASH: +- return 2; ++ return 32; + case MEM_EEPROM: + return 8; + case MEM_ID: +@@ -215,11 +215,17 @@ + { + show_progress(OP_ERASING, type(), memory, 0); + open(params); +- // erase 0x800-0x4000 //!!! 18f24j50 change ++ // erase 0x800-0x4000 + command.erase_flash.echo = ++command_id; + command.erase_flash.addr_hi = 0x08; + command.erase_flash.addr_lo = 0x00; +- command.erase_flash.size_x64 = 0x0D; ++ command.erase_flash.size_x64 = 0xE0; ++ transaction(&command, &response); ++ // erase 0x4000-0x6000 ++ command.erase_flash.echo = ++command_id; ++ command.erase_flash.addr_hi = 0x40; ++ command.erase_flash.addr_lo = 0x00; ++ command.erase_flash.size_x64 = 0x80; + transaction(&command, &response); + close(); + show_progress(OP_ERASING, type(), memory, OPERATION_DONE); +@@ -379,9 +385,8 @@ + command.write_flash.echo = ++command_id; + command.write_flash.addr_hi = (unsigned char)((address >> 8) & 0xFF); + command.write_flash.addr_lo = (unsigned char)(address & 0xFF); +- command.write_flash.flush = (unsigned char) 0xff; + // size must be 8 dividable +- //eAssert(size % 8 == 0); ++ eAssert(size % 8 == 0); + command.write_flash.size8 = size; + transaction(&command, &response); + show_progress(OP_PROGRAMMING, type(), memory, buffer->progress()); diff --git a/additions/SW/usb-ir-toy-lirc/lircrc b/additions/SW/usb-ir-toy-lirc/lircrc new file mode 100644 index 0000000..51c93db --- /dev/null +++ b/additions/SW/usb-ir-toy-lirc/lircrc @@ -0,0 +1,90 @@ +begin + prog=vlc + button=b1_push + config=key-play-pause +end +begin + prog=vlc + button=b1_pull + config=key-stop +end +begin + prog=vlc + button=b1_rot_cw + config=key-vol-up +end +begin + prog=vlc + button=b1_rot_ccw + config=key-vol-down +end +begin + prog=vlc + button=b1_press_back + config=key-toggle-fullscreen +end +begin + prog=vlc + button=b1_move_left + config=key-jump-medium +end +begin + prog=vlc + button=b1_move_right + config=key-jump+medium +end +begin + prog=vlc + button=b1_tap_left + config=key-chapter-prev +end +begin + prog=vlc + button=b1_tap_right + config=key-chapter-next +end +begin + prog=vlc + button=b2_move_up + config=key-nav-up +end +begin + prog=vlc + button=b2_move_left + config=key-nav-left +end +begin + prog=vlc + button=b2_move_right + config=key-nav-right +end +begin + prog=vlc + button=b2_move_down + config=key-nav-down +end +begin + prog=vlc + button=b2_push + config=key-nav-activate +end +begin + prog=vlc + button=b2_tap_left + config=key-audio-track +end +begin + prog=vlc + button=b2_tap_right + config=key-audio-track +end +begin + prog=vlc + button=b2_tap_top + config=key-subtitle-track +end +begin + prog=vlc + button=b2_tap_bottom + config=key-subtitle-track +end diff --git a/additions/SW/usb-ir-toy-lirc/send b/additions/SW/usb-ir-toy-lirc/send new file mode 100644 index 0000000..f0f7a1e --- /dev/null +++ b/additions/SW/usb-ir-toy-lirc/send @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.016; +use Time::HiRes 'sleep'; + +my @cmds; + +open my $fh,'<','/etc/lirc/lircd.conf'; +while (my $line=<$fh>) { + $line =~ m{^\s+(b[123]\w+)} or next; + push @cmds,$1; +} + +while (@cmds) { + my $current = shift @cmds; + say "Ready to send $current"; + my $ans=<>; + if ($ans =~ m{^a}) { + unshift @cmds,$current; + $current=pop @cmds; + unshift @cmds,$current; + redo; + } + elsif ($ans =~ m{^n}) { + push @cmds,$current; + next; + } + system('irsend','SEND_START','sonic',$current); + sleep 0.8; + system('irsend','SEND_STOP','sonic',''); + push @cmds,$current; +} diff --git a/src/SW/usb-ir-toy-lirc/.gitignore b/src/SW/usb-ir-toy-lirc/.gitignore new file mode 100644 index 0000000..08d33d4 --- /dev/null +++ b/src/SW/usb-ir-toy-lirc/.gitignore @@ -0,0 +1,2 @@ +/document.en.du.xml +/document.it.du.xml diff --git a/src/SW/usb-ir-toy-lirc/document.en.rest.txt b/src/SW/usb-ir-toy-lirc/document.en.rest.txt new file mode 100644 index 0000000..9f7169e --- /dev/null +++ b/src/SW/usb-ir-toy-lirc/document.en.rest.txt @@ -0,0 +1,108 @@ +============================== +Using the USB IR Toy with LIRC +============================== +:CreationDate: 2012-10-08 10:49:07 +:Id: SW/usb-ir-toy-lirc +:tags: - software + - configs + +So I got myself a `programmable remote control in the shape of Eleven's +sonic screwdriver `_ (sorry, +horrible in-accessible website). Of course I want to control my PC +with it! + +To do that, I needed a IR receiver and `LIRC +`_. Since I sometimes like being overly generic, +I bought `Dangerous Prototypes `_ +`USB Infrared Toy +`_, which allows +me to send & receive any kind of IR pulse stream. + +Getting the three pieces (remote, toy, LIRC) to play together was more +effort than I'd really liked, so here's what I did, to help everybody +else. + +Flash a newer firmware +====================== + +Your IR Toy is probably running an old version of the firmware. If +you're running Windows, the `instructions provided +`_ may +work; otherwise, you have to dig deeper. The source code for the +``fw_update`` program that you can get from those pages (or from `the +Subversion repository +`_) +does not even compile (it "forgets" to include half the header files +it needs), and when you get it to compile it segfaults. User +"JessH" of the Dangerous Prototypes forums `posted a working version +`_ +(`here's the patch `_ if you want to see it, it should +apply to the SVN version). + +.. note:: + + Yes, I know I'm pointing at the updater source for the 18F24J50, but + the chip on the actual IR Toy says "18F2550". What can I say, it + works! + +Having compiled it, I was able to update the firmware to version 22:: + + $ echo '$' > /dev/ttyACM0 + $ ./fw_update -e -w -v -m all -vid 0x04D8 -pid 0xFD0B \ + -ix ~/src/dangerous-prototypes-open-hardware/USB_IR_Toy/package/firmware/USBIRToy.v22.hex + +Unplug, re-plug, and we're set. + +Patching LIRC +============= + +LIRC can use the IR Toy in ``irman`` compatibility mode, but I needed +full send capability, to program the sonic screwdriver. I found `a +patch to add full support +`_, +thanks to Peter Kooiman. If you're running Gentoo, you can add `my +overlay `_ and +install `my patched LIRC +`_. + +Configuring LIRC +================ + +This may well be written down somewhere, but I had problems finding a +useful guide, so I'll just show what I did: + +1) get a full Philips RC-5 code list from `the LIRC remotes repository + `_ + +2) assign, arbitrarily, the first 39 codes to the 13 gestures on 3 + memory banks of the screwdriver:: + + begin remote + name sonic + # snip + begin codes + b1_tap_top 0x1000 + b1_tap_left 0x1001 + #etc etc + +Programming the remote +====================== + +I wrote `a simple Perl program to send the IR codes `_. Run it +with ``lircd`` running and ``irsend`` in your path. When it say +``Ready to send $something``, press "enter" to send it, ``a`` to go +back to the previous code (useful if the screwdriver didn't get it), +``n`` to go the next code without sending anything. + +I put the screwdriver in programming mode, performed all 39 gestures +one after the other, and programmed all of them. LIRC now uses +sensible names for the 39 gestures. + +Using it +======== + +Finally, I re-compiled `vlc `_ with LIRC +support, and wrote `a |lircrc| for vlc `_. With that, I can +control ``vlc`` with my sonic screwdriver! + +.. |lircrc| replace:: ``~/.lircrc`` diff --git a/src/SW/usb-ir-toy-lirc/document.it.rest.txt b/src/SW/usb-ir-toy-lirc/document.it.rest.txt new file mode 100644 index 0000000..953bd22 --- /dev/null +++ b/src/SW/usb-ir-toy-lirc/document.it.rest.txt @@ -0,0 +1,111 @@ +================================= +Come usare lo USB IR Toy con LIRC +================================= +:CreationDate: 2012-10-08 10:49:07 +:Id: SW/usb-ir-toy-lirc +:tags: - software + - configs + +Mi son comprato un `telecomando universale a forma di cacciavite +sonico `_ (il sito è orrendo e +difficile da navigare…). Chiaramente voglio poterci controllare il mio +PC! + +Per farlo, mi serviva un ricevitore IR e `LIRC +`_. Visto che mi piace complicarmi la vita, ho +comprato lo `USB Infrared Toy +`_ da `Dangerous +Prototypes `_, che permette di +inviare e ricevere qualsiasi sequenza di impulsi a infrarossi. + +Convincere i tre pezzi (telecomando, Toy, LIRC) a funzionare assieme è +stato più complicato di quel che avrei gradito, per cui descrivo qua +quel che ho fatto, per aiutare i prossimi. + +Aggiornare il firmware +====================== + +Il vostro IR Top ha probabilmente una versione vecchia del +firmware. Se usate Windows, le `instruzioni fornite +`_ +potrebbero anche funzionare; altrimenti, bisogna studiarci un po'. I +sorgenti del programma ``fw_update`` che potete ottenere da quelle +pagine (o dal `repository Subversion +`_) +non compilano neppure (si sono "scordati" di includere metà degli +header che servono), e quando riuscite a compilarli, vanno in +segfault. L'utente "JessH" dei forum di Dangerous Prototypes `ha +postato una versione che funziona +`_ +(`questa è la patch `_ se la volete vedere, dovrebbe +applicarsi alla versione SVN). + +.. note:: + + Sì, lo so che sto puntando ai sorgenti per il 18F24J50, ma il chip + sul IR Toy dice "18F2550". Che ci posso fare, così funziona! + +Dopo averlo compilato, sono finalmente riuscito ad aggiornare il +firmware alla versione 22:: + + $ echo '$' > /dev/ttyACM0 + $ ./fw_update -e -w -v -m all -vid 0x04D8 -pid 0xFD0B \ + -ix ~/src/dangerous-prototypes-open-hardware/USB_IR_Toy/package/firmware/USBIRToy.v22.hex + +Stacca, ri-attacca, e siamo pronti. + +Patch per LIRC +============== + +LIRC può usare lo IR Toy in modalità compatibile ``irman``, ma a me +serviva la funzione completa di invio segnali, per programmare il +cacciavite. Ho trovato `una patch per aggiungere il supporto completo +`_, +grazie a Peter Kooiman. Se usate Gentoo, potete aggiungere `la mia +overlay `_ e +installare `LIRC già modificato +`_. + +Configurare LIRC +================ + +Questo dovrebbe essere scritto da qualche parte, ma non sono riuscito +a trovare usa spiegazione usabile, per cui mostro quel che ho fatto: + +1) mi son procurato un set completo di codici Philips RC-5 dal + `repository di telecomandi LIRC + `_ + +2) ho assegnato, arbitrariamente, i primi 39 codici ai 13 gesti su 3 + banchi di memoria del cacciavite:: + + begin remote + name sonic + # snip + begin codes + b1_tap_top 0x1000 + b1_tap_left 0x1001 + #etc etc + +Programmare il telecomando +========================== + +Ho scritto `un semplice programma Perl per inviare i codici IR +`_. Eseguitelo mentre ``lircd`` è in esecuzione, e con +``irsend`` nel path. Quando dice ``Ready to send $something``, premete +"enter" per inviare il codice, ``a`` per tornare al codice precedente +(utile se il cacciavite non l'ha ricevuto), ``n`` per saltare al +codice successivo senza inviare nulla. + +Ho messo il cacciavite in modalità programmazione, ho eseguito i 39 +gesti uno alla volta, e li ho programmati tutti. LIRC ora usa nomi +sensati per tutti e 39 i gesti. + +Usarlo +====== + +Finalmente, ho ri-compilato `vlc `_ col +supporto LIRC, e ho scritto `un |lircrc| per vlc `_. A questo +punto, posso controllare ``vlc`` col cacciavite sonico! + +.. |lircrc| replace:: ``~/.lircrc`` diff --git a/src/SW/usb-ir-toy-lirc/du2html.xsl b/src/SW/usb-ir-toy-lirc/du2html.xsl new file mode 120000 index 0000000..e2487e0 --- /dev/null +++ b/src/SW/usb-ir-toy-lirc/du2html.xsl @@ -0,0 +1 @@ +../../../templates/du2html.xsl \ No newline at end of file -- cgit v1.2.3