-
-
Notifications
You must be signed in to change notification settings - Fork 7
Programming your own applications
The main destiny of Malinka is to be a radio transmitter. You can write your application in any language you want: C, C++, Python, or even Java. You can also use any GUI library. But to keep things simple, my recommendations are:
- RF24 library, because it works on both RPi and microcontrollers flawlessly
- LVGL, one of most popular GUI library for embedded devices
- Nuklear instead of LVGL, if you want a really lightweight library
Note that both RF24 and LVGL can be programmed in C and Python! I will show an example of creating a robot arm interface, using NRF24L01 and Arduino. Quoting the famous electrician, let's get started!
As of now, LVGL gets confused with touch and joystick input! To get it working, you need to disable the joystick driver with sudo killall malinkabtn
! I'm working on the fix.
I got the LVGL working in simulator mode (doesn't require running X-Server manually), and Nuklear as well (requires X11). If you have chosen to use LVGL, a simulator on PC may be useful!
You will need to make compatible code on the receiver and the transceiver, using your libraries of choice - this is why I don't share any example code. (and hey, if you actually made this project, you probably aren't new in programming NRFs)
You must remember though that if you send structs, you must take care of padding and data alignment! Data may be packed differently on 8 bit devices as opposed to 32 bit devices. This guide may be useful!
The radio is connected as device 0 on SPI 1, and the CE pin is connected to BCM pin 4. So, if you use the RF24 library, the object would look like RF24 radio(4, 10);
. Interrupt pin is disconnected, but one could modify the hardware to actually utilize it.
Once you have your main application, you need to make a custom script to run it.
Create a new .sh
file in /home/pi/RetroPie/roms/apps
directory. You want to run all dependencies your application needs, and your application at the end. An example bash script can look like:
# Not necessary but you can insert any text here
echo "Running my custom application!"
# run an X server in a screen instance
sudo screen -dmS X Xorg -config /etc/X11/X.conf -nocursor :3
export DISPLAY=:3
# run the application
sudo /home/pi/path/to/my/app &
If everything goes good, you should see your script in the 'apps' section in RetroPie. If not, alternatively you can put the .sh
file to RetroPie/retropiemenu
, so it would appear in the RetroPie options menu.
System button doesn't shut down the radio nor Pi, so you won't lose connection if you turn the screen off.
Have fun with your new handheld!