I believe the Hero bus pins are:
- Pin3 - GPIO 127
- Pin4 - GPIO 2
- Pin16 - GPIO 22
- Pin17 - GPIO 19
- Pin18 - GPIO 124
- Pin19 - GPIO 129 (ID1)
- Pin20 - GPIO 125 (ID2)
- Pin22 - GPIO 136 (ID4)
- Pin28 - GPIO 36
- Pin29 - GPIO 37
Using these pins I want to connect ID2 with the pwr pin on the herobus and using a script, have it
- start recording
- Sit in a loop checking gpio125 and then exits the loop when 125 goes high.
- Script stops he recording and then shuts the GoPro down.
The power pin sits high and to turn the GoPro in pulling it low for about 1s works. It will then be a case of keeping it low, along with gpio125 and then on release of the button, both go high which trigger it to stop.
Currently I have a modified version of KonradITs code off GitHub as follows:
sleep 5
/usr/local/gopro/bin/gpsend ca CM%00 #selects video mode
sleep 5
/usr/local/gopro/bin/gpsend bp SH%01 #starts recording
sleep x
/usr/local/gopro/bin/gpsend bp SH%00 #stops recording after x seconds
sleep 5
/usr/local/gopro/bin/gpsend bp PW%00 #turns off GoPro
This is obviously constrained by the time conditions and is triggered as soon as the pwr pin is pulled low. I need to modify this around the sleep x
area to allow for the commands after sleep x
to be executed depending on when the power button is released.
I have considered using things like:
echo 125 > /sys/class/gpio/export # creates pin interface
echo in > /sys/class/gpio/gpio125/direction # sets it as output pin
echo 1 > /sys/class/gpio/gpio125/value # sets value to 1
etc to incorporate this but am unsure how to finish writing the code. I basically want it to check gpio125 in a loop and then exit the loop when it reads 125 high and then executes the stop recording and shut down commands after.