Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/talogo.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-12-29 17:03:42 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-12-29 17:03:42 (GMT)
commitb9f147f3f72f0ce0eecf7e6598cad4b785aa4719 (patch)
treeffb27f2c169a35ba5092c938fd372d620b4194bf /TurtleArt/talogo.py
parentb628998276dd58151d2e850587096ef3d9cb8646 (diff)
refactored camera code to use poll for MESSAGE_EOS instead of timeout
Diffstat (limited to 'TurtleArt/talogo.py')
-rwxr-xr-xTurtleArt/talogo.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py
index 399b5b4..5c8a771 100755
--- a/TurtleArt/talogo.py
+++ b/TurtleArt/talogo.py
@@ -44,7 +44,7 @@ from taconstants import TAB_LAYER, BLACK, WHITE, \
SENSOR_DC_BIAS, XO1, XO15
from tagplay import play_audio_from_file, play_movie_from_file, stop_media, \
media_playing
-from tacamera import save_camera_input_to_file
+from tacamera import Camera
from tajail import myfunc, myfunc_import
from tautils import get_pixbuf_from_journal, convert, data_from_file, \
text_media_type, round_int, chr_to_ord, strtype, get_path
@@ -305,6 +305,8 @@ def stop_logo(tw):
tw.step_time = 0
tw.lc.step = _just_stop()
stop_media(tw.lc)
+ if tw.camera_available:
+ tw.lc.camera.stop_camera_input()
tw.active_turtle.show()
@@ -526,19 +528,17 @@ class LogoCode:
if self.tw.hw == XO1:
self.voltage_gain = 0.00002225
self.voltage_bias = 1.140
- self.camera_pause = 0.6
elif self.tw.hw == XO15:
self.voltage_gain = -0.0001471
self.voltage_bias = 1.695
- self.camera_pause = 0.5
- else:
- self.camera_pause = 2.0
- if self.tw.running_sugar:
- self.imagepath = get_path(self.tw.activity,
- 'data/turtlepic.jpg')
- else:
- self.imagepath = '/tmp/turtlepic.jpg'
+ if self.tw.camera_available:
+ if self.tw.running_sugar:
+ self.imagepath = get_path(self.tw.activity,
+ 'data/turtlepic.png')
+ else:
+ self.imagepath = '/tmp/turtlepic.png'
+ self.camera = Camera(self.imagepath)
def _def_prim(self, name, args, fcn, rprim=False):
""" Define the primitives associated with the blocks """
@@ -1327,9 +1327,9 @@ class LogoCode:
self.filepath = None
dsobject = None
if string[6:] == 'CAMERA':
- if self.tw.camera:
- save_camera_input_to_file(self.imagepath,
- self.camera_pause)
+ if self.tw.camera_available:
+ self.camera.save_camera_input_to_file()
+ self.camera.stop_camera_input()
self.filepath = self.imagepath
elif os.path.exists(string[6:]): # is it a path?
self.filepath = string[6:]
@@ -1476,8 +1476,9 @@ class LogoCode:
array = None
w = self._w()
h = self._h()
- if w > 0 and h > 0 and self.tw.camera:
- save_camera_input_to_file(self.imagepath, self.camera_pause)
+ if w > 0 and h > 0 and self.tw.camera_available:
+ self.camera.save_camera_input_to_file()
+ self.camera.stop_camera_input()
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.imagepath, w, h)
try:
array = pixbuf.get_pixels()