question

bigbadbob76 avatar image
bigbadbob76 asked

venus raspberry pi with physical buttons.

Hi Folks.

I have set up my raspberry pi 2B with Venus 2.66 and got it to display the gui on the 2.2" non touch screen hat built into my pi case, the one with six buttons and IR receiver.

In case anyone else is using this screen there is an overlay available for the 2.2" screen hat here-

https://github.com/raspberrypi/firmware/tree/master/boot/overlays. it is called pitft22.dtbo. ;-)

As it is not a touch screen I would like to use the six physical buttons on the hat to control my venus in a similar way to the CCGX. these are wired to GPIO pins on the pi hat. can anyone tell me how the CCGX buttons are wired to it's processor?

I have tried adding the gpio-key.dtbo to the venus overlays folder and editing the config file to run the overlay using "dtoverlay=gpio-key, gpio=24,active_low=1,gpio_pull=up, label=Down, keycode=108"

This should give me a down button on GPIO pin 24 but the button is not responding.

Any help appreciated.

Cheers.

Bob.

Venus OS
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

6 Answers
Kevin Windrem avatar image
Kevin Windrem answered ·

You might see if you can map those buttons to the keyboard keys with the names shown on the remote console display: escape, return, the 4 arrow buttons and space.

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

bigbadbob76 avatar image bigbadbob76 commented ·

Thanks for your reply Kevin. :-)

I was under the impression that asigning keycode 108 to a button would map it to the keyboard down arrow. but maybe that only works with raspian and not with venus. hmmm....

I will check if this works with a keyboard plugged in.... venus might need one in order to map properly.


0 Likes 0 ·
bigbadbob76 avatar image
bigbadbob76 answered ·

@Kevin Windrem

Hi Kevin. could you advise me please?

it seems that my overlay is not working, probing the GPIO pins with a voltmeter shows some are still being pulled low. my entries in the config file should call the overlay for each pin and pull them up but this doesn't seem to be happening.

can you tell me if it should be a .dtb or a .dtbo for venus? both seem to work for other overlays.

I found your VenusGpioOverlay.dts on github but have no way to compile it for my button pins (4,5,17,22,23,24) my Linux machine is in bits atm. :-(

I don't want to install all of your RpiGpioSetup as it uses pins I use for buttons as relay drives.

2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Kevin Windrem avatar image Kevin Windrem commented ·
I think I used a Raspberry PI OS SD card to compile the .dts file. I then moved the .dtb file over to the PI running Venus OS.

I believe .dtb and .dtbo extensions work interchangeably.

0 Likes 0 ·
bigbadbob76 avatar image bigbadbob76 Kevin Windrem commented ·

Many thanks Kevin. that confirms what I thought too. :-)

I'll keep plugging away at it.


0 Likes 0 ·
bigbadbob76 avatar image
bigbadbob76 answered ·

So it looks like Veuns is missing the gpio-keys module that the gpio-key.dtbo overlay needs.

hmmm.....

EDIT- according to an old post by Izak Burger on another forum, the gpio-keys module is included in venus and is used by the CCGX so I'm on the right track but not sure why my overlay is not working.

some more debug needing done....

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

bigbadbob76 avatar image
bigbadbob76 answered ·

i found the gpio_keys driver in /lib/modules/4.9.80/kernel/drivers/input/keyboard

so now it looks like the gpio-key.dtbo is working after all, along with my shutdown-key.dtbo

event0 is created by gpio-key

event1 is created by my shutdown-key

root@raspberrypi2:~# ls /dev/input
by-path event0 event1 mice
root@raspberrypi2:~# ls /dev/input/by-path
platform-button@0-event platform-soc:shutdown_button@11-event
root@raspberrypi2:~#

but something not quite right as nothing appears in event0 and some hex appears in event1 when i press my shutdown button.


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

bigbadbob76 avatar image
bigbadbob76 answered ·

Found it!!!!

I had spaces in my config file lines that called the dtbo. doh!!

Params should have commas between them but no spaces.

All good now. :-)

I have six lines in config.txt that call the six buttons...

dtoverlay=gpio-key,gpio=4,active_low=1,gpio_pull=up,label=enter,keycode=28

dtoverlay=gpio-key,gpio=17,active_low=1,gpio_pull=up,label=escape,keycode=1

dtoverlay=gpio-key,gpio=5,active_low=1,gpio_pull=up,label=up,keycode=103

dtoverlay=gpio-key,gpio=24,active_low=1,gpio_pull=up,label=down,keycode=108

dtoverlay=gpio-key,gpio=22,active_low=1,gpio_pull=up,label=left,keycode=105

dtoverlay=gpio-key,gpio=23,active_low=1,gpio_pull=up,label=right,keycode=106

Then to add the 7th button (space) I removed the IR receiver and connected a button in it's place.

this is wired to gpio26. due to the footprint of the button I wired it between +3.3v and gpio 26.

then added the following line to config.txt

dtoverlay=gpio-key,gpio=26,active_low=0,gpio_pull=down,label=space,keycode=57

this is the oposite to the other pins that are active_low=1,gpio_pull=up.

be careful if you use venus digital inputs with this board as gpio5 and gpio26 are digital inputs 1 and 5 respectively so leave these diabled/unused in venus or the buttons will trigger alarms or start your genny. hahahah... you have been warned.

p.s. you can comment them out in /etc/venus/gpio_list if you're paranoid. ;-)

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

bigbadbob76 avatar image
bigbadbob76 answered ·

And just to finish this off-

I got the backlight/screensaver working using overlay- "hdmi_backlight_hwhack_gpio.dtbo" from the link above, copying it into "u-boot/overlays"

and putting "dtoverlay=hdmi_backlight_hwhack_gpio,gpio_pin=27,active_low=1" in u-boot/config.txt

then from ssh screen, type

echo '/sys/class/backlight/hdmi_backlight_hwhack_gpio/bl_power' >/etc/venus/blank_display_device

This links the gui to the gpio pin.

DO NOT put anything into "/etc/venus/backlight_device" as, with this display board, dimming is not an option. (gpio 27 is not a pwm pin).

"/etc/venus/backlight_device" must be empty or the screensaver will not activate.

Now when you go to the display and language menu in the gui you have the option to set the timeout time for the backlight. and yes... it comes out of screensaver when you press a button.

simples ;-)

Thanks to posts on here I figured out what I had to do. cheers guys.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources