#include <rdline.h>
#include "main.h"
+#include "shovel.h"
/* init spickle position at beginning */
static void shovel_autopos(void)
{
+ printf_P(PSTR("shovel autopos..."));
pwm_ng_set(SHOVEL_PWM, -500);
wait_ms(1000);
pwm_ng_set(LEFT_SPICKLE_PWM, 0);
encoders_spi_set_value(SHOVEL_ENCODER, 0);
+ printf_P(PSTR("ok\r\n"));
+}
+
+static uint8_t shovel_is_at_pos(int32_t pos)
+{
+ int32_t diff;
+ diff = pos - encoders_spi_get_value(SHOVEL_ENCODER);
+ if (diff < 0)
+ diff = -diff;
+ if (diff < 500)
+ return 1;
+ return 0;
+}
+
+uint8_t shovel_is_up(void)
+{
+ return shovel_is_at_pos(SHOVEL_UP);
+}
+
+uint8_t shovel_is_down(void)
+{
+ return shovel_is_at_pos(SHOVEL_DOWN);
}
void shovel_init(void)