Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TurtleArt/talogo.py1
-rw-r--r--TurtleArt/tawindow.py8
-rw-r--r--plugins/audio_sensors/audio_sensors.py25
3 files changed, 15 insertions, 19 deletions
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py
index 4662429..944b9bf 100644
--- a/TurtleArt/talogo.py
+++ b/TurtleArt/talogo.py
@@ -162,7 +162,6 @@ class LogoCode:
self.stacks['stack2'] = None
self.tw.saving_svg = False
- self.find_value_blocks()
if self.trace > 0:
self.update_values = True
else:
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 3ce6b71..f2da535 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -419,9 +419,6 @@ class TurtleArtWindow():
if self.running_sugar:
self.activity.recenter()
- if self.interactive_mode:
- self._start_plugins()
-
# Look for a 'start' block
for blk in self.just_blocks():
if find_start_stack(blk):
@@ -1695,7 +1692,6 @@ class TurtleArtWindow():
dy = 20
blk.expand_in_y(dy)
else:
- self._start_plugins()
self._run_stack(blk)
return
@@ -1761,7 +1757,6 @@ class TurtleArtWindow():
elif blk.name in PYTHON_SKIN:
self._import_py()
else:
- self._start_plugins()
self._run_stack(blk)
elif blk.name in ['sandwichtop_no_arm_no_label',
@@ -1776,7 +1771,6 @@ class TurtleArtWindow():
collapse_stack(top)
else:
- self._start_plugins()
self._run_stack(blk)
def _expand_boolean(self, blk, blk2, dy):
@@ -1868,6 +1862,8 @@ class TurtleArtWindow():
""" Run a stack of blocks. """
if blk is None:
return
+ self.lc.find_value_blocks() # Are there blocks to update?
+ self._start_plugins() # Let the plugins know we are running.
top = find_top_block(blk)
self.lc.run_blocks(top, self.just_blocks(), True)
if self.interactive_mode:
diff --git a/plugins/audio_sensors/audio_sensors.py b/plugins/audio_sensors/audio_sensors.py
index 39bad17..580d12f 100644
--- a/plugins/audio_sensors/audio_sensors.py
+++ b/plugins/audio_sensors/audio_sensors.py
@@ -56,9 +56,10 @@ class Audio_sensors(Plugin):
def __init__(self, parent):
self._parent = parent
+ self._status = True # TODO: test for audio device
+ # These flags are referenced by audiograb
self.hw = self._parent.hw
self.running_sugar = self._parent.running_sugar
- self._status = True # TODO: test for audio device
def setup(self):
# set up audio-sensor-specific blocks
@@ -169,27 +170,26 @@ class Audio_sensors(Plugin):
def _update_audio_mode(self):
""" If there are sensor blocks, set the appropriate audio mode """
- if not hasattr(self._parent.lc, 'value_blocks'):
+ if not hasattr(self._parent.lc, 'value_blocks_to_update'):
return
for name in ['sound', 'volume', 'pitch']:
- if name in self._parent.lc.value_blocks:
- if len(self._parent.lc.value_blocks[name]) > 0:
+ if name in self._parent.lc.value_blocks_to_update:
+ if len(self._parent.lc.value_blocks_to_update[name]) > 0:
self.audiograb.set_sensor_type()
return
- if 'resistance' in self._parent.lc.value_blocks:
- if len(self._parent.lc.value_blocks['resistance']) > 0:
+ if 'resistance' in self._parent.lc.value_blocks_to_update:
+ if len(self._parent.lc.value_blocks_to_update['resistance']) > 0:
self.audiograb.set_sensor_type(SENSOR_DC_BIAS)
return
- if 'voltage' in self._parent.lc.value_blocks:
- if len(self._parent.lc.value_blocks['voltage']) > 0:
+ if 'voltage' in self._parent.lc.value_blocks_to_update:
+ if len(self._parent.lc.value_blocks_to_update['voltage']) > 0:
self.audiograb.set_sensor_type(SENSOR_DC_NO_BIAS)
return
def stop(self):
# This gets called by the stop button
- if self._status:
- if self.audio_started:
- self.audiograb.pause_grabbing()
+ if self._status and self.audio_started:
+ self.audiograb.pause_grabbing()
def goto_background(self):
# This gets called when your process is sent to the background
@@ -203,7 +203,8 @@ class Audio_sensors(Plugin):
def quit(self):
# This gets called by the quit button
- self.stop()
+ if self._status and self.audio_started:
+ self.audiograb.stop_grabbing()
def _status_report(self):
debug_output('Reporting audio sensor status: %s' % (str(self._status)))