[tuxdroid-svn] r707 - firmware/tuxcore/trunk
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2007-11-16 14:28:54
|
Author: Paul_R Date: 2007-11-16 15:28:53 +0100 (Fri, 16 Nov 2007) New Revision: 707 Modified: firmware/tuxcore/trunk/motors.c Log: * Adapt the motors function to the new API commands. - When the mouth move, the tux.cmd.mouth_open/close commands can be used. - When the wings waves, the tux.cmd.wings_up/down stop the wings in the desired position. Modified: firmware/tuxcore/trunk/motors.c =================================================================== --- firmware/tuxcore/trunk/motors.c 2007-11-16 12:06:07 UTC (rev 706) +++ firmware/tuxcore/trunk/motors.c 2007-11-16 14:28:53 UTC (rev 707) @@ -54,6 +54,10 @@ /** Minimum difference required between the period the flippers are moving from * up to down and from down to up. */ #define FLIPPERS_RESETTIMER_HYST 0x10 +/** Mouth final state */ +#define MOUTH_UDEF 0 +#define MOUTH_OPEN 1 +#define MOUTH_CLOSE 2 /** Number of periods remaining before stopping the eyes. * Normally used when braking, to stop the motor after a short period of @@ -71,6 +75,8 @@ * Normally used when braking, to stop the motor after a short period of * inversion. */ static uint8_t flippers_stop_delay; +/** A flag which indicate the final wanted state for the mouth */ +static uint8_t mouth_final_state; /** Number of movements remaining before stopping the flippers. */ uint8_t flippers_move_counter; /** PWM applied on the flippers motor. */ @@ -386,6 +392,9 @@ { if (!(PSW_MOUTH_PIN & PSW_MOUTH_C_MK)) move_mouth(1); + if (MOT_MOUTH_PT |= MOT_MOUTH_MK) + mouth_final_state = MOUTH_OPEN; + move_mouth(2); } /** @@ -398,6 +407,9 @@ { if (!(PSW_MOUTH_PIN & PSW_MOUTH_O_MK)) move_mouth(1); + if (MOT_MOUTH_PT |= MOT_MOUTH_MK) + mouth_final_state = MOUTH_CLOSE; + move_mouth(2); } /** @@ -424,8 +436,16 @@ if (mouth_move_counter) { mouth_move_counter--; + if (mouth_final_state != MOUTH_UDEF) + { + if ((mouth_final_state == MOUTH_OPEN) && !(PSW_MOUTH_PIN & PSW_MOUTH_O_MK)) + mouth_move_counter = 0; + else if ((mouth_final_state == MOUTH_CLOSE) && !(PSW_MOUTH_PIN & PSW_MOUTH_C_MK)) + mouth_move_counter = 0; + } if (!mouth_move_counter) { + mouth_final_state = MOUTH_UDEF; stop_mouth_motor(); invert_mouth_motor(); mouth_stop_delay = MOUTH_BRAKING_DLY; @@ -542,6 +562,8 @@ { if (gStatus.pos == 0) wave_flippers(1,5); + else + flippers_move_counter = 2; } /** @@ -558,6 +580,8 @@ { if (gStatus.pos == 1) wave_flippers(1,5); + else + flippers_move_counter = 2; } /** |