cup1
[aversive.git] / projects / microb2010 / ballboard / actuator.c
index 367e241..c635fe9 100644 (file)
 
 #include <rdline.h>
 
+#include "actuator.h"
 #include "main.h"
 
+#define ROLLER_ON      -ROLLER_SPEED
+#define ROLLER_OFF     0
+#define ROLLER_REVERSE ROLLER_SPEED
+
+#define FORKROT_DEPLOYED -55000
+#define FORKROT_MID -33000
+#define FORKROT_PACKED   -4000
+
+void roller_on(void)
+{
+       cs_set_consign(&ballboard.roller.cs, ROLLER_ON);
+}
+
+void roller_off(void)
+{
+       cs_set_consign(&ballboard.roller.cs, ROLLER_OFF);
+}
+
+void roller_reverse(void)
+{
+       cs_set_consign(&ballboard.roller.cs, ROLLER_REVERSE);
+}
+
+void fork_deploy(void)
+{
+       cs_set_consign(&ballboard.forkrot.cs, FORKROT_DEPLOYED);
+}
+
+void fork_pack(void)
+{
+       cs_set_consign(&ballboard.forkrot.cs, FORKROT_PACKED);
+}
+
+void fork_mid(void)
+{
+       cs_set_consign(&ballboard.forkrot.cs, FORKROT_MID);
+}
+
+void actuator_init(void)
+{
+       printf_P(PSTR("fork autopos..."));
+       pwm_ng_set(FORKROT_PWM, 400);
+       wait_ms(1000);
+       pwm_ng_set(FORKROT_PWM, 0);
+       encoders_spi_set_value(FORKROT_ENCODER, 0);
+       printf_P(PSTR("ok\r\n"));
+       ballboard.forkrot.on = 1;
+}