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-11-05 17:01:07 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-11-05 17:01:07 (GMT)
commit186ce24e1d132f35475aeafe90a119e5e0e5c295 (patch)
treea4795685a7c32d528dd784c365d011d9f93f4c44 /TurtleArt/talogo.py
parentd1995c224b0fa5279ee80ce78870476525e0670d (diff)
comparing audio_mode vs sensor blocks to ensure proper initialization
Diffstat (limited to 'TurtleArt/talogo.py')
-rw-r--r--TurtleArt/talogo.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py
index f849760..7c6ca1c 100644
--- a/TurtleArt/talogo.py
+++ b/TurtleArt/talogo.py
@@ -1087,15 +1087,26 @@ class LogoCode:
""" Find any sensor blocks and set the appropriate sensor type """
for name in ['sound', 'volume', 'pitch', 'resistance', 'voltage']:
if len(self.tw.block_list.get_similar_blocks('block', name)):
+ _logger.debug('find_sensor_blocks: found %s block' % (name))
+ _logger.debug('audio mode was %s' % (self.audio_mode))
if name in ['sound', 'volume', 'pitch']:
- self.tw.audiograb.set_sensor_type()
- return
+ if self.audio_mode != 'sound':
+ self.tw.audiograb.set_sensor_type()
+ self.audio_mode = 'sound'
+ _logger.debug('audio mode is %s' % (self.audio_mode))
+ return
elif name == 'resistance':
- self.tw.audiograb.set_sensor_type(SENSOR_DC_BIAS)
- return
+ if self.audio_mode != 'resistance':
+ self.tw.audiograb.set_sensor_type(SENSOR_DC_BIAS)
+ self.audio_mode = 'resistance'
+ _logger.debug('audio mode is %s' % (self.audio_mode))
+ return
elif name == 'voltage':
- self.tw.audiograb.set_sensor_type(SENSOR_DC_NO_BIAS)
- return
+ if self.audio_mode != 'voltage':
+ self.tw.audiograb.set_sensor_type(SENSOR_DC_NO_BIAS)
+ self.audio_mode = 'voltage'
+ _logger.debug('audio mode is %s' % (self.audio_mode))
+ return
def update_label_value(self, name, value=None):
""" Update the label of value blocks to reflect current value """