[tuxdroid-svn] r761 - firmware/tuxdefs
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-12-06 17:37:01
|
Author: jaguarondi Date: 2007-12-06 18:37:00 +0100 (Thu, 06 Dec 2007) New Revision: 761 Modified: firmware/tuxdefs/api.h firmware/tuxdefs/commands.h firmware/tuxdefs/config.h firmware/tuxdefs/defines.h Log: * And here are the defines that should go with the previous commit. Enjoy. Modified: firmware/tuxdefs/api.h =================================================================== --- firmware/tuxdefs/api.h 2007-12-06 17:32:44 UTC (rev 760) +++ firmware/tuxdefs/api.h 2007-12-06 17:37:00 UTC (rev 761) @@ -188,6 +188,70 @@ */ #define SOUND_VAR_CMD 0xCB +/*! @} */ + +/** + * \name LEDs + * The blue LEDs located inside tux's eyes can be controlled individually by + * changing their intensity from 0 (OFF) to 255 (ON). + * @{ */ + +/** + * Set the rate and step which determine the speed of the fading effect. + * + * The fading increases or decreases the intensity by 'step' each 'rate' times + * 4ms. + * + * Parameters: + * - 1 - LEDs affected by the command, either left, right or both. + * The values are defined in LEDS_t. + * - 2 - rate of the fading effect, the time base is 4ms. + * A value from 1 to 255 will change the rate, + * 0 will leave it unaffected. + * - 3 - step of the fading effect. + * A value from 1 to 255 will change the step, + * 0 will leave it unaffected. + */ +#define LED_FADE_SPEED_CMD 0xD0 + +/** + * Set both LEDs to a given intensity with a fading effect controlled by + * 'rate' and 'step'. + * + * Parameters: + * - 1 - Which LEDs. + * - 2 - Intensity that the LEDs should be set to. Fading may be applied if + * set. + */ +#define LED_SET_CMD 0xD1 + +/** + * Set the intensity boundaries for the blink command. + * + * Parameters: + * - 1 - Which LEDs. + * - 2 - Maximum intensity. + * - 3 - Minimum intensity. + */ +#define LED_BLINK_RANGE_CMD 0xD2 + +/** + * Blink LEDs 'number' times with a frequency determined by 'pulse_width'. + * + * Parameters: + * - 1 - Which LEDs + * - 2 - Number of toggles the LED should do. + * - 3 - Pulse width of the blinking effect. Affected by the fading effect. + * + * The pulse width won't be shorter than what is set for the fading effect, + * even if you set a low value here. + */ +#define LED_BLINK_CMD 0xD3 + +/*! @} */ + +/*! @} */ + /** States of the audio recording (flash programming) process */ typedef enum audiorec_status { @@ -200,8 +264,5 @@ NO_SOUND, } audiorec_status_t; -/*! @} */ - -/*! @} */ #endif /* _API_H_ */ Modified: firmware/tuxdefs/commands.h =================================================================== --- firmware/tuxdefs/commands.h 2007-12-06 17:32:44 UTC (rev 760) +++ firmware/tuxdefs/commands.h 2007-12-06 17:37:00 UTC (rev 761) @@ -87,7 +87,6 @@ #define LED_L_OFF_CMD 0x1D /* Turn left LED off */ #define LED_R_ON_CMD 0x1E /* Turn right LED on */ #define LED_R_OFF_CMD 0x1F /* Turn right LED off */ -#define LED_BLINK_CMD 0x9A /* Blink both LEDs multiple time */ /* 1st parameter: number of LED toggles */ /* 2nd parameter: delay between each LED toggle, in multiple of 4ms */ @@ -105,7 +104,7 @@ /* 1st parameter: 1 to write the sound * 0 to not write the sound*/ -#define ERASE_FLASH_CMD 0xD0 /* get indexes of the flash sound bank [1] */ +#define ERASE_FLASH_CMD 0x54 /* get indexes of the flash sound bank [1] */ #define TEST_SOUND_CMD 0x10 /* test the audio input and output [1] */ #define MUTE_CMD 0x92 /* mute/unmute the audio amplifier */ Modified: firmware/tuxdefs/config.h =================================================================== --- firmware/tuxdefs/config.h 2007-12-06 17:32:44 UTC (rev 760) +++ firmware/tuxdefs/config.h 2007-12-06 17:37:00 UTC (rev 761) @@ -26,6 +26,7 @@ #include "commands.h" #include "api.h" +#include "defines.h" /* * Standalone events @@ -48,26 +49,29 @@ /* Head button event */ #define HEAD_E_SEQ {\ - 0, LED_BLINK_CMD, 2, 30, 0, /* blink led's once */\ + 0, LED_FADE_SPEED_CMD, 3, 1, 10, \ + 0, LED_BLINK_CMD, 3, 2, 30, /* blink led's once */\ END_OF_ACTIONS\ } /* Left flipper button event */ #define LEFT_FLIP_E_SEQ {\ - 0, LED_BLINK_CMD, 2, 30, 0, /* blink led's once */\ + 0, LED_FADE_SPEED_CMD, 3, 1, 10, \ + 0, LED_BLINK_CMD, 3, 2, 30, /* blink led's once */\ END_OF_ACTIONS\ } /* Right flipper event */ #define RIGHT_FLIP_E_SEQ {\ - 0, LED_BLINK_CMD, 2, 30, 0, /* blink led's once */\ + 0, LED_FADE_SPEED_CMD, 3, 1, 10, \ + 0, LED_BLINK_CMD, 3, 2, 30, /* blink led's once */\ END_OF_ACTIONS\ } /* Start charging event */ #define CHARGER_START_E_SEQ {\ 0, MOVE_MOUTH_CMD, 2, 0, 0, /* move the mouth */\ - 0, LED_BLINK_CMD, 4, 50, 0, /* blink led's twice */\ + 0, LED_BLINK_CMD, 3, 4, 50, /* blink led's twice */\ 0, PLAY_SOUND_CMD, 3, 0, 0, /* play a sound */\ END_OF_ACTIONS\ } @@ -82,8 +86,8 @@ /* Entering sleep event */ #define SLEEP_ENTER_E_SEQ {\ 10, CLOSE_EYES_CMD, PLAY_SOUND_CMD, 1, 0, /* */\ - /* the delay (first byte) is necessary for the movement to complete before - * sleep is entered */\ + /* the delay (first byte set to 10) is necessary for the movement \ + * to complete before sleep is entered */ \ END_OF_ACTIONS\ } @@ -95,13 +99,13 @@ /* RF connection event */ #define RF_CONN_E_SEQ {\ - 0, LED_ON_CMD, 0, 0, 0, /* tun on the leds */\ + 0, LED_SET_CMD, LED_BOTH, 0xFF, 0, /* turn on the leds */\ END_OF_ACTIONS\ } /* RF disconnection event */ #define RF_DISCONN_E_SEQ {\ - 0, LED_OFF_CMD, 0, 0, 0, /* tun off the leds */\ + 0, LED_SET_CMD, LED_BOTH, 0, 0, /* turn off the leds */\ END_OF_ACTIONS\ } Modified: firmware/tuxdefs/defines.h =================================================================== --- firmware/tuxdefs/defines.h 2007-12-06 17:32:44 UTC (rev 760) +++ firmware/tuxdefs/defines.h 2007-12-06 17:37:00 UTC (rev 761) @@ -164,6 +164,24 @@ /*! @} */ /** + * \name LEDs + */ +/*! @{ */ +/** + * Type indicating which led should be affected by the command. + * The left LED is affected to bit0 and the right LED is at bit1. This + * simplifies comparisons. + */ +typedef enum +{ + LED_LEFT = 0x01, + LED_RIGHT = 0x02, + LED_BOTH = 0x03, +} LEDS_t; + +/*! @} */ + +/** * \name Movements */ /*! @{ */ |