Skip to content

Commit

Permalink
added some features from TimJuni#3
Browse files Browse the repository at this point in the history
  • Loading branch information
TimJuni committed Feb 8, 2014
1 parent 336759f commit 1f17b17
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 123 deletions.
2 changes: 1 addition & 1 deletion raspistillweb/templates/home-layout.mako
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">raspistillWeb</a>
<a class="navbar-brand" href="/">raspistillWeb</a>
</div>
<div class="navbar-collapse collapse" style="height: 1px;">
<ul class="nav navbar-nav">
Expand Down
2 changes: 1 addition & 1 deletion raspistillweb/templates/settings-layout.mako
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">raspistillWeb</a>
<a class="navbar-brand" href="/">raspistillWeb</a>
</div>
<div class="navbar-collapse collapse" style="height: 1px;">
<ul class="nav navbar-nav">
Expand Down
35 changes: 34 additions & 1 deletion raspistillweb/templates/settings.mako
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
</div>
% endif
% if preferences_fail_alert != []:
% if preferences_fail_alert != []:
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="alert alert-danger alert-dismissable">
Expand Down Expand Up @@ -48,6 +48,20 @@
<input type="number" class="form-control" id="ImageHeight1" name="imageHeight" placeholder="${image_height}">
</div>
</div>
<div class="form-group">
<label for="isoOption1" class="col-lg-2 control-label">ISO Option</label>
<div class="col-lg-10">
<select name="isoOption" class="form-control" id="isoOption1">
% for option in iso_options:
% if option == image_iso:
<option selected>${option}</option>
% else:
<option>${option}</option>
% endif
% endfor
</select>
</div>
</div>
<div class="form-group">
<label for="exposureMode1" class="col-lg-2 control-label">Exposure Mode</label>
<div class="col-lg-10">
Expand Down Expand Up @@ -90,6 +104,25 @@
</select>
</div>
</div>
<div class="form-group">
<label for="imageRotation1" class="col-lg-2 control-label">Image Rotation</label>
<div class="col-lg-10">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default ${'active' if image_rotation == '0' else ''}">
<input type="radio" name="imageRotation" value="0"><span class="glyphicon glyphicon-circle-arrow-up"></span> 0°
</label>
<label class="btn btn-default ${'active' if image_rotation == '90' else ''}">
<input type="radio" name="imageRotation" value="90"><span class="glyphicon glyphicon-circle-arrow-right"></span> 90°
</label>
<label class="btn btn-default ${'active' if image_rotation == '180' else ''}">
<input type="radio" name="imageRotation" value="180"><span class="glyphicon glyphicon-circle-arrow-down"></span> 180°
</label>
<label class="btn btn-default ${'active' if image_rotation == '270' else ''}">
<input type="radio" name="imageRotation" value="270"><span class="glyphicon glyphicon-circle-arrow-left"></span> 270°
</label>
</div>
</div>
</div>
<span class="help-block">Timelapse preferences:</span>
<div class="form-group">
<label for="TimelapseInterval1" class="col-lg-2 control-label">Timelapse Interval (ms)</label>
Expand Down
102 changes: 0 additions & 102 deletions raspistillweb/templates/settings.mako~

This file was deleted.

2 changes: 1 addition & 1 deletion raspistillweb/templates/timelapse-layout.mako
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">raspistillWeb</a>
<a class="navbar-brand" href="/">raspistillWeb</a>
</div>
<div class="navbar-collapse collapse" style="height: 1px;">
<ul class="nav navbar-nav">
Expand Down
82 changes: 65 additions & 17 deletions raspistillweb/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,19 @@
'off', 'auto', 'sun', 'cloud', 'shade', 'tungsten', 'fluorescent',
'incandescent', 'flash', 'horizon'
]

ISO_OPTIONS = [
'auto', '100', '150', '200', '250', '300', '400', '500',
'600', '700', '800'
]

IMAGE_HEIGHT_ALERT = 'Please enter an image height between 0 and 1945.'
IMAGE_WIDTH_ALERT = 'Please enter an image width between 0 and 2593.'
IMAGE_EFFECT_ALERT = 'Please enter a valid image effect.'
EXPOSURE_MODE_ALERT = 'Please enter a valid exposure mode.'
AWB_MODE_ALERT = 'Please enter a valid awb mode.'
ISO_OPTION_ALERT = 'Please enter a valid ISO option.'
IMAGE_ROTATION_ALERT = 'Please enter a valid image rotation option.'

THUMBNAIL_SIZE = '240:160:80'

Expand All @@ -60,8 +70,8 @@

timelapse = False

preferences_success_alert = False
preferences_fail_alert = []
preferences_success_alert = False

# image parameter commands
image_width = 800
Expand All @@ -71,14 +81,16 @@
awb_mode = 'off'
timelapse_interval = 4000
timelapse_time = 20000
image_ISO = 'auto'
image_rotation = '0'

# not implemented yet
image_quality = '100'
image_sharpness = '0'
image_contrast = '0'
image_brightness = '50'
image_saturation = '0'
image_ISO = '300'


###############################################################################
################################### Views #####################################
Expand All @@ -88,17 +100,17 @@
# View for the /settings site
@view_config(route_name='settings', renderer='settings.mako')
def settings_view(request):
global preferences_success_alert, preferences_fail_alert

preferences_success_alert_temp = False
if preferences_success_alert is True:
preferences_success_alert_temp = True
preferences_success_alert = False
global preferences_fail_alert, preferences_success_alert

preferences_fail_alert_temp = []
if preferences_fail_alert is not []:
preferences_fail_alert_temp = preferences_fail_alert
preferences_fail_alert = []

preferences_success_alert_temp = False
if preferences_success_alert:
preferences_success_alert_temp = True
preferences_success_alert = False

return {'project' : 'raspistillWeb',
'image_effect' : image_effect,
Expand All @@ -109,10 +121,13 @@ def settings_view(request):
'awb_modes' : AWB_MODES,
'image_width' : image_width,
'image_height' : image_height,
'image_iso' : image_ISO,
'iso_options' : ISO_OPTIONS,
'timelapse_interval' : timelapse_interval,
'timelapse_time' : timelapse_time,
'preferences_fail_alert' : preferences_fail_alert_temp,
'preferences_success_alert' : preferences_success_alert_temp,
'preferences_fail_alert' : preferences_fail_alert_temp
'image_rotation' : image_rotation
}

# View for the /archive site
Expand Down Expand Up @@ -190,28 +205,30 @@ def delete_view(request):
# View for settings form data - no site will be generated
@view_config(route_name='save')
def save_view(request):
global exposure_mode, image_effect, preferences_success_alert, image_width
global exposure_mode, image_effect, image_width, preferences_success_alert
global image_height, preferences_fail_alert, awb_mode, timelapse_interval
global timelapse_time
global timelapse_time, image_ISO, image_rotation

image_width_temp = request.params['imageWidth']
image_height_temp = request.params['imageHeight']
timelapse_interval_temp = request.params['timelapseInterval']
timelapse_time_temp = request.params['timelapseTime']
exposure_mode_temp = request.params['exposureMode']
image_effect_temp = request.params['imageEffect']
awb_mode_temp = request.params['awbMode']
image_ISO_temp = request.params['isoOption']
image_rotation_temp = request.params['imageRotation']

preferences_success_alert = True
if image_width_temp:
if 0 < int(image_width_temp) < 2593:
image_width = image_width_temp
else:
preferences_success_alert = False
preferences_fail_alert.append(IMAGE_WIDTH_ALERT)

if image_height_temp:
if 0 < int(image_height_temp) < 1945:
image_height = image_height_temp
else:
preferences_success_alert = False
preferences_fail_alert.append(IMAGE_HEIGHT_ALERT)

if timelapse_interval_temp:
Expand All @@ -220,23 +237,54 @@ def save_view(request):
if timelapse_time_temp:
timelapse_time = timelapse_time_temp

exposure_mode = request.params['exposureMode']
image_effect = request.params['imageEffect']
awb_mode = request.params['awbMode']
if exposure_mode_temp and exposure_mode_temp in EXPOSURE_MODES:
exposure_mode = exposure_mode_temp
else:
preferences_fail_alert.append(EXPOSURE_MODE_ALERT)

if image_effect_temp and image_effect_temp in IMAGE_EFFECTS:
image_effect = image_effect_temp
else:
preferences_fail_alert.append(IMAGE_EFFECT_ALERT)

if awb_mode_temp and awb_mode_temp in AWB_MODES:
awb_mode = awb_mode_temp
else:
preferences_fail_alert.append(AWB_MODE_ALERT)

if image_ISO_temp and image_ISO_temp in ISO_OPTIONS:
image_ISO = image_ISO_temp
else:
preferences_fail_alert.append(ISO_OPTION_ALERT)

if image_rotation_temp and image_rotation_temp in ['0','90','180','270']:
image_rotation = image_rotation_temp
else:
preferences_fail_alert.append(IMAGE_ROTATION_ALERT)

if preferences_fail_alert == []:
preferences_success_alert = True

return HTTPFound(location='/settings')

###############################################################################
############ Helper functions to keep the code clean ##########################
###############################################################################

def take_photo(filename):
if image_ISO == 'auto':
iso_call = ''
else:
iso_call = ' -ISO ' + str(image_ISO)
call (
['raspistill -t 500'
+ ' -w ' + str(image_width)
+ ' -h ' + str(image_height)
+ ' -ex ' + exposure_mode
+ ' -awb ' + awb_mode
+ ' -rot ' + str(image_rotation)
+ ' -ifx ' + image_effect
+ iso_call
+ ' -th ' + THUMBNAIL_SIZE
+ ' -o ' + RASPISTILL_DIRECTORY + filename], shell=True
)
Expand Down

0 comments on commit 1f17b17

Please sign in to comment.