Hyperpixel - selective output (eg on boot)?


#1

Hyperpixel is awesome, but I have a question: I’d like to be able to selectively use HDMI out instead of the hyperpixel. Is there a way to programmatically change at runtime, or alternatively at boot, such as checking for a particular keypress or GPIO - although it looks like all GPIOs are used by hyperpixel itself.

All suggestions gratefully received.


HyperPixel-HDMI switch
Hyperpixel - HDMI Display Switcher
#2

It’s actually quite a tricky thing to accomplish, since switching over to the display is one of the first things that happens upon boot.

As far as I know, it can only be done manually (by offering some mention to pick HDMI/DSI, tweaking the config.txt and rebooting) or semi-automatically, like the functionality offered by PINN: https://github.com/procount/pinn/blob/master/README_PINN.md#how-to-auto-switch-hdmidsi-screen-configurations

PINN will automatically boot the last selected OS after it times out. If a HDMI screen is attached, PINN will copy the config.hdmi file to config.txt on the selected OS and reboot into it.

So I guess PINN is worth a look into!


#3

Hi there, I’m using an “auto-detection” script using bash commands leveraging using tvservice in my rc.local file. It’s not perfect, but it uses the typical config.txt style swapping (mentioned by other posts) to achieve my needs. It does have to reboot the Pi to switch, but it’s less than 10 seconds to get what I want. Hope it works for you.

Best regards,
– C-S

My equipment:

  • Stock Raspberry Pi 3 - Retropie Jessie standard image
  • Hyperpixel 800x480 display.
  • Pibow PITFT+ case modified to fit the Hyperpixel (modified Slice 9 and clear slice to make it fit).
  • Standard HDMI monitor supporting 1080p 60hz

I added the following code in my rc.local file above the exit 0 statement:

# Check to see if display is not connected
_NOHDMI=$(tvservice -n ) || true
# Check to make sure it's not already in LCD mode
_ISLCD=$(tvservice -s | grep "LCD") || true
# HDMI is connected - turn off backlight LCD
_HDMI=$(tvservice -s | grep "0x12000a") || true

if [ -z "$_NOHDMI" ]; then
  if [ "$_ISLCD" ]; then
    printf "NO HDMI connected, Hyperpixel display config already active\n"
    #do nothing
  else
    printf "NO HDMI connected, Switching to Hyperpixel display\n"
    #change config to Hyperpixel and reboot since no display detected
    sudo cp /boot/hyper-config.txt /boot/config.txt
    sudo reboot
  fi
elif [ "$_NOHDMI" ]; then
  if [ "$_ISLCD" ]; then
    printf "HDMI is connected, but Hyperpixel config is being used\n"
    #we need to switch to HDMI display config and reboot
    sudo cp /boot/hdmi-config.txt /boot/config.txt
    sudo reboot
  elif [ "$_HDMI" ]; then
    printf "HDMI is connected, HDMI config detected, so turning off LCD BL\n"
    #we need to shut off the backlight on the Hyperpixel display since we aren't using it
    #don't panic, a reboot automatically resets this - it isn't a persistent value
    #also to do this the config.txt file needs to load the backlight module on startup
    #to control it even if you aren't loading the overlay driver for the display
    echo 1 | sudo tee /sys/class/backlight/rpi_backlight/bl_power
  else
    #debugging catchall - shouldn't happen since we expect 0x12000a - but you never know...
    printf "HDMI is connected, HDMI config detected, your tv might not like 1920x1080 resolution\n"
  fi
else
  #do nothing - based on previous if statements - you either have HDMI or you don't have it...
  printf "Debug catchall point - sorry I can't help you out - I haven't run into the error state yet!\n"
fi

To use the above code in your own rc.local file, you need to create two files (hdmi-config.txt) and (hyper-config.txt) that live in your /boot directory. It’s strongly suggested to make a backup of your existing config.txt so you don’t accidentally nuke yourself just because my configuration may not 100% match your equipment.

file 1 - hyper-config.txt – a copy of the stock retropie jessie build with hyperpixel drivers installed with the following audio tweak:

# Use cleaner headphone audio output mode - trust me leave this enabled
audio_pwm_mode=2

file 2 - hdmi-config.txt – a copy of the stock build with one tweak:

# Use a basic GPIO backlight driver with on/off support
# Even if you use HDMI, you need to load this driver to be able to control the backlight
# of the Hyperpixel even when it is not used
dtoverlay=hyperpixel-gpio-backlight

#4

Very nice way about it!
I was planning to put an auto-default timer on my own script as Gadgetoid suggested, but I never got around to understanding enough about Python multi threading to implement it. I salute you sir!


#5

Sorry for not understanding this fully but am I correct in saying that the line of code will enable the pi to switch displays depending on if the HDMI port is occupied? If not, can someone explain how exactly this works? Thanks.


#6

Pretty much so; it checks to see if the HDMI port is active, and if so, uses it, unless the Hyperpixel display is also connected, in which case, it uses that.
Well, I think so at least!


#7

Thanks! :) Does the Hyperpixel cancel out any other HAT modules if one was to stack them? Eg. https://www.modmypi.com/raspberry-pi/breakout-boards-229/pi-modules/ups-pico ? Im making a portable pi hence why im wondering this as ill need a battery pack HAT module. Any reccomendations on cases? Im wanting the sides of the Hyperpixel entirely closed of and would even settle for covering the screen entirely as long as i could use a bluetooth keyboard without a digital one appearing on the screen. Thanks!


#8

I’m afraid the Hyperpixel display uses all of the GPIO pins in order to operate, so it’s likely that any other boards will be incompatible. You could try using something like a Black Hat H3cker, but I’m not sure whether it’d work.

As for a case, take a look at this thread. Pibow Suitability
I’m afraid I think the large case is still out of stock though…


#9

:( ah right, thanks anyway!


#10

You can always use the i2c to use an I/O expander for more GPIO pins (I am trying out the MCP23017 chip for this purpose for the powerboost’s low voltage signal for auto-shutdown, waiting for the custom pcb to arrive from China)


#11

C-S, I can’t find the rc.local file. Can you give me the path?

JackMart


#12

I suggest looking here to know about this file and what it does.

The path for rc.local is /etc/rc.local

To edit the file use something like this:

sudo nano /etc/rc.local


#13

Just a note that I’ve tested with the new hyperpixel4 and this is working.