diff options
author | Sebastian Reichel <sre@ring0.de> | 2012-06-28 19:59:55 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2012-06-28 19:59:55 +0200 |
commit | 1e123c3670209132fa82cf02e95b8425a0c070aa (patch) | |
tree | f424d4f26191ac0fedbfd5416f0835ea6453cf93 /actuators | |
parent | 8a08b9dce9cfc161494ddb07a1c979c7796780ff (diff) | |
download | microcopterd-1e123c3670209132fa82cf02e95b8425a0c070aa.tar.bz2 |
implement atmostripe motor controller
Diffstat (limited to 'actuators')
-rw-r--r-- | actuators/motor-controller.vala | 4 | ||||
-rw-r--r-- | actuators/motor/atmostripe.vala | 34 |
2 files changed, 31 insertions, 7 deletions
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; } } |