From f5456f4aa1d4ec38fee4190cc8067b5e7de1a459 Mon Sep 17 00:00:00 2001 From: Julien Balleyguier Date: Sat, 12 May 2012 12:37:23 +0200 Subject: digital/io-hub/src/guybrush/ : Adding a position_to_drop_cd function This has been done to have a proper signal to tell the bottom clamp it has to open --- digital/io-hub/src/guybrush/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'digital/io-hub/src/guybrush/main.c') diff --git a/digital/io-hub/src/guybrush/main.c b/digital/io-hub/src/guybrush/main.c index 326cb423..8239b263 100644 --- a/digital/io-hub/src/guybrush/main.c +++ b/digital/io-hub/src/guybrush/main.c @@ -106,6 +106,9 @@ static uint8_t main_stats_clamp_zero_last_io_; /** Clamp zero stats: last position. */ static uint16_t main_stats_clamp_zero_last_position_; +/** Position to drop CD */ +static int position_to_drop; + /** Main initialisation. */ static void main_init (void) @@ -176,6 +179,8 @@ main_event_to_fsm (void) || !IO_GET (CONTACT_LOWER_CLAMP_SENSOR_3) || !IO_GET (CONTACT_LOWER_CLAMP_SENSOR_4)) FSM_HANDLE_E (AI, coin_detected); + if ((int16_t) (mimot_get_motor0_position() - position_to_drop) > 0) + FSM_HANDLE_E (AI, time_to_drop_coin); /* Jack. */ if (!contact_get_jack ()) FSM_HANDLE_E (AI, jack_inserted); @@ -395,6 +400,11 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) #undef c } +void main_set_drop_coin_pos(int pos_to_drop) +{ + position_to_drop = pos_to_drop; +} + int main (int argc, char **argv) { -- cgit v1.2.3