Skip to content

Instantly share code, notes, and snippets.

@lrvick
Created July 15, 2012 02:01
Show Gist options
  • Save lrvick/3114421 to your computer and use it in GitHub Desktop.
Save lrvick/3114421 to your computer and use it in GitHub Desktop.
Simple script to run a timelapse on a canon camera from a raspberry pi with an attached HD44780 display
from hd44780 import HD44780
import ctypes
from time import sleep
class CameraFilePath(ctypes.Structure):
_fields_ = [('name', (ctypes.c_char * 128)),
('folder', (ctypes.c_char * 1024))]
gp = ctypes.CDLL('libgphoto2.so.2')
context = gp.gp_context_new()
camera = ctypes.c_void_p()
gp.gp_camera_new(ctypes.pointer(camera))
gp.gp_camera_init(camera, context)
cam_path = CameraFilePath()
lcd = HD44780()
while 1:
for i in reversed(range(1,4)):
lcd.clear()
lcd.message('taking picture\n in %s seconds' % i)
sleep(1)
lcd.clear()
lcd.message('Capturing...')
gp.gp_camera_capture(camera, 0, ctypes.pointer(cam_path), context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment