Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Cetrulo <mail2samus@gmail.com>2012-06-16 20:35:11 (GMT)
committer Michael Cetrulo <mail2samus@gmail.com>2012-06-16 20:35:11 (GMT)
commit6f35a689e896c1fa3c1c9faa57c580f0da9148e2 (patch)
tree74df5c2ae531aa674f88bf5cd1d2b66a75d7c75f
parent3e511197f705a04c9496508e5cf2ff85df0c4aae (diff)
mas refactorizacion
-rw-r--r--LegoJAM.py18
1 files changed, 6 insertions, 12 deletions
diff --git a/LegoJAM.py b/LegoJAM.py
index 25a8355..8913a2e 100644
--- a/LegoJAM.py
+++ b/LegoJAM.py
@@ -146,20 +146,14 @@ class Robot(gobject.GObject):
gobject.timeout_add(1000, self.handle)
def run_motor(self, motor):
- if motor == "A":
- self.motorA.run(power=127, regulated=False)
- elif motor == "B":
- self.motorB.run(power=127, regulated=False)
- elif motor == "C":
- self.motorC.run(power=127, regulated=False)
+ method_name = 'motor%s' % motor
+ method = getattr(self, method_name)
+ method.run(power=127, regulated=False)
def stop_motor(self, motor):
- if motor == "A":
- self.motorA.brake()
- elif motor == "B":
- self.motorB.brake()
- elif motor == "C":
- self.motorC.brake()
+ method_name = 'motor%s' % motor
+ method = getattr(self, method_name)
+ method.brake()
def handle(self):
valor_boton = self.presion.get_sample()