led_7seg.h
Go to the documentation of this file.
00001
00089 #ifndef DRV_LED_7SEG_H
00090 #define DRV_LED_7SEG_H
00091 
00092 #include "cfg/cfg_led_7seg.h"
00093 #include <drv/timer.h>
00094 #include <mware/event.h>
00095
00096 /*
00097  * Numbers and Letters Table
00098  * Segments definitions
00099  * Segments macro
00100  *
00101  * These tables contain all the printable
00102  * characters on a 7 segment digit encoded
00103  * for common cathode and common anode
00104  * display type.
00105  *
00106  * 0, 1, 2, 3, 4, 5, 6, 7, 8,
00107  * 9, ., -, A, B, C, D, E, F,
00108  * G, H, I, J, K, L, M, N, O,
00109  * P, Q, R, S, T, U, V, W, X,
00110  * Y, Z, SPACE
00111  *
00112  * Follows the Segments definitions for the
00113  * graphic digits routines and the macro that
00114  * set the graphic digit with the appropriate
00115  * segment.
00116  *
00117  */
00118 #if CONFIG_LED_7SEG_CCAT
00119         static const uint8_t segstable[] =
00120         {
00121                 0x3f, 0x6, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x7, 0x7f,
00122                 0x6f, 0x80, 0x40, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71,
00123                 0x3d, 0x74, 0x30, 0x1e, 0x75, 0x38, 0x15, 0x37, 0x3f,
00124                 0x73, 0x67, 0x50, 0x6d, 0x78, 0x3e, 0x2a, 0x6a, 0x76,
00125                 0x6e, 0x5b, 0x0
00126         };
00127         #define SEGMENT_EMPTY (0x00)
00128         #define SEGMENT_A (0x01)
00129         #define SEGMENT_B (0x02)
00130         #define SEGMENT_C (0x04)
00131         #define SEGMENT_D (0x08)
00132         #define SEGMENT_E (0x10)
00133         #define SEGMENT_F (0x20)
00134         #define SEGMENT_G (0x40)
00135         #define SEGMENT_P (0x80)
00136         #define SET_SEGMENT(var, segment) (var |= segment)
00137 #else
00138         static const uint8_t segstable[] =
00139         {
00140                 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80,
00141                 0x90, 0x7f, 0xbf, 0x88, 0x83, 0xc6, 0xa1, 0x86, 0x8e,
00142                 0xc2, 0x8b, 0xcf, 0xe1, 0x8a, 0xc7, 0xea, 0xc8, 0xc0,
00143                 0x8c, 0x98, 0xaf, 0x92, 0x87, 0xc1, 0xd5, 0x95, 0x89,
00144                 0x91, 0xa4, 0xff
00145         };
00146         #define SEGMENT_EMPTY (0xFF)
00147         #define SEGMENT_A (0xFE)
00148         #define SEGMENT_B (0xFD)
00149         #define SEGMENT_C (0xFB)
00150         #define SEGMENT_D (0xF7)
00151         #define SEGMENT_E (0xEF)
00152         #define SEGMENT_F (0xDF)
00153         #define SEGMENT_G (0xBF)
00154         #define SEGMENT_P (0x7F)
00155         #define SET_SEGMENT(var, segment) (var &= segment)
00156 #endif
00157 
00162 typedef struct SevenSeg
00163 {
00165         uint8_t string[CONFIG_LED_7SEG_STRLEN];
00167         unsigned int string_len;
00169         bool blink;
00171         uint8_t bdigit;
00173         bool runonce;
00175         unsigned int speed;
00177         unsigned int curspeed;
00179         bool firstrun;
00181         unsigned int curpos;
00183         unsigned int curdigit;
00185         bool busyedit;
00186 } SevenSeg;
00187
00188 /* Functions prototypes */
00189
00190 /*
00191  * This is the procedure that fills the seven_seg structure with the translated
00192  * string to display. It swaps also the structures to display the new text when
00193  * all the data is ready to display.
00194  */
00195 int sevenseg_print(SevenSeg *SS, const char *sstring);
00196
00197 /*
00198  * This is the procedure that inits all the structures that rules the 7 segments
00199  * display and set the timer for the proper print/refresh of the text.
00200  */
00201 void sevenseg_init(SevenSeg *SS);
00202
00203 /*
00204  * This is the procedure that does a short print of all segments of all
00205  * digits of the display.
00206  */
00207 void sevenseg_test(SevenSeg *SS);
00208
00209 /*
00210  * This is the procedure that check if the print of the current text is run
00211  * almost one time and we're ready to print a new text.
00212  */
00213 bool sevenseg_isReady(SevenSeg *SS);
00214
00215 /*
00216  * This is the procedure that check if the print of the current text is run
00217  * almost one time and then set the status of the display to "unlocked".
00218  */
00219 bool sevenseg_unlock(SevenSeg *SS);
00220
00221 /*
00222  * This is the procedure that lock the display and permit
00223  * the print of the text.
00224  */
00225 bool sevenseg_lock(SevenSeg *SS);
00226
00227 /*
00228  * This is the procedure that set the blinking of the display.
00229  * You can choose to blink all the display or only a single
00230  * digit.
00231  */
00232 bool sevenseg_setBlink(SevenSeg *SS, bool blink, uint8_t digit);
00233
00234 /*
00235  * This is the procedure that set if the text has to be displayed
00236  * just one time
00237  */
00238 bool sevenseg_setRunonce(SevenSeg *SS, bool runonce);
00239
00240 /*
00241  * This is the procedure that set the scrolling speed of the text
00242  * if the text is longer than the display digits or the
00243  * duration of the display if the text is smaller or equal the
00244  * length of display digits.
00245  */
00246 bool sevenseg_setRunspeed(SevenSeg *SS, unsigned int r_speed);
00247
00248 /*
00249  * This is the procedure that blanks the text to be displayed
00250  * and so on clear the display.
00251  */
00252 bool sevenseg_clear(SevenSeg *SS);
00253
00254 #endif /* DRV_LED_7SEG_H */
00255  //defgroup drivers