JOY-IT RPI4 CASE MM IR Instructions

MULTIMEDIA CASE
for the Raspberry Pi 4
Expert manual
www.joy-it.net
Pascalstr. 8 47506 Neukirchen-Vluyn
1. TABLE OF CONTENTS
2. Usage with Raspberry Pi OS
2.1 Setting up the serial interface
2.2 IR-Receiver
2.2.1 learningMode
2.3 Shutdown script
2.4 RGB-LEDs
2.4.1 LED colour mode
2.4.2 Installation of Hyperion
2.5 Fan
2.6 Sowareupdates for the board
2.7 UART Control
3. Usage with Kodi 19 Matrix
3.1 Installation
3.2 Multimedia Case Configuration
3.3 Multimedia Case LED Configuration
3.4 HDMI CEC
3.5 IR Control Configuration
4. Further Information
5. Support
This is an expert manual and should only be used if you do want to use the Multimedia Case with another operating system or do
not want to use our prepared LibreElec image. The basic manual
can be found here.
i
www.joy-it.net
Pascalstr. 8 47506 Neukirchen-Vluyn
2. USAGE WITH RASPBERRY PI OS
The case has several functions, for example fan control and LED control,
which can be used in conjunction with the Raspberry Pi. In this chapter
you will find an exemplary application of these functions in Raspberry Pi OS and a more detailed explanation of the individual functions. For this purpose we oer you suitable code examples. You can download these code examples here and load them onto your Raspberry Pi using an SSH connection or you can enter the following command into the console of your Raspberry Pi:
sudo raspi-config
2.1 Setting up the serial interface
Using serial communication, the Raspberry Pi is able to communicate with the board of the multimedia case. This must be activated separately on the Raspberry Pi.
unzip /home/pi/MultimediaCase.zip && rm /home/pi/MultimediaCase.zip
wget https://joy-it.net/public/MultimediaCase.zip
If you have downloaded the sample codes, you must first unpack them with a command, and you can also remove the zip file in the same step. Please note, however, that the directory in which the file is located does
not necessarily have to match the directory of the command. The com-
mand is the following:
The serial interface is required for communication between the
Raspberry Pi and the board. In some scripts (
learningMode
and
shutdown-function
) a string is sent from the Raspberry Pi to the board depending on the script. There, this string is used to execute a program specific to the script.
i
To enable this serial port, type the following command in the console to access the settings:
There select
3 Interface Options → P6 Serial Port
.
www.joy-it.net
Pascalstr. 8 47506 Neukirchen-Vluyn
Now you are asked the question
Would you like a login shell to be
accessible over serial?
which should be declined.
The next question
Would you like the serial port hardware to be
enabled?
should be confirmed.
Exit the raspi-config configuration tool and do not restart your Raspberry Pi for now.
Add three lines in the
config.txt.
Open the file with the following
command:
sudo nano /boot/config.txt
Add the following three lines to the file at the end:
dtoverlay=pi3-miniuart-bt core_freq=250
Save the changes with CTRL + O and exit the editor with CTRL + X. Now restart the Raspberry Pi with the following command:
sudo reboot
www.joy-it.net
Pascalstr. 8 47506 Neukirchen-Vluyn
2.2 Infrared-Receiver
An infrared receiver is built into the case, which is positioned in the front
(opposite the connections). This allows, among other things, the control
by a remote control, for example to switch the Raspberry Pi on and o. This also allows you to operate without mouse and keyboard. The infra­red sensor TSOP4838 is connected to the GPIO 7.
2.2.1 learningMode The script
learningMode.py
is a program that allows to set up a PowerO button of any remote control. The PowerO button serves as a button that switches the Multimedia Case on and o. This can be any button on a separate remote control or an unassigned button of a remote control you are already using with another device.
IIn the script, the string \x0D X04 \x0D is sent from the Raspberry Pi to
the board of the multimedia case via serial communication (see 2.1). This
string puts the board into the so-called
learningMode
.
The
learningMode
is used to declare the PowerO button. In this mode you must press the desired button three times to set it. The LEDs will light up in dierent colors so that the
learningMode
can be recognized from
outside.
sudo python3 /home/pi/MultimediaCase/learningMode.py
You can run the
learningMode
with the following command:
Each time the button is pressed, the LEDs light up white to confirm that an infrared signal has been received. If you should press any other key, the LEDs light up red and the program resets. Then you have to press a key three times again. The LEDs will light up green when the PowerO button has been set suc­cessfully.
The
learningMode
can be executed as oen as desired, so the
PowerO button can be changed again.
i
www.joy-it.net
Pascalstr. 8 47506 Neukirchen-Vluyn
You get more information about the learningMode in relation to Kodi in
Chapter 3.1 Multimedia Case Configuration, which is declared using
this script.
2.3 Shutdown script
You can shut down the Raspberry Pi using the Multimedia Case's circuit board. You can do this with a PowerO button (see 2.2.1 learningMode) or with the button directly on the case. The shutdown script is needed to shut down the Raspberry Pi and not only to disconnect the power supp­ly. When the PowerO button or the button on the Multimedia Case is pres­sed, the Multimedia Case serially sends the string
xxxShutdownRaspberryPixxx\n\r to the Raspberry Pi. The following
script then interprets the string as a command. This command is sudo
sudo shutdown -h now and shuts down the Raspberry Pi.
Aer starting the Multimedia Case, a green pulsation of the RGB
LEDs indicates that the system is starting up - during this time the Raspberry Pi starts its operating system. The displayed pulsation is preset to a time of 30s in the Multimedia Case and then changes to a permanent green light, which signals rea­diness for operation. If the operating system of the Raspberry Pi has started up faster than in the 30s, the pulsation can be stopped by sending the string \x0D
X05 \x0D via UART, so that the successful startup is displayed more
directly. More about activating the serial interface can be found in
chapter 2.1. We have also integrated this method in our script of the shutdown function.
i
The Multimedia Case indicates the startup with a green flashing
of the LEDs. Aer 30s this blinking changes to a permanent light
by default. The shutdown of the Multimedia Case is indicated by a red blinking of the LEDs. When the Multimedia Case has disconnected the power supply to the Raspberry Pi, the LEDs will be permanently red.
i
www.joy-it.net
Pascalstr. 8 47506 Neukirchen-Vluyn
sudo python3 /home/pi/MultimediaCase/shutdown-function.py &
You can use the following command to run the program in the back­ground so that the terminal is still available.
We recommend adding this program to the autostart, so that Raspberry Pi always automatically calls the script at startup and remains perman­ently activated in the background. To do this, open the file
rc.local
with
the following command:
sudo nano /etc/rc.local
Insert the following line before
exit 0
. Note that the directory where the
script is located may dier.
python3 /home/pi/MultimediaCase/shutdown-function.py & exit 0
2.4 RGB-LEDs
The case has a RGB LED on each corner. The WS2812B LEDs are connected in a row and can be color adjusted with GPIO 18. This pin is connected to the PWM module of the Raspberry Pi. It is mandatory to use time critical signals (PWM) for WS2812B LEDs, otherwise disturbances may occur. To set up the LEDs we recommend Hyperion. Hyperion is an open source ambient light implementation which is compatible with many platforms. It also oers you the possibility to add more LEDs to add a backlight to your monitor and also allows you to play eects on your LEDs. You don't need any further knowledge about the data processing of LEDs.
Data processing of the LEDs
Because the WS2812B LEDs are arranged in a row / string, the
signal passes through all the LEDs one aer the other. Each LED takes one data package. Four data packages must always be sent so that all LEDs receive one data packet. These data packages contain values in GRB color space.
i
LED 1 LED 2
LED 3
LED 4
www.joy-it.net
Pascalstr. 8 47506 Neukirchen-Vluyn
If you want to use the jack plug, you must first switch o the LEDs, otherwise malfunctions may occur. Both PWM0 pins are
required for audio output via the jack plug.
i
2.4.1 LED colour mode The firmware of the board supports dierent LED color modes starting with version 1.0.1. These modes also control the LEDs when the Raspber­ry Pi is shut down. You set the LED mode by means of a string, which is transmitted serially to the board.
Mode 0 - Default colour mode
This is the default color mode, which is set in the factory default
state. Here the LEDs are permanently red when the Raspberry Pi is powered o and green when it is active. Powering up and powering down is indicated by pulsing green or red. The string
\x0D LM0 \x0D sets this mode.
Mode 1 - Only pulsating In this color mode only the startup and shutdown of the Raspberry Pi is indicated by pulsating. As soon as the Raspberry Pi is switched o or on, the LEDs are o. For this color mode you have to send this
string \x0D LM1 \x0D serially to the board.
Mode 2 - Only confirming In this color mode, only the startup and shutdown are
acknowledged. The LEDs only light up briefly, when the signal for
startup and shutdown has been received, to indicate that this signal has been acknowledged. The string \x0D LM2 \x0D is used to set the board.
You can send these strings serially to the board using a Python script. The following is an exemplary formulation of how this might look:
Loading...
+ 16 hidden pages