Skip to content

Commit

Permalink
More param fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
waveform80 committed May 12, 2016
1 parent a701756 commit 602c1e0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
9 changes: 5 additions & 4 deletions picamera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -1960,14 +1960,15 @@ def _get_framerate(self):
def _set_framerate(self, value):
self._check_camera_open()
self._check_recording_stopped()
if not (0 <= value <= 90):
n, d = to_rational(value)
if not (0 <= n / d <= 90):
raise PiCameraValueError("Invalid framerate: %.2ffps" % value)
sensor_mode = self.sensor_mode
clock_mode = self.CLOCK_MODES[self.clock_mode]
resolution = self.resolution
self._disable_camera()
self._configure_camera(
sensor_mode=sensor_mode, framerate=value, resolution=resolution,
sensor_mode=sensor_mode, framerate=(n, d), resolution=resolution,
clock_mode=clock_mode)
self._configure_splitter()
self._enable_camera()
Expand Down Expand Up @@ -2922,7 +2923,7 @@ def _set_image_effect_params(self, value):
def _get_color_effects(self):
self._check_camera_open()
mp = self._camera.control.params[mmal.MMAL_PARAMETER_COLOUR_EFFECT]
if mp.enable != mmal.MMAL_FALSE:
if mp.enable.value != mmal.MMAL_FALSE:
return (mp.u, mp.v)
else:
return None
Expand Down Expand Up @@ -3289,7 +3290,7 @@ def _set_annotate_text(self, value):
def _get_annotate_frame_num(self):
self._check_camera_open()
mp = self._camera.control.params[mmal.MMAL_PARAMETER_ANNOTATE]
return mp.show_frame_num != mmal.MMAL_FALSE
return mp.show_frame_num.value != mmal.MMAL_FALSE
def _set_annotate_frame_num(self, value):
self._check_camera_open()
mp = self._camera.control.params[mmal.MMAL_PARAMETER_ANNOTATE]
Expand Down
7 changes: 5 additions & 2 deletions picamera/mmal.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ def MMAL_FOURCC(s):

MMAL_FALSE = 0
MMAL_TRUE = 1

class MMAL_BOOL_T(ct.c_int32):
def __repr__(self):
return 'MMAL_BOOL_T(%s)' % (self.value != MMAL_FALSE)
# This only exists to ensure we've got a distinct type to ct.c_int32
# for mmalobj to perform dict-lookups against
pass


class MMAL_CORE_STATISTICS_T(ct.Structure):
_fields_ = [
Expand Down
2 changes: 1 addition & 1 deletion picamera/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def _set_layer(self, value):
""")

def _get_fullscreen(self):
return self.renderer.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION].fullscreen != mmal.MMAL_FALSE
return self.renderer.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION].fullscreen.value != mmal.MMAL_FALSE
def _set_fullscreen(self, value):
mp = self.renderer.inputs[0].params[mmal.MMAL_PARAMETER_DISPLAYREGION]
mp.set = mmal.MMAL_DISPLAY_SET_FULLSCREEN
Expand Down
8 changes: 4 additions & 4 deletions tests/test_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,17 +456,17 @@ def test_resolution(camera, previewing):
# Camera's vertical resolution is always a multiple of 16, and
# horizontal is a multiple of 32, hence the difference in the video
# formats here and below
assert camera._camera.outputs[2].width == 1920
assert camera._camera.outputs[2].height == 1088
assert camera._camera.outputs[2]._port[0].format[0].es[0].video.width == 1920
assert camera._camera.outputs[2]._port[0].format[0].es[0].video.height == 1088
camera.resolution = (2592, 1944)
assert camera.resolution == (2592, 1944)
assert camera._camera.outputs[2].width == 2592
assert camera._camera.outputs[2].height == 1952
# Test some irregular resolutions
camera.resolution = (100, 100)
assert camera.resolution == (100, 100)
assert camera._camera.outputs[2].width == 128
assert camera._camera.outputs[2].height == 112
assert camera._camera.outputs[2]._port[0].format[0].es[0].video.width == 128
assert camera._camera.outputs[2]._port[0].format[0].es[0].video.height == 112
# Anything below 16,16 will fail (because the camera's vertical
# resolution works in increments of 16)
with pytest.raises(picamera.PiCameraError):
Expand Down

0 comments on commit 602c1e0

Please sign in to comment.