# Source or dot this file to pick up some utilities for dealing with the servo and camera export RELAY_PIN=23 export SERVO_PIN=18 export DATA_DIR=~/suncam-pics configure-gpio() { # Call this first in any program to get the pins configured properly # On/off signal signal to the relay gpio -g mode ${RELAY_PIN} out # PWM to the servo gpio -g mode ${SERVO_PIN} pwm gpio pwm-ms gpio pwmc 192 gpio pwmr 2000 } turnRelayOn() { gpio -g write ${RELAY_PIN} 1 } turnRelayOff() { gpio -g write ${RELAY_PIN} 0 } filter() { # Move filter arm so that it covers the camera lens gpio -g pwm ${SERVO_PIN} 145 sleep 1 } nofilter() { # Move filter arm out of the way gpio -g pwm ${SERVO_PIN} 220 sleep 1 } takeFilteredPic() { # $1 filename without suffix # $2 is the shutter speed in uSec raspistill -n -e jpg -o $1.jpg -ss $2 } takeUnfilteredPic() { # $1 filename without suffix raspistill -n -e jpg -o $1.jpg } getFilename() { DAILYDIR=${DATA_DIR}/`date +%Y%m%d` mkdir -p ${DAILYDIR} echo ${DAILYDIR}/`date +%Y%m%d-%H%M%S` }