Skip to content

Commit

Permalink
minor Arduino code updates
Browse files Browse the repository at this point in the history
  • Loading branch information
wyojustin committed Dec 10, 2014
1 parent 6b3fc08 commit b4b6808
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
21 changes: 14 additions & 7 deletions arduino/ButtonSnap/ButtonSnap.ino
Expand Up @@ -16,7 +16,7 @@ const int DBG_PIN = 13;
const long PhotoDelay = 3000;
const int N_PIXEL = 128;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_PIXEL, PIN, NEO_GRB + NEO_KHZ800);
bool dbg_val = false;

void setup() {
Expand All @@ -34,11 +34,21 @@ void setup() {
delay(100);
}
digitalWrite(DBG_PIN, dbg_val);
setColor(0, 0, 0);
}

void setColor(char r, char g, char b){
int i;

for(i = 0; i < N_PIXEL; i++){
strip.setPixelColor(i, r, g, b);
}
strip.show();
}

void loop() {
char command;
int i, r, g, b;
int r, g, b;

if(Serial.available()){
while(Serial.available()){
Expand All @@ -51,10 +61,7 @@ void loop() {
g = Serial.read();
b = Serial.read();
dbg_val = !dbg_val;
for(i = 0; i < N_PIXEL; i++){
strip.setPixelColor(i, r, g, b);
}
strip.show();
setColor(r, g, b);
digitalWrite(DBG_PIN, dbg_val);
}
}
Expand All @@ -63,7 +70,7 @@ void loop() {
if (digitalRead(ButtonPin) == LOW)
{
Serial.println("snap");// send to Pi
StartCountdown(PhotoDelay/1000); //Start blinky Lights
// StartCountdown(PhotoDelay/1000); //Start blinky Lights
// The Pi will be processing the image for a while. Could add
// red green ready light/strip
delay (PhotoDelay); // allow pi to process the previous image
Expand Down
15 changes: 10 additions & 5 deletions scripts/boothcam.py
@@ -1,3 +1,5 @@
from subprocess import call
import tkFileDialog
import glob
import os
import os.path
Expand Down Expand Up @@ -86,10 +88,12 @@ def snap(can, n_count):
if config.ARCHIVE and os.path.exists(config.PROC_FILENAME):
### copy image to archive
image_idx += 1
os.rename(config.PROC_FILENAME, 'Archive/%s_%05d.%s' % (config.PROC_FILENAME[:-4], image_idx, config.EXT))
new_filename = os.path.join(config.archive_dir, '%s_%05d.%s' % (config.PROC_FILENAME[:-4], image_idx, config.EXT))
command = (['cp', config.PROC_FILENAME, new_filename])
call(command)
camera = picamera.PiCamera()
countdown(camera, can, n_count)
camera.capture(config.RAW_FILENAME)
camera.capture(config.RAW_FILENAME, resize=(1366, 768))
camera.close()

snapshot = Image.open(config.RAW_FILENAME)
Expand All @@ -104,9 +108,10 @@ def snap(can, n_count):
snap.active = False

if config.ARCHIVE:
if not os.path.exists('Archive'):
os.mkdir('Archive')
image_idx = len(glob.glob('Archive/%s_*.%s' % (config.PROC_FILENAME[:-4], config.EXT)))
config.archive_dir = tkFileDialog.askdirectory(initialdir='/media/')
if not os.path.exists(config.archive_dir):
os.mkdir(config.archive_dir)
image_idx = len(glob.glob(os.path.join(config.archive_dir, '%s_*.%s' % (config.PROC_FILENAME[:-4], config.EXT))))

def findser():
ser = serial.Serial('/dev/ttyS0',19200, timeout=.1)
Expand Down
4 changes: 2 additions & 2 deletions scripts/config.py
Expand Up @@ -25,14 +25,14 @@ def __init__(self):
gmailPassword = password
n_count = 0

TIMELAPSE = 20 ## use 0 for no time lapse photos
TIMELAPSE = 30 ## use 0 for no time lapse photos, at least 3 (seconds)
### set up GUI
BUTTON_FONT = ('Times', 24)
CANVAS_FONT = ("times", 50)

# SIGN_ME_IN = True
SIGN_ME_IN = False; print 'DBG:: not signing in'
ARCHIVE = True
ARCHIVE = False
EXT = 'jpg'
RAW_FILENAME = 'image.' + EXT
PROC_FILENAME = 'photo.' + EXT
11 changes: 7 additions & 4 deletions scripts/photobooth_gui.py
Expand Up @@ -7,14 +7,19 @@

## imports
import time
from boothcam import *
from Tkinter import *
import ImageTk
from mailfile import *
import custom
import Image
import config

## This is a simple GUI, so we allow the root singleton to do the legwork
root = Tk()

### booth cam may need to present a file dialog gui. So import after root is defined.
from boothcam import *

## set display geometry
WIDTH = 1366
HEIGHT = 788
Expand All @@ -28,9 +33,6 @@
## put the status widget below the displayed image
STATUS_H_OFFSET = 150 ## was 210

## This is a simple GUI, so we allow the root singleton to do the legwork
root = Tk()

## only accept button inputs from the AlaMode when ready
Button_enabled = False

Expand Down Expand Up @@ -259,4 +261,5 @@ def labeled_slider(parent, label, from_, to, side, variable):
root.wm_title("Wyolum Photobooth")
etext.focus_set()
# etext.bind("<Enter>", sendPic)
on_rgb_change()
root.mainloop()

0 comments on commit b4b6808

Please sign in to comment.