diff options
author | Michael Cetrulo <mail2samus@gmail.com> | 2012-06-16 20:35:11 (GMT) |
---|---|---|
committer | Michael Cetrulo <mail2samus@gmail.com> | 2012-06-16 20:35:11 (GMT) |
commit | 6f35a689e896c1fa3c1c9faa57c580f0da9148e2 (patch) | |
tree | 74df5c2ae531aa674f88bf5cd1d2b66a75d7c75f | |
parent | 3e511197f705a04c9496508e5cf2ff85df0c4aae (diff) |
mas refactorizacion
-rw-r--r-- | LegoJAM.py | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -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() |