accessing right button in recalbox

Very powerful gaming console solution based on Debian
Post Reply
adiastra
Posts: 5
Joined: Tue May 12, 2020 9:53 pm
languages_spoken: english
ODROIDs: XU4 OGST
Has thanked: 0
Been thanked: 0
Contact:

accessing right button in recalbox

Post by adiastra »

I would like to turn on and off the TFT backlight using the programmable right button in using the Recalbox OS

I have written this script which works great. It accepts either 'in' or 'off' arguments and if no argument is given it toggles the backlight (and provides instructions).

Code: Select all

#!/bin/bash

filename='/sys/class/backlight/fb_ili9340/bl_power'
read -r state<$filename

if [ "$1" = "off" ]; then
        echo 1 > /sys/class/backlight/fb_ili9340/bl_power
elif [ "$1" = "on" ]; then
        echo 0 > /sys/class/backlight/fb_ili9340/bl_power
else
        echo "This command accepts the following arguments"
        echo "on - turns the backlight on"
        echo "off - turns the backlight off"
        echo "If no argument is given the backlight will toggle"
        echo "No state selcted, toggling."
        if [ "$state" = "0" ]; then
                echo 1 > /sys/class/backlight/fb_ili9340/bl_power
        else
                echo 0 > /sys/class/backlight/fb_ili9340/bl_power
        fi
fi



But I am not sure how to access the gpio event to trigger the script. Any help would be appreciated.
Last edited by adiastra on Wed May 13, 2020 4:12 am, edited 1 time in total.

User avatar
tobetter
Posts: 7633
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 420 times
Been thanked: 1167 times
Contact:

Re: accessing right button in recalbox

Post by tobetter »

I think you can use 'inotify' that monitors the change of a directory or a file.

adiastra
Posts: 5
Joined: Tue May 12, 2020 9:53 pm
languages_spoken: english
ODROIDs: XU4 OGST
Has thanked: 0
Been thanked: 0
Contact:

Re: accessing right button in recalbox

Post by adiastra »

that wont work unless I know which file I am monitoring.

adiastra
Posts: 5
Joined: Tue May 12, 2020 9:53 pm
languages_spoken: english
ODROIDs: XU4 OGST
Has thanked: 0
Been thanked: 0
Contact:

Re: accessing right button in recalbox

Post by adiastra »

ok what I need to know is what GPIO pin the button is attached to, what the raw export number for that pin is. Once I have that I can export the pin as an input and monitor the VALUE. The part I am missing is the export number.

based on this https://odroid.com/dokuwiki/doku.php?id ... dware_gpio the number is 25 but that resource is busy already so I am not sure what is going on.

User avatar
odroid
Site Admin
Posts: 37229
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1723 times
Been thanked: 1120 times
Contact:

Re: accessing right button in recalbox

Post by odroid »

According to the schematics, the button XE_INT16 GPIO export number must be 24 not 25.
https://wiki.odroid.com/odroid-xu4/soft ... pcb_layout
https://wiki.odroid.com/odroid-xu4/hard ... connectors

Try 24 first. If you still meet "resource is busy" message, show us "lsmod" output to find which driver module uses that GPIO.

BTW, what is your working Kernel version in Recalbox OS image?

adiastra
Posts: 5
Joined: Tue May 12, 2020 9:53 pm
languages_spoken: english
ODROIDs: XU4 OGST
Has thanked: 0
Been thanked: 0
Contact:

Re: accessing right button in recalbox

Post by adiastra »

# lsmod
Module Size Used by Tainted: G
fb_ili9340 16384 0
fbtft_device 40960 0
fbtft 36864 2 fb_ili9340,fbtft_device
spi_s3c64xx 20480 0
ipv6 376832 44 [permanent]
bnep 20480 2
usbhid 45056 0
uinput 20480 0
sd_mod 45056 2
cfg80211 479232 0
uas 20480 0
usb_storage 49152 2 uas
joydev 20480 0
scsi_mod 135168 3 sd_mod,uas,usb_storage
spidev 20480 0
ads7846 20480 0
btusb 40960 0
btrtl 16384 1 btusb
btbcm 16384 1 btusb
btintel 16384 1 btusb
evdev 24576 2
w1_gpio 16384 0
bluetooth 409600 26 bnep,btusb,btrtl,btbcm,btintel
wire 24576 1 w1_gpio
ecdh_generic 28672 1 bluetooth
rfkill 20480 3 cfg80211,bluetooth
uio_pdrv_genirq 16384 0
uio 20480 1 uio_pdrv_genirq
extcon_usb_gpio 16384 0
exynos_gpiomem 16384 0
gpio_keys 20480 0

I am root

# cd /sys/class/gpio/
# echo 24 >export
-sh: echo: write error: Device or resource busy





Linux version 4.14.141 (root@8346aca3aea2) (gcc version 7.3.0 (Buildroot 2018.02.3-dirty)) #1 SMP PREEMPT Wed Nov 13 14:19:41 CET 2019

User avatar
odroid
Site Admin
Posts: 37229
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1723 times
Been thanked: 1120 times
Contact:

Re: accessing right button in recalbox

Post by odroid »

Try adding the following driver modules into the blacklist file to narrow down root causes.

Code: Select all

ads7846
w1_gpio
wire
gpio_keys
In Ubuntu, we've used /etc/modprobe.d/blacklist-odroid.conf.
But I am not sure which file should be edited in your OS image.

Or, run modprobe -r command with driver names to remove the drivers one by one.
I hope you can find which driver occupies the GPIO pin.

Post Reply

Return to “OGST-XU4”

Who is online

Users browsing this forum: No registered users and 8 guests