BeRTOS
led_7seg.h
Go to the documentation of this file.
00001 
00090 #ifndef DRV_LED_7SEG_H
00091 #define DRV_LED_7SEG_H
00092 
00093 #include "cfg/cfg_led_7seg.h"
00094 #include <drv/timer.h>
00095 #include <mware/event.h>
00096 
00112 #if CONFIG_LED_7SEG_CCAT
00113         static const uint8_t segstable[] =
00114         {
00115                 0x3f, 0x6, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x7, 0x7f,
00116                 0x6f, 0x80, 0x40, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71,
00117                 0x3d, 0x74, 0x30, 0x1e, 0x75, 0x38, 0x15, 0x37, 0x3f,
00118                 0x73, 0x67, 0x50, 0x6d, 0x78, 0x3e, 0x2a, 0x6a, 0x76,
00119                 0x6e, 0x5b, 0x0
00120         };
00121 #else
00122         static const uint8_t segstable[] =
00123         {
00124                 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80,
00125                 0x90, 0x7f, 0xbf, 0x88, 0x83, 0xc6, 0xa1, 0x86, 0x8e,
00126                 0xc2, 0x8b, 0xcf, 0xe1, 0x8a, 0xc7, 0xea, 0xc8, 0xc0,
00127                 0x8c, 0x98, 0xaf, 0x92, 0x87, 0xc1, 0xd5, 0x95, 0x89,
00128                 0x91, 0xa4, 0xff
00129         };
00130 #endif
00131 
00137 typedef struct SevenSeg
00138 {
00140         uint8_t string[CONFIG_LED_7SEG_STRLEN];
00142         unsigned int string_len;
00144         bool blink;
00146         uint8_t bdigit;
00148         bool runonce;
00150         unsigned int speed;
00152         unsigned int curspeed;
00154         bool firstrun;
00156         unsigned int curpos;
00158         unsigned int curdigit;
00160         bool busyedit;
00161 } SevenSeg;
00162 
00163 /* Functions prototypes */
00164 
00165 /*
00166  * This is the procedure that fills the seven_seg structure with the translated
00167  * string to display. It swaps also the structures to display the new text when
00168  * all the data is ready to display.
00169  */
00170 int sevenseg_print(SevenSeg *SS, const char *sstring);
00171 
00172 /*
00173  * This is the procedure that inits all the structures that rules the 7 segments
00174  * display and set the timer for the proper print/refresh of the text.
00175  */
00176 void sevenseg_init(SevenSeg *SS);
00177 
00178 /*
00179  * This is the procedure that does a short print of all segments of all
00180  * digits of the display.
00181  */
00182 void sevenseg_test(SevenSeg *SS);
00183 
00184 /*
00185  * This is the procedure that check if the print of the current text is run
00186  * almost one time and we're ready to print a new text.
00187  */
00188 bool sevenseg_isReady(SevenSeg *SS);
00189 
00190 /*
00191  * This is the procedure that check if the print of the current text is run
00192  * almost one time and then set the status of the display to "unlocked".
00193  */
00194 bool sevenseg_unlock(SevenSeg *SS);
00195 
00196 /*
00197  * This is the procedure that lock the display and permit
00198  * the print of the text.
00199  */
00200 bool sevenseg_lock(SevenSeg *SS);
00201 
00202 /*
00203  * This is the procedure that set the blinking of the display.
00204  * You can choose to blink all the display or only a single
00205  * digit.
00206  */
00207 bool sevenseg_setBlink(SevenSeg *SS, bool blink, uint8_t digit);
00208 
00209 /*
00210  * This is the procedure that set if the text has to be displayed
00211  * just one time
00212  */
00213 bool sevenseg_setRunonce(SevenSeg *SS, bool runonce);
00214 
00215 /*
00216  * This is the procedure that set the scrolling speed of the text
00217  * if the text is longer than the display digits or the
00218  * duration of the display if the text is smaller or equal the
00219  * length of display digits.
00220  */
00221 bool sevenseg_setRunspeed(SevenSeg *SS, unsigned int r_speed);
00222 
00223 /*
00224  * This is the procedure that blanks the text to be displayed
00225  * and so on clear the display.
00226  */
00227 bool sevenseg_clear(SevenSeg *SS);
00228 
00229 #endif /* DRV_LED_7SEG_H */
00230  //defgroup drivers