|
The only thing missing for me on OE on a NanoPI-M1 (identical to the OPi One) was being able to wake up the board with the IR remote (a brandless one I bought on Ebay). The procedure I used to set it up was as follows:
1. Setup lirc as indicated on the FAQ. Make sure you set up the POWER button on your remote to the KEY_SLEEP code.
2. At this point you should be able to put the board to sleep using the POWER button on the remote, but will need to press the K1 button on the board to wake it up.
3. Power off the board and put the SD card on your work computer. I'm using Kubuntu on it but anything Linux will do (not sure the FEX tools needed are available for Windows).
4. The SD card has two partitions on it; one 512 MB (system) and another larger one (OE data). Mount both on your system; on mine they show up under /media/<username>/<id>.
5. Open your lircd.conf file at /media/<username>/<id of larger partition>/.config. This is an excerpt of mime:
- begin remote
- name /storage/.config/lircd.conf
- bits 16
- flags SPACE_ENC|CONST_LENGTH
- eps 30
- aeps 100
- header 9032 4520
- one 546 1709
- zero 546 583
- ptrail 546
- repeat 9032 2266
- pre_data_bits 16
- pre_data 0x205D
- gap 141638
- toggle_bit_mask 0x0
- begin codes
- KEY_SLEEP 0x38C7
Copy code
6. It was reported that the ARISC firmware only recognizes NEC encoding from the remote. Assuming that, you must generate the correct values, as expressed in NEC encoding, to put on the script.bin file so that the POWER key can be decoded by the ARISC processor built-in to the H3. A NEC-encoded button press has the following format:
- a 9ms leading pulse burst (16 times the pulse burst length used for a logical data bit)
- the 8-bit address for the receiving device (A1)
- the 8-bit logical inverse of the address (A2)
- the 8-bit logical inverse of the command (B2)
- a final 562.5µs pulse burst to signify the end of message transmission.
- Logical '0' – a 562.5µs pulse burst followed by a 562.5µs space, with a total transmit time of 1.125ms
- Logical '1' – a 562.5µs pulse burst followed by a 1.6875ms space, with a total transmit time of 2.25ms
The values A2 and B2 should be the logical inversion (0->1, 1->0) of A1 and B1, respectively, but most remotes use both A1 and A2 to differentiate model and make.
7. Looking at the values on lircd.conf you may notice that the 'header', 'one' and 'zero' keys have values that approximately match the NEC encoding; 'header' is the 9ms leading pulse + the 4.5ms space and 'one' and 'zero' also match the symbols for 0 and 1. If that's the case the remote is compatible enough to the NEC encoding to use.
8. Now convert your 'script.bin' file to textual representation with this:
- bin2fex /media/<username>/<id of 512MB partition>/script.bin ~/script.fex
Copy code
9. Open the 'script.fex' file and look for a line with '[s_cir0]'. Below it you'll find several pairs 'ir_power_key_code<order> = X' and 'ir_addr_code<order> = Y', being 'order' consecutive numbers starting from 0 and X/Y being the codes as seen by the ARISC firmware. But those codes are bit-reversed in regards to the lirc definitions. So Y is the same as 'pre_data' but bit-reversed' like this:
pre_data = 0x205D = 0010 0000 0101 1101 => (bit-reversed) => 1011 1010 0000 0100 = 0xBA04 = Y
Given that the key code is sent as a code and its logical inversion you'll notice that the code for the POWER key is composed of one byte (0x38) and its inverse (0xC7). So X should be the bit-reversal of the top 8 bits of the word like this:
KEY_SLEEP = 0x38C7 => code = 0x38 = 0011 1000 => (bit-reversed) => 0001 1100 = 0x1C = X
10. Add those codes to the [s_cir0] section, either by adding a new pair (make sure the order is consecutive and without duplicate numbers) or by just removing all existing pairs and adding this new one. I did it the second way and ended up with a section like this:
- [s_cir0]
- ir_used = 1
- ir_rx = port:PL11<2><1><default><default>
- ir_power_key_code0 = 0x1C
- ir_addr_code0 = 0xBA04
Copy code
11. Now convert the FEX file back using this:
- fex2bin ~/script.fex /media/<username>/<id of 512MB partition>/script.bin
Copy code
12. Un-mount the partitions, put the SD card back on the board and enjoy.
NOTE: If your lircd.conf file has the same values as mine on the 'bits' and 'pre_data_bits' you can follow the procedure above. If not you'll have to adapt it knowing that lirc records the bitstream frame from the remote like this:
<header> <plead> <pre_data> <pre> <data> <post> <post_data> <ptrail> <foot> <gap>
The default value (if missing from lircd.conf) for these keys is 0 and while 'pre_data' and 'post_data' are actual values from the bitstream the rest of the keys are durations in uS. As long as the values for 'header', 'one' and 'zero' are similar to mine it should be just question of finding out how to map the actual frame from the remote as detailed on lircd.conf into a NEC encoding as explained above.
|
|