summaryrefslogtreecommitdiffstats
path: root/actuators
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2012-06-07 19:54:38 +0200
committerSebastian Reichel <sre@ring0.de>2012-06-07 19:54:38 +0200
commitdfbb403fcd4d3d6ceec22d2e70091686c53606f3 (patch)
tree430ea41f647fba88dcf26cb2a4f9b3eace8fcc61 /actuators
downloadmicrocopterd-dfbb403fcd4d3d6ceec22d2e70091686c53606f3.tar.bz2
initial code import
Diffstat (limited to 'actuators')
-rw-r--r--actuators/blinkm.vala154
-rw-r--r--actuators/motor-controller.vala19
-rw-r--r--actuators/motor/atmostripe.vala24
3 files changed, 197 insertions, 0 deletions
diff --git a/actuators/blinkm.vala b/actuators/blinkm.vala
new file mode 100644
index 0000000..be98260
--- /dev/null
+++ b/actuators/blinkm.vala
@@ -0,0 +1,154 @@
+/* Copyright 2012, Sebastian Reichel <sre@ring0.de>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+public class BlinkM : I2CDevice {
+ public struct Command {
+ uint8 id;
+ uint8 line;
+ uint8 duration;
+ uint8 cmd;
+ uint8 parameter1;
+ uint8 parameter2;
+ uint8 parameter3;
+ }
+
+ public enum Script {
+ STARTUP,
+ RGB,
+ WHITE_FLASH,
+ RED_FLASH,
+ GREEN_FLASH,
+ BLUE_FLASH,
+ CYAN_FLASH,
+ MAGENTA_FLASH,
+ YELLOW_FLASH,
+ BLACK,
+ HUE_CYCLE,
+ MOOD_LIGHT,
+ VIRTUAL_CANDLE,
+ WATER_REFLECTIONS,
+ OLD_NEON,
+ THE_SEASONS,
+ THUNDERSTORM,
+ STOP_LIGHT,
+ MORSE_CODE
+ }
+
+ public BlinkM(uint8 dev, uint8 addr = 0x09) throws I2CError {
+ base(dev, addr);
+ }
+
+ public void get_firmware_version(out char major, out char minor) throws I2CError {
+ write_byte('Z');
+ major = (char) read_byte();
+ minor = (char) read_byte();
+ }
+
+ public uint8 get_address() throws I2CError {
+ write_byte('a');
+ return read_byte();
+ }
+
+ public void set_address(uint8 addr) throws I2CError {
+ write_byte('A');
+ write_byte(addr);
+ write_byte(0xd0);
+ write_byte(0x0d);
+ write_byte(addr);
+ setup_address(addr);
+ }
+
+ public void script_stop() throws I2CError {
+ write_byte('o');
+ }
+
+ public void script_play(Script id, uint8 repeat = 0, uint8 start = 0) throws I2CError {
+ write_byte('p');
+ write_byte(id);
+ write_byte(repeat);
+ write_byte(start);
+ }
+
+ public void set(uint8 red, uint8 green, uint8 blue) throws I2CError {
+ write_byte('n');
+ write_byte(red);
+ write_byte(green);
+ write_byte(blue);
+ }
+
+ public void get(out uint8 red, out uint8 green, out uint8 blue) throws I2CError {
+ write_byte('g');
+ red = read_byte();
+ green = read_byte();
+ blue = read_byte();
+ }
+
+ public void fade(uint8 red, uint8 green, uint8 blue) throws I2CError {
+ write_byte('c');
+ write_byte(red);
+ write_byte(green);
+ write_byte(blue);
+ }
+
+ public void set_fade_speed(uint8 speed) throws I2CError {
+ write_byte('f');
+ write_byte(speed);
+ }
+
+ public void set_time_adjust(int8 adjust) throws I2CError {
+ write_byte('t');
+ write_byte((uint8) adjust);
+ }
+
+ public void script_set_line(Command cmd) throws I2CError {
+ write_byte('W');
+ write_byte(cmd.id);
+ write_byte(cmd.line);
+ write_byte(cmd.duration);
+ write_byte(cmd.cmd);
+ write_byte(cmd.parameter1);
+ write_byte(cmd.parameter2);
+ write_byte(cmd.parameter3);
+ }
+
+ public void script_get_line(out Command cmd) throws I2CError {
+ write_byte('R');
+ cmd = Command();
+ cmd.id = read_byte();
+ cmd.line = read_byte();
+ cmd.duration = read_byte();
+ cmd.cmd = read_byte();
+ cmd.parameter1 = read_byte();
+ cmd.parameter2 = read_byte();
+ cmd.parameter3 = read_byte();
+ }
+
+ public void script_setup(Script id, uint8 length, uint8 repeats) throws I2CError
+ requires (id == 0) requires (length <= 50) {
+ write_byte('L');
+ write_byte(id);
+ write_byte(length);
+ write_byte(repeats);
+ }
+
+ public void setup_startup(uint8 mode, Script id, uint8 repeat, uint8 fade_speed, int8 time_adjust) throws I2CError {
+ write_byte('B');
+ write_byte(mode);
+ write_byte(id);
+ write_byte(repeat);
+ write_byte(fade_speed);
+ write_byte(time_adjust);
+ }
+}
diff --git a/actuators/motor-controller.vala b/actuators/motor-controller.vala
new file mode 100644
index 0000000..fb596dd
--- /dev/null
+++ b/actuators/motor-controller.vala
@@ -0,0 +1,19 @@
+/* Copyright 2012, Sebastian Reichel <sre@ring0.de>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+public interface MotorController : Device {
+ public abstract void set(uint8 m, uint8 v);
+ public abstract void set_all(uint8 v);
+}
diff --git a/actuators/motor/atmostripe.vala b/actuators/motor/atmostripe.vala
new file mode 100644
index 0000000..0cc4eef
--- /dev/null
+++ b/actuators/motor/atmostripe.vala
@@ -0,0 +1,24 @@
+/* Copyright 2012, Sebastian Reichel <sre@ring0.de>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+public class AtmostripeMotorController : SerialDevice, MotorController {
+ public void set(uint8 m, uint8 v) {
+ /* */
+ }
+
+ public void set_all(uint8 v) {
+ /* */
+ }
+}