Last active
June 5, 2022 18:46
-
-
Save danmonaghan/9ad57a9472f3890ac13224c88bcaaaa5 to your computer and use it in GitHub Desktop.
DIY Cine Film Scanner Makers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ISO=100 #32 | |
SHUTTER=25000 #1250 #6140 #6140=120th? | |
OUTPUTFILENAME=$1 | |
OUTPUTDIR=$PWD # Or set to your own, I prefer working the current directory | |
raspistill -vf -r -bm -fs 1 -ex fixedfps -q 25 -ISO $ISO -ss $SHUTTER -k -awb tungsten -o $OUTPUTDIR/${OUTPUTFILENAME}_%04d.jpg -s -p 0,0,800,600 #-n ex fixedfps # -q 100 -fw -r | |
# notes, so... | |
# -vf is vertial flip | |
# -r is raw | |
# -bm is burst mode (display doesn't update continuously) | |
# -ex fixedfps is exposure at constant | |
# -q is jpeg quality | |
# -ISO self explanatory | |
# -ss shutter speed | |
# -k is keyboard trigger (just use space bar instead of using the reed switch | |
# -awb tungsten - set to your liking | |
# -o outputs | |
# -s set to trigger of GPIO | |
# -p preview window |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# this must be run with python3 or it will fail, no other pre-requisites as RPi.GPIO is install on a Raspberry Pi by default. | |
import signal | |
import sys | |
import time | |
import RPi.GPIO as GPIO | |
import os | |
import subprocess | |
from subprocess import check_output | |
import threading | |
import datetime | |
HALLEFFECT_GPIO = 23 | |
BUTTON_GPIO = 16 | |
MOTOR_STATUS = 21 | |
PRESSED = 0 | |
LASTCOUNT = 0 | |
TESTMODE = 0 | |
COUNT = 1 | |
# Setup Code | |
GPIO.setmode(GPIO.BCM) | |
#GPIO.setwarnings(True) | |
GPIO.setup(HALLEFFECT_GPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP) | |
def get_pid(name): | |
return int(check_output(["pidof", "-s", name])) | |
def threadFunc(): | |
time.sleep(0.2) | |
os.kill(raspid, signal.SIGUSR1) | |
def signal_handler(sig, frame): | |
GPIO.cleanup() | |
sys.exit(0) | |
def button_pressed_callback(channel): | |
global LASTCOUNT | |
global PRESSED | |
global TESTMODE | |
global COUNT | |
thisTime = time.perf_counter() - LASTCOUNT | |
print("Button pressed!", COUNT, thisTime) | |
GPIO.output(MOTOR_STATUS, 0) | |
COUNT += 1 | |
LASTCOUNT = time.perf_counter() | |
if TESTMODE == 1: | |
th = threading.Thread(target=threadFunc) | |
th.start() | |
try: | |
if len(sys.argv) == 2: | |
raspid=get_pid("raspistill") | |
#global TESTMODE | |
TESTMODE = 1 | |
print("proc name = ", raspid) | |
else: | |
print("Test mode") | |
if __name__ == '__main__': | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(BUTTON_GPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP) | |
GPIO.setup(MOTOR_STATUS, GPIO.OUT) | |
GPIO.output(MOTOR_STATUS, 1) | |
GPIO.add_event_detect(BUTTON_GPIO, GPIO.FALLING, | |
callback=button_pressed_callback, bouncetime=500) | |
GPIO.add_event_detect(HALLEFFECT_GPIO, GPIO.RISING, | |
callback=button_pressed_callback, bouncetime=50) | |
signal.signal(signal.SIGINT, signal_handler) | |
signal.pause() | |
except KeyboardInterrupt: | |
print ("You exited the program") | |
#execute code inside this block as the program exits | |
finally: | |
print ("You exited the program") | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment