Hammaskejju
Posts: 4
Joined: Tue Apr 09, 2013 4:59 am

Control over HDMI

Thu Mar 27, 2014 10:44 am

I am not quite sure if this is right category for this question...

I have a RaspberryPI computer showing a picture from network camera. This camera is constantly changing it's postion (PTZ, moving duration is about half minute). This causes the plastic parts to get worn very quickly inside the camera. Therefore I want to stop the movement of the camera every time, the HDMI TV display is turned off.

The webcam picture is shown in a web page in Chromium. When I close this web page, the camera stops moving. So easiest way to do this is just simply terminate/close the Chromium process, when the TV get's turned of. And same way when someone turns the TV back ON, the chromium should start showing the image.

Unfortunately I'm newbie with Linux and linux programming, so I don't know even where to start. Don't even know if this is even possible.

The second possibility could be use of GPIO. I have the preassembled GPIO board with few buttons and screw-pins. I could do a separate button for controlling the chromium.

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Control over HDMI

Mon Apr 07, 2014 5:15 am

HDMI supports a protocol called CEC, Consumer Electronics Control. It's designed to pass remote control signals received by one device (eg, the TV) to other devices (eg a Blu-Ray player) so that you only need one remote, and to automatically turn on the TV and change inputs when another device is turned on. It supports many features, including polling a device for power state. I'm not sure if a device broadcasts a power state change over the channel when it is changed, but I do know that you can check manually, and doing it on a scheduled basis may let you power down the camera at least shortly after the TV is turned off, even if not immediately.

You first need to install libcec on the Pi. Installation instructions can be found here.

Try the following commands from the Pi while an HDMI device is plugged in:
Scan the CEC bus, and report all devices:
echo "scan" | cec-client -s -d 1
Check the power status of the TV (device 0):
echo "pow 0" | cec-client -s -d 1
Turn the TV on:
echo "on 0" | cec-client -s -d 1
Turn the TV off:
echo "standby 0" | cec-client -s -d 1

These are a few of the ones with shortcuts in the CEC client. You can find a more complete list of CEC commands at http://www.cec-o-matic.com/ but I'll warn you, it takes some time to understand. Feel free to ask me for more info about these if you're interested. I wrote a pair of scripts heavily based on libcec and using many of the CEC commands, so I have more experience with it than most. (It lets me use many of the controls of my TV and bluray player with simple CLI commands, eg "tv on" and "bd eject" etc.)

Return to “Raspberry Pi OS”