0

My Project on a Raspberry Pi 2 with Raspian stretch. I want use a GPIO pin to drive 3d shutter glasses (glasses hacked to receive 0 _3V square wave) Video playing on the HDMI port and A Pin goes on when one video frame completes then goes off when the next video frame completes.

Things I’ve tried. HDMI splitter then a VGA converter one of the HDMI’s. This works but requires a bit of electronics to clean up the signal to give me the square wave I want. I’m also hoping in the end to have more than one pin switching. Plus it seems to upset the RPI on occasions possible due to the and shaking between the PI and the monitor. So this solution doesn’t really cut it

Set up the DPI output and get the Vsync from pin 3. Then use mirroring software like rpi-fbcp or raspi2fb to show the same video on the HDMI and DPI at the same time. Main problem here is there is a varying time delay between the HDMI frames and the DPI frames. So they are not synchronised.

I’ve been searching the ol google for near a week now trying stuff but haven’t managed to bottom it.

As the video I’m showing is made up of still images made in to an MPG I could send the individual JPGs to the HDMI and put a pin toggle command between each frame but Python is too slow to get a decent frame rate (ie 60fps or more) . So a smart person maybe able to do this in C or something but it’s beyond me and I can’t find any example close enough on the net to figure it out…

I think it is probably very possible using the Video core API’s like DispmanX but I can’t understand how to use it and again can’t find any examples out there that are close enough for me to tinker with.

So I’m really open to suggestions…

Thanks for reading….

  • It is not clear (to me) what the inputs and outputs are. Something happens (end of frame?) which is meant to trigger something else (3D glasses?). Where and what is the input and where and what is the output? Preferably in terms relevant to the Pi such as GPIO X receives a pulse and then GPIO Y must be set low. – joan Mar 9 at 8:43
  • Hello Joan thanks for replying.. There wont be an input as such well nothing external to the RPI. The RPI will be playing a video with (omx probably) . The video will be set up to run at 60 frames per second. I want a GPIO pin to toggle between high and low each frame. My thoughts were if I could match the fps and the refresh rate and I can get at the video Vsync pulse then this may do it.. – perfo Mar 10 at 0:25
0

My very rusty C programming skills (they never were that good) held me back here but I final cracked it.. now I have a GPIO pin with a nice square wave on syncronised to the VSync of the HDMI signal.. works super duper...

Just in case it helps others I've tagged the code on below. Other than installing wiringpi for the gpio bit everything else is already there.. of course I'm sure there is plenty of room for improvement

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wiringPi.h>
#include <stdint.h>
#include "bcm_host.h"

int Toggle = 0;

void Vsync(DISPMANX_UPDATE_HANDLE_T update, void *arg)
{
  Toggle= !Toggle;
}

int
main(void)
{
    if (wiringPiSetup () == -1)
      return 1 ;

    bcm_host_init();

    DISPMANX_DISPLAY_HANDLE_T display = vc_dispmanx_display_open(0);

    vc_dispmanx_vsync_callback(display, Vsync, NULL);
    while (1)
    {
        digitalWrite (11, Toggle) ; 
    }

    return 0;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.