From 1e123c3670209132fa82cf02e95b8425a0c070aa Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Thu, 28 Jun 2012 19:59:55 +0200 Subject: implement atmostripe motor controller --- actuators/motor-controller.vala | 4 ++-- actuators/motor/atmostripe.vala | 34 +++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 7 deletions(-) (limited to 'actuators') diff --git a/actuators/motor-controller.vala b/actuators/motor-controller.vala index d348e53..b638e06 100644 --- a/actuators/motor-controller.vala +++ b/actuators/motor-controller.vala @@ -18,6 +18,6 @@ public interface MotorController : Device { public abstract uint8 max { get ; } public abstract void init(KeyFile cfg) throws Error; - public abstract void set_single(uint8 m, uint8 v); - public abstract void set_all(uint8 v); + public abstract bool set_single(uint8 m, uint8 v); + public abstract bool set_all(uint8 v); } diff --git a/actuators/motor/atmostripe.vala b/actuators/motor/atmostripe.vala index ad996e7..23f0fda 100644 --- a/actuators/motor/atmostripe.vala +++ b/actuators/motor/atmostripe.vala @@ -23,15 +23,39 @@ public class AtmostripeMotorController : SerialDevice, MotorController { } public void init(KeyFile cfg) throws Error { - /* */ + var device = cfg.get_string("AtmostripeMotorController", "device"); + setup(device); } - public void set_single(uint8 m, uint8 v) { - /* */ + public bool set_single(uint8 engine, uint8 speed) { + uint8[2] buf = new uint8[2]; + buf[0] = engine; + buf[1] = speed; + + if(engine > 5) + return false; + + write(buf, 2); + read(buf, 2); + + if(buf[0] == '.') + return true; + else + return false; } - public void set_all(uint8 v) { - /* */ + public bool set_all(uint8 speed) { + uint8[2] buf = new uint8[2]; + buf[0] = 6; + buf[1] = speed; + + write(buf, 2); + read(buf, 2); + + if(buf[0] == '.') + return true; + else + return false; } } -- cgit v1.2.3