📜 ⬆️ ⬇️

Intervalometer from the phone: continued

Not so long ago, the user afan wrote an article describing the ability to control devices via IR using specially crafted audio files. It was then about the SONY NEX-5, for which the audio file was presented. I was interested in the method described in the article, but the RMT-DSC2 is used for my SONY H50, whereas for the NEX-5 it is the RMT-DSLR1, and, accordingly, the commands are different there. The article provided a link to the ledrem project, which contains a converter of LIRC configuration files to audio files. Actually, the transformation of sequences of commands in this article will be discussed.

The last change in the project ledrem dates back to August 2008, I noticed this after the converter program refused to work with the configuration file for my camera. There is an example of a file for a satellite tuner on the program’s website. Comparing it with modern LIRC command files, you can understand why that program refused to work. The presented utility for conversion is designed for converting RAW codes, whereas today the majority of configurations in the LIRC catalog are presented in a different format (more on this later). By the way, it is written on a very specific Rapid Q Basic.

So, the program does not work, but the desire to create some kind of intervalometer remains. Well, let's write our program using Adobe AIR as a platform for development, and as the main component of the program - what audio files write - all from SOX (Sound eXchange) used in the previous version. But first, you still need to figure out how the LIRC describes and "understands" the IR commands.
')

LIRC command structure



The file describing the IR signal sequences to be sent consists of two main parts: the first part describes the duration and composition of the IR shipment, the second one contains the RAW codes themselves or, more often, the hex format.

Main fields and their sequence





The pre_data and post_data fields are a sequence of pulses equivalent to a hexadecimal value in the corresponding field. Data is transferred in binary format; the pulse duration for zeros and ones is also indicated.
  one 100 200
 zero 120 400 

For the fields foot, header, pre, post, one, zero in the configuration file are indicated durations in the format
  [name] [on, microseconds] [off, microseconds]
 header 1940 200 

The remaining fields - ptrail and plead - are indicated only by the duration of the transfer.
  [name] [on, microseconds]
 ptrail 1342 

For hexadecimal parameters, the number of bits in which these parameters should be contained is determined.
  [bits, pre_data_bits, post_data_bits] [number of bits] 

If the code converted into a binary sequence will contain fewer bits than the one specified in the configuration, the remaining bits must be filled with zeros.

Configuration example for SONY H50:
 begin remote
   name Sony_RMT-DSC2
   bits 12

   .....

   header 2461 525
   one 1266 525
   zero 668 525
   post_data_bits 8
   post_data 0x8F
   gap 44752 
   min_repeat 4

This is what a part of the finished audio file will look like:



Why only a part? Because there is also min_repeat.

Command repetition



Some devices require the command to be repeated to perform an action. In order to support such devices, LIRC uses several more notation.

  min_repeat [number] 
Indicates the minimum required number of repetitions of a command for perception by its device.
  min_repeat 4 

  gap [off, microseconds] 
This value displays the length of the pause after sending ptrail. When repeating commands, necessary because of the min_repeat set value, determines the delay time before the second signal is transmitted.
  gap 44300 

In addition, a number of parameters are defined that are responsible for the long press of a key. In the case of conversion to audio files, such parameters are not as necessary as the main ones, so they will not be disassembled here.

Command transfer



For my Nokia 5800, the proposed transmission method did not fit due to the small amplitude of the output signal. A cursory review of devices found in the house with audio outputs revealed that not every device is capable of giving the desired signal level. For this reason, we had to assemble a small amplifier on the TDA7050 chip. The microcircuit is used in various players, radio, etc., as an amplifier for headphones. The inclusion scheme is extremely simple:



For the body was chosen a certain object, which was once a blinking two-color flashlight. The case has a compartment for batteries, a switch and a place under the LED, all that is needed in this case.

Between the LED and the microcircuit are soldered a resistor that limits the current of the LED, of 38 Ohms.

View of the resulting structure from the inside ...



... and outside:



Program



And finally, the converter program itself:



It works, as seen in the screenshot, using SoX (Linux users may not bother to search for the sox binary and simply write sox in the appropriate field). The folder for the results will end up with files like BTN_HOME.raw, BTN_HOME.wav, KEY_UP.raw, KEY_UP.wav, etc. When you click the Start button, writing to the cmd or sh file (depending on the OS) starts, You will have to start it yourself.

$ sh lirc2wav_temp.sh

To run from the program, of course, there is NativeProcessApi, but even with its use it will be quite difficult to get the same result as with manual start. Problems adds cross-platform.

Work tested in Windows and Linux, for Mac did not try.

Download the program here (requires Adobe Air version 2.0 and higher).

Related Links:

Source: https://habr.com/ru/post/126351/


All Articles