From 186ce24e1d132f35475aeafe90a119e5e0e5c295 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Fri, 05 Nov 2010 17:01:07 +0000 Subject: comparing audio_mode vs sensor blocks to ensure proper initialization --- 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 """ -- cgit v0.9.1