BlueWave Studio forum
Controller service - Printable Version

+- BlueWave Studio forum (https://bluewavestudio.io/community)
+-- Forum: OpenAuto Pro (https://bluewavestudio.io/community/forum-86.html)
+--- Forum: Documentation, User Manuals (https://bluewavestudio.io/community/forum-104.html)
+--- Thread: Controller service (/thread-2208.html)



Controller service - BlueWave - 11-21-2020

Controller service is a service that translates input from various devices (like rotary encoders, MMI 2G panel, GPIO pins, etc.) to the key strokes. One controller service instance can handle one input device at a time. It is possible to run many instances of controller service. First (and the only) argument of controller service is a path to the configuration file.

Example command for controller service execution:
controller_service /home/pi/.openauto/config/openauto_controller_service.ini

Using /etc/xdg/lxsession/LXDE-pi/autostart file you can start instances of controller service automatically after startup of the system. Below please find configuration of the controller service for particular input device:



RE: Controller service - BlueWave - 11-21-2020

Rotary encoder:
[Controller]
; Type of the input device
; 1 - Audi MMI 2G panel
; 2 - BMW iDrive Gen 1 controller
; 3 - BMW IBUS
; 4 - Audi RNSE
; 5 - Rotary Encoder
; 6 - GPIO
; 7 - ResistiveButtons
Type=5

[RotaryEncoder]
; GPIO pin number connected to the SIA/DT pin of the encoder
; For most rotary encoders you can control direction of the rotation by swapping SIA/DT abd SIB/CLK pins.
SiaPinNumber=16

; GPIO pin number connected to the the SIB/CLK pin of the encoder
; For most rotary encoders you can control direction of the rotation by swapping SIB/CLK and SIA/DT pins.
SibPinNumber=20

; GPIO pin number connected to the the SW pin of the encoder
SwPinNumber=21

; Key stroke that will be simulated after detection of left rotation
LeftKeyStrokes=V

; Key stroke that will be simulated after detection of right rotation
RightKeyStrokes=N

; Key stroke that will be simulated after detection of knob press/release
SwitchKeyStrokes=B


Example of media knob configuration:
[Controller]
Type=5

[RotaryEncoder]
SiaPinNumber=16
SibPinNumber=20
SwPinNumber=21
LeftKeyStrokes=V
RightKeyStrokes=N
SwitchKeyStrokes=B

Example of volume knob configuration:
[Controller]
Type=5

[RotaryEncoder]
SiaPinNumber=25
SibPinNumber=24
SwPinNumber=12
LeftKeyStrokes=F7
RightKeyStrokes=F8
SwitchKeyStrokes=Ctrl+F11



RE: Controller service - BlueWave - 11-21-2020

GPIO:
[Controller]
; Type of the input device
; 1 - Audi MMI 2G panel
; 2 - BMW iDrive Gen 1 controller
; 3 - BMW IBUS
; 4 - Audi RNSE
; 5 - Rotary Encoder
; 6 - GPIO
; 7 - ResistiveButtons
Type=6

; Transition from LOW to HIGH state simulates key press, transition from HIGH to LOW state simulates key release.
[GpioButtons]
; Number of configured GPIO pins
Count=3

; Number of 1st GPIO pin
Button_0_Pin=22

; Key stroke to simulate for 1st GPIO pin
Button_0_Key=F8

; Number of 2nd GPIO pin
Button_1_Pin=23

; Key stroke to simulate for 2nd GPIO pin
Button_1_Key=F7

; Number of 3rd GPIO pin
Button_2_Pin=16

; Key stroke to simulate for 3rd GPIO pin
Button_2_Key=N



RE: Controller service - BlueWave - 11-21-2020

Audi MMI 2G panel:
[Controller]
; Type of the input device
; 1 - Audi MMI 2G panel
; 2 - BMW iDrive Gen 1 controller
; 3 - BMW IBUS
; 4 - Audi RNSE
; 5 - Rotary Encoder
; 6 - GPIO
; 7 - ResistiveButtons
Type=1

; Path to the descriptor of MAX3232 device connected to the MMI 2G panel and Raspberry PI.
Interface=/dev/ttyS0

; Duration in milliseconds between two presses of the button on the  MMI 2G panel. 0 disables double press feature.
;
; List of buttons on the panel with double press actions:
;
; Right Up button - [Show/Hide OpenAuto Pro Top Bar]
; Right Down button - [Mode - switch between active applications, OpenAuto Pro and active Projection (Android Auto or Mirroring)]
; Left Up button - [Back]
; Left Down button - [Bring OpenAuto Pro to front]
DoublePressSpeed=200

; Code of the button that will trigger sending a message to LVDS adapter for switching video source
; Button codes: NAME - 0x03, NAVI - 0x05, INFO - 0x06
VideoSwitch=0x05

; Code of the button used by LVDS adapter to switch video source
; Button codes: NAME - 0x03, NAVI - 0x05, INFO - 0x06
AdapterVideoSwitch=0x05



RE: Controller service - BlueWave - 11-21-2020

BMW iDrive Gen 1 controller:
[Controller]
; Type of the input device
; 1 - Audi MMI 2G panel
; 2 - BMW iDrive Gen 1 controller
; 3 - BMW IBUS
; 4 - Audi RNSE
; 5 - Rotary Encoder
; 6 - GPIO
; 7 - ResistiveButtons
Type=2

; CAN interface connected to the iDrive Gen 1 controller (e.g. via MCP2515 device)
Interface=can0

; Duration in milliseconds between two presses of the iDrive controller knob in left, right, up or down direction. 0 disables double press feature.
;
; List of double press actions:
;
; Right - [Mode - switch between active applications, OpenAuto Pro and active Projection (Android Auto or Mirroring)]
; Left - [Back]
; Up - [Show/Hide OpenAuto Pro Top Bar]
; Down - [Bring OpenAuto Pro to front]
DoublePressSpeed=200

[IDriveGen1]
; Orientation in degrees of the iDrive Gen 1 controller. Possible values are 0, 90, 180, 270.
Angle=0

; true - Enable standalone mode of the controller; false - listen controller connected to the CIC/CCC BMW head unit.
Polling=true

; Period in milliseconds of querying the iDrive Gen1 controller (standalone mode).
PollTimeout=100

; Timeout in milliseconds for response from the iDrive Gen 1 controller (standalone mode). Exceeding this timeout terminates the controller service.
ControllerTimeout=1000



RE: Controller service - BlueWave - 11-21-2020

BMW I-BUS:
[Controller]
; Type of the input device
; 1 - Audi MMI 2G panel
; 2 - BMW iDrive Gen 1 controller
; 3 - BMW IBUS
; 4 - Audi RNSE
; 5 - Rotary Encoder
; 6 - GPIO
; 7 - ResistiveButtons
Type=3

; List of supported steering wheel keys:
;
; Next track
; Previous track
; Volume up
; Volume down
; Answer phone call
; R/T - it will trigger Google Assistant
;
; Path to the "IBUS to UART" device descriptor (e.g. Melexis TH3122).
Interface=/dev/ttyS0

[IBus]
; true - control volume of OpenAuto Pro application using volume buttons of the steering wheel; false - do nothing when volume buttons of the steering wheels were pressed/released.
VolumeControlsEnabled=false



RE: Controller service - BlueWave - 11-21-2020

Audi RNSE:
[Controller]
; Type of the input device
; 1 - Audi MMI 2G panel
; 2 - BMW iDrive Gen 1 controller
; 3 - BMW IBUS
; 4 - Audi RNSE
; 5 - Rotary Encoder
; 6 - GPIO
; 7 - ResistiveButtons
Type=4

; List of supported Audi RNSE buttons:
;
; Setup button - Toggle play
; Return button - Back
; Knob press - Enter
; Knob right - Scroll right
; Knob left - Scroll left
; Previous track button - Previous track
; Next track button - Next track
; Left Up button - Up
; Left Down button - Down
;
; CAN interface connected to the Audi RNSE head unit (e.g. via MCP2515 device)
Interface=can0



RE: Controller service - BlueWave - 10-31-2021

Resistive buttons:
[Controller]
; Type of the input device
; 1 - Audi MMI 2G panel
; 2 - BMW iDrive Gen 1 controller
; 3 - BMW IBUS
; 4 - Audi RNSE
; 5 - Rotary Encoder
; 6 - GPIO
; 7 - ResistiveButtons
Type=7

; Interface of the ADS11x5 converter
Interface=/dev/i2c-1

[ResistiveButtons]
; Type of the ADS converter
; 0 - ads1105; 1 - ads1115
AdsType=1

; Gain of the ADS converter
; 0 - Twothirds (6.144V);  1 -  One (4.096V); 2 - Two (2.048V); 3 - Four (1.024V); 4 - Eight (0.512V); 5 - Sixteen (0.256V)
AdsGain=0

; Sleep duration [ms] after each conversion (read) of the ads11x5 converter
AdsSleepTime=10

; Count of configured buttons
Count=2

; Configuration of first button
; Channel from which value of the button should be read
; 0 - A0; 1 - A1; 2 - A2; 3 - A3
Button_0_Channel=1

; Minimum value to consider button as pressed
Button_0_Min=8965

; Maximum value to consider button as pressed
Button_0_Max=9025

; Key stroke to trigger after detection of button press
Button_0_Key=Ctrl+F11

; Configuration of second button
Button_1_Channel=1
Button_1_Min=16795
Button_1_Max=16855
Button_1_Key=p

ads11x5reader utility:
If you do not know what values your resistive buttons have, there is the ads11x5reader command-line tool created for such purpose. It will constantly print out to the console current value read from the desired channel of ads11x5 converter. You can then figure out minimum and maximum value of pressed button and put them to the config file.
Quote:ads11x5reader available options:
  --help                        display help message
  --descriptor arg (=/dev/i2c-1) descriptor of ads converter
  --gain arg (=0)                set gain of ads converter
  --type arg (=0)                ads converter type; 0 - ads1105, 1 - ads1115
  --channel arg (=0)            channel of ads converter to read