Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPootle daemon <pootle@pootle.sugarlabs.org>2013-11-10 05:30:34 (GMT)
committer Pootle daemon <pootle@pootle.sugarlabs.org>2013-11-10 05:30:34 (GMT)
commitaef76f8f3765f2994204747eae257f887a3cb5fc (patch)
treed6da556d84a26e254c127de77e0f6baffd06aa38
parentd1baec9324c4663abb5dc396da338ea35426a740 (diff)
parent12857ace39932b36826f37a464d50ecede0ee3e0 (diff)
Merge branch 'master' of git.sugarlabs.org:turtleart/mainline
-rw-r--r--plugins/audio_sensors/audio_sensors.py182
1 files changed, 78 insertions, 104 deletions
diff --git a/plugins/audio_sensors/audio_sensors.py b/plugins/audio_sensors/audio_sensors.py
index eec73bb..5184896 100644
--- a/plugins/audio_sensors/audio_sensors.py
+++ b/plugins/audio_sensors/audio_sensors.py
@@ -82,36 +82,24 @@ class Audio_sensors(Plugin):
colors=["#FF6060", "#A06060"],
help_string=_('Palette of sensor blocks'),
position=6)
-
+ hidden = True
if self._status:
- palette.add_block('sound',
- style='box-style',
- label=_('sound'),
- help_string=_('raw microphone input signal'),
- value_block=True,
- prim_name='sound')
-
- palette.add_block('volume',
- style='box-style',
- label=_('loudness'),
- help_string=_('microphone input volume'),
- value_block=True,
- prim_name='volume')
- else:
- palette.add_block('sound',
- hidden=True,
- style='box-style',
- label=_('sound'),
- help_string=_('raw microphone input signal'),
- value_block=True,
- prim_name='sound')
- palette.add_block('volume',
- hidden=True,
- style='box-style',
- label=_('loudness'),
- help_string=_('microphone input volume'),
- value_block=True,
- prim_name='volume')
+ hidden = False
+
+ palette.add_block('sound',
+ hidden=hidden,
+ style='box-style',
+ label=_('sound'),
+ help_string=_('raw microphone input signal'),
+ value_block=True,
+ prim_name='sound')
+ palette.add_block('volume',
+ hidden=hidden,
+ style='box-style',
+ label=_('loudness'),
+ help_string=_('microphone input volume'),
+ value_block=True,
+ prim_name='volume')
self._parent.lc.def_prim(
'sound', 0,
@@ -127,21 +115,17 @@ class Audio_sensors(Plugin):
kwarg_descs={'channel': ConstantArg(0)},
call_afterwards=self.after_volume))
+ hidden = True
if PITCH_AVAILABLE and self._status:
- palette.add_block('pitch',
- style='box-style',
- label=_('pitch'),
- help_string=_('microphone input pitch'),
- value_block=True,
- prim_name='pitch')
- else:
- palette.add_block('pitch',
- hidden=True,
- style='box-style',
- label=_('pitch'),
- help_string=_('microphone input pitch'),
- value_block=True,
- prim_name='pitch')
+ hidden = False
+
+ palette.add_block('pitch',
+ hidden=hidden,
+ style='box-style',
+ label=_('pitch'),
+ help_string=_('microphone input pitch'),
+ value_block=True,
+ prim_name='pitch')
self._parent.lc.def_prim(
'pitch', 0,
Primitive(self.prim_pitch,
@@ -149,72 +133,56 @@ class Audio_sensors(Plugin):
kwarg_descs={'channel': ConstantArg(0)},
call_afterwards=self.after_pitch))
+ hidden = True
if self.hw in [XO1, XO15, XO175, XO4, XO30] and self._status:
+ # Calibration based on http://bugs.sugarlabs.org/ticket/4649
if self.hw == XO1:
self.voltage_gain = 0.000022
self.voltage_bias = 1.14
elif self.hw == XO15:
self.voltage_gain = -0.00015
self.voltage_bias = 1.70
- elif self.hw in [XO175, XO4]: # recalibrate in light of #3675?
- self.voltage_gain = 0.000071
- self.voltage_bias = 0.55
+ elif self.hw == XO175: # Range 0.01V to 3.01V
+ self.voltage_gain = 0.000101
+ self.voltage_bias = 1.371
+ elif self.hw == XO4: # Range 0.17V to 3.08V
+ self.voltage_gain = 0.0004073
+ self.voltage_bias = 1.6289
else: # XO 3.0
self.voltage_gain = 0.000077
self.voltage_bias = 0.72
- palette.add_block('resistance',
- style='box-style',
- label=_('resistance'),
- help_string=_('microphone input resistance'),
- value_block=True,
- prim_name='resistance')
- palette.add_block('voltage',
- style='box-style',
- label=_('voltage'),
- help_string=_('microphone input voltage'),
- value_block=True,
- prim_name='voltage')
- else:
- palette.add_block('resistance',
- hidden=True,
- style='box-style',
- label=_('resistance'),
- help_string=_('microphone input resistance'),
- prim_name='resistance')
- palette.add_block('voltage',
- hidden=True,
- style='box-style',
- label=_('voltage'),
- help_string=_('microphone input voltage'),
- prim_name='voltage')
-
- # FIXME: Only add stereo capture for XO15 (broken on ARM #3675)
+ hidden = False
+
+ palette.add_block('resistance',
+ hidden=hidden,
+ style='box-style',
+ label=_('resistance'),
+ help_string=_('microphone input resistance'),
+ prim_name='resistance')
+ palette.add_block('voltage',
+ hidden=hidden,
+ style='box-style',
+ label=_('voltage'),
+ help_string=_('microphone input voltage'),
+ prim_name='voltage')
+
+ hidden = True
+ # Only add stereo capture for XO15 (broken on ARM #3675)
if self.hw in [XO15] and self._status:
- palette.add_block('resistance2',
- style='box-style',
- label=_('resistance') + '2',
- help_string=_('microphone input resistance'),
- value_block=True,
- prim_name='resistance2')
- palette.add_block('voltage2',
- style='box-style',
- label=_('voltage') + '2',
- help_string=_('microphone input voltage'),
- value_block=True,
- prim_name='voltage2')
- else:
- palette.add_block('resistance2',
- hidden=True,
- style='box-style',
- label=_('resistance') + '2',
- help_string=_('microphone input resistance'),
- prim_name='resistance2')
- palette.add_block('voltage2',
- hidden=True,
- style='box-style',
- label=_('voltage') + '2',
- help_string=_('microphone input voltage'),
- prim_name='voltage2')
+ hidden = False
+
+ palette.add_block('resistance2',
+ hidden=hidden,
+ style='box-style',
+ label=_('resistance') + '2',
+ help_string=_('microphone input resistance'),
+ prim_name='resistance2')
+ palette.add_block('voltage2',
+ hidden=hidden,
+ style='box-style',
+ label=_('voltage') + '2',
+ help_string=_('microphone input voltage'),
+ prim_name='voltage2')
self._parent.lc.def_prim(
'resistance', 0,
Primitive(self.prim_resistance,
@@ -415,7 +383,7 @@ class Audio_sensors(Plugin):
elif self.hw == XO15:
self._prim_resistance(channel)
return self._resistance[channel]
- # FIXME: For XO175: channel assignment is seemingly random
+ # For XO175: channel assignment is seemingly random
# (#3675), one of them will be 0
else:
self._prim_resistance(0)
@@ -429,8 +397,8 @@ class Audio_sensors(Plugin):
''' return resistance sensor value '''
buf = self.ringbuffer[channel].read(None, self.input_step)
if len(buf) > 0:
- # See <http://bugs.sugarlabs.org/ticket/552#comment:7>
- # TODO: test this calibration on XO 1.5, XO 1.75
+ # See http://bugs.sugarlabs.org/ticket/552#comment:7
+ # and http://bugs.sugarlabs.org/ticket/4649
avg_buf = float(_avg(buf))
if self.hw == XO1:
self._resistance[channel] = \
@@ -440,16 +408,22 @@ class Audio_sensors(Plugin):
self._resistance[channel] = (420000000 / avg_buf) - 13500
else:
self._resistance[channel] = 420000000
- elif self.hw in [XO175, XO4]:
+ elif self.hw == XO175: # Range 0 to inf ohms
if avg_buf < 30700:
self._resistance[channel] = \
- 0.12 * ((180000000 / (30700 - avg_buf)) - 3150)
+ (48000000. / (15740 - avg_buf)) - 1640
+ else:
+ self._resistance[channel] = 999999999
+ elif self.hw == XO4: # Range 0 to inf ohms
+ if avg_buf < 6629:
+ self._resistance[channel] = \
+ (50000000. / (6629 - avg_buf)) - 3175
else:
self._resistance[channel] = 999999999
else: # XO 3.0
if avg_buf < 30514:
self._resistance[channel] = \
- (46000000 / (30514 - avg_buf)) - 1150
+ (46000000. / (30514 - avg_buf)) - 1150
else:
self._resistance[channel] = 999999999
if self._resistance[channel] < 0: