diff options
author | Emiliano Pastorino <epastorino@plan.ceibal.edu.uy> | 2011-03-21 16:49:13 (GMT) |
---|---|---|
committer | Emiliano Pastorino <epastorino@plan.ceibal.edu.uy> | 2011-03-21 16:49:13 (GMT) |
commit | 02c54ad2369127f4ab7fb407ea98d187f61088e4 (patch) | |
tree | 936a50de94eae9c19c5b3058b8974b7c78e02c21 | |
parent | 9770ea3a591946d9cb04879b0259d7f148fb69d9 (diff) |
- New block: set color sensor led
-rw-r--r-- | plugins/nxt_plugin.py | 29 | ||||
-rw-r--r-- | po/es.po | 7 |
2 files changed, 31 insertions, 5 deletions
diff --git a/plugins/nxt_plugin.py b/plugins/nxt_plugin.py index bad7dcf..0842c24 100644 --- a/plugins/nxt_plugin.py +++ b/plugins/nxt_plugin.py @@ -39,7 +39,7 @@ from dbus.mainloop.glib import DBusGMainLoop from lib.nxt.locator import BrickNotFoundError from lib.nxt.motor import PORT_A, PORT_B, PORT_C, Motor, SynchronizedMotors from lib.nxt.sensor import PORT_1, PORT_2, PORT_3, PORT_4, Touch, Color20, \ - Ultrasonic + Ultrasonic, Type NXT_SENSORS = {'nxttouch': 0, 'nxtultrasonic': 1, 'nxtcolor': 2} @@ -201,7 +201,7 @@ class Nxt_plugin(Plugin): palette.add_block('nxtsyncmotors', style='basic-style-3arg', label=[_('sync\nmotors'), _('power'), _('rotations'), - _('direction')], + _('steering')], default=[100, 0, 1], help_string=_('Synchronize motors'), prim_name='nxtsyncmotors') @@ -228,6 +228,14 @@ class Nxt_plugin(Plugin): self.tw.lc.def_prim('nxtbrake', 1, lambda self, x: primitive_dictionary['nxtbrake'](x)) + primitive_dictionary['nxtsetcolor'] = self._prim_nxtsetcolor + palette.add_block('nxtsetcolor', + style='basic-style-2arg', + label=[_('set light'), _('color'), _('port')], + help_string=_('Set color sensor light'), + prim_name='nxtsetcolor') + self.tw.lc.def_prim('nxtsetcolor', 2, lambda self, x, y: + primitive_dictionary['nxtsetcolor'](x, y)) def start(self): # This gets called by the start button @@ -252,10 +260,10 @@ class Nxt_plugin(Plugin): def _prim_nxtturnmotor(self, port, turns, power): return Motor(self.nxtbrick, port).turn(power, int(turns*360)) - def _prim_nxtsyncmotors(self, power, direction, turns): + def _prim_nxtsyncmotors(self, power, steering, turns): motorB = Motor(self.nxtbrick, PORT_B) motorC = Motor(self.nxtbrick, PORT_C) - syncmotors = SynchronizedMotors(motorB, motorC, direction) + syncmotors = SynchronizedMotors(motorB, motorC, steering) return syncmotors.turn(power, int(turns*360)) def _prim_nxtplaytone(self, freq, time): @@ -310,3 +318,16 @@ class Nxt_plugin(Plugin): def _prim_nxtbrake(self, port): return Motor(self.nxtbrick, port).brake() + + def _prim_nxtsetcolor(self, color, port): + if color == WHITE: + color = Type.COLORFULL + elif color == CONSTANTS['red']: + color = Type.COLORRED + elif color == CONSTANTS['green']: + color = Type.COLORGREEN + elif color == CONSTANTS['blue']: + color = Type.COLORBLUE + else: + color = Type.COLORNONE + Color20(self.nxtbrick, port).set_light_color(color) @@ -1487,9 +1487,14 @@ msgstr "girar\nmotor" #: /home/emiliano/src/lego/mainline/plugins/nxt_plugin.py:81 #: /home/emiliano/src/lego/mainline/plugins/nxt_plugin.py:193 #: /home/emiliano/src/lego/mainline/plugins/nxt_plugin.py:215 +#: /home/emiliano/src/lego/mainline/plugins/nxt_plugin.py:234 msgid "port" msgstr "puerto" +#: /home/emiliano/src/lego/mainline/plugins/nxt_plugin.py:234 +msgid "set light" +msgstr "encender luz" + #: /home/emiliano/src/lego/mainline/plugins/nxt_plugin.py:82 #: /home/emiliano/src/lego/mainline/plugins/nxt_plugin.py:203 msgid "rotations" @@ -1617,7 +1622,7 @@ msgid "" msgstr "sincronizar\nmotores" #: /home/emiliano/src/lego/mainline/plugins/nxt_plugin.py:204 -msgid "direction" +msgid "steering" msgstr "dirección" #: /home/emiliano/src/lego/mainline/plugins/nxt_plugin.py:206 |