7 Segments LED Displays Driver
[BeRTOS peripherals drivers]
7 segments LED displays (headers) More...
Data Structures | |
| struct | SevenSeg |
| Context data for Display functions. More... | |
Defines | |
| #define | CONFIG_LED_7SEG_CCAT 0 |
| Use a Common Cathode display. | |
| #define | CONFIG_LED_7SEG_DIGIT 4 |
| Number of digit present in the LED display. | |
| #define | CONFIG_LED_7SEG_STRLEN 255 |
| Max lenght of the string to be displayed. | |
| #define | CONFIG_LED_7SEG_SSPEED 10 |
| Default scrolling speed (ms * CONFIG_LED_7SEG_RTIME). | |
| #define | CONFIG_LED_7SEG_RTIME 5 |
| Default refresh time (ms). | |
Functions | |
| int | sevenseg_print (SevenSeg *SS, const char *sstring) |
| Print a string on the display. | |
| void | sevenseg_init (SevenSeg *SS) |
| initialize the structure and the timer for the display | |
| bool | sevenseg_isReady (SevenSeg *SS) |
| check if is possible to do a new print | |
| bool | sevenseg_unlock (SevenSeg *SS) |
| unlock the SevenSeg structure and stops the print | |
| bool | sevenseg_lock (SevenSeg *SS) |
| lock the SeveSeg structure and starts a new print | |
| bool | sevenseg_setBlink (SevenSeg *SS, bool blink, uint8_t digit) |
| set the blinking of the digits of the display | |
| bool | sevenseg_setRunonce (SevenSeg *SS, bool runonce) |
| set if the text has to be displayed just one time | |
| bool | sevenseg_setRunspeed (SevenSeg *SS, unsigned int r_speed) |
| set the scrolling speed of the text | |
| bool | sevenseg_clear (SevenSeg *SS) |
| clear the display | |
Numbers and Letters Table. | |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ., -, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, SPACE | |
| static const uint8_t | segstable [] |
Detailed Description
7 segments LED displays (headers)
Here you find the prototypes and the data structures that format and holds the text that has to be displayed by the 7 segments display.
The main function is the sevenseg_print() that is called by your software to display the text, also important is the sevenseg_init() that initialize the data structures and set the refresh timer, you need to call this procedure just one time in the init procedure of your software before any use of the sevenseg_print().
Usage:
To use succesfully the display you have to follow these steps:
- Create the structure and init the display
- Check if the display is ready to accept a new print with the function sevenseg_isReady()
- Unlock the display with the function sevenseg_unlock() NOTE: when the display is unlocked the displaying of any text is stopped but the data (text and attributes like text position, blinking etc etc) are not erased.
- Set the wanted text attributes with sevenseg_set* functions
- Print the wanted text with sevenseg_print()
- Lock the display with sevenseg_lock()
When the display is locked the displaying of the text starts.
static Seven_Seg display; // ... sevenseg_init(&display); while (!sevenseg_isReady(&display)) ; sevenseg_unlock(&display); sevenseg_setBlink(&display,false,0); sevenseg_setRunonce(&display,false); sevenseg_setRunspeed(&display,10); if ((sevenseg_print(&display, "made with bertos.")) != 0) return -1; sevenseg_lock(&display);
Function Documentation
| bool sevenseg_clear | ( | SevenSeg * | SS | ) |
clear the display
This is the procedure that blanks the text to be displayed and so on clear the display.
- Parameters:
-
SS Pointer to the SevenSeg structure
- Returns:
- true if the clear was succesfull, false if the clear was not succesfull.
| void sevenseg_init | ( | SevenSeg * | SS | ) |
initialize the structure and the timer for the display
This is the procedure that inits all the structures that rules the 7 segments display and set the timer for the proper print/refresh of the text.
- Parameters:
-
SS Pointer to the SevenSeg structure
| bool sevenseg_isReady | ( | SevenSeg * | SS | ) |
check if is possible to do a new print
This is the procedure that check if the print of the current text is run almost one time and we're ready to print a new text.
- Parameters:
-
SS Pointer to the SevenSeg structure
- Returns:
- true if we can print a new text, false if we're still printing the previous text for the first time and we have to wait.
| bool sevenseg_lock | ( | SevenSeg * | SS | ) |
lock the SeveSeg structure and starts a new print
This is the procedure that lock the display and permit the print of the text.
- Parameters:
-
SS Pointer to the SevenSeg structure
- Returns:
- true if the display is now locked, false if the display was already locked.
| int sevenseg_print | ( | SevenSeg * | SS, | |
| const char * | sstring | |||
| ) |
Print a string on the display.
This is the procedure that fills the seven_seg structure with the translated string to display. It swaps also the structures to display the new text when all the data is ready to display.
- Parameters:
-
SS Pointer to the SevenSeg structure sstring String to be displayed
- Returns:
- 0 if all went well, -1 if the display is locked, -2 if the string too long.
| bool sevenseg_setBlink | ( | SevenSeg * | SS, | |
| bool | blink, | |||
| uint8_t | digit | |||
| ) |
set the blinking of the digits of the display
This is the procedure that set the blinking of the display. You can choose to blink all the display or only a single digit.
- Parameters:
-
SS Pointer to the SevenSeg structure blink if true the display will blink digit if 0 all the digits have to blink, else the digit that has to blink
- Returns:
- true if the set was succesfull, false if the set was not succesfull.
| bool sevenseg_setRunonce | ( | SevenSeg * | SS, | |
| bool | runonce | |||
| ) |
set if the text has to be displayed just one time
This is the procedure that set if the text has to be displayed just one time
- Parameters:
-
SS Pointer to the SevenSeg structure runonce true if the text has to be displayed only one time, false if the text has to be displayed till next print
- Returns:
- true if the set was succesfull, false if the set was not succesfull.
| bool sevenseg_setRunspeed | ( | SevenSeg * | SS, | |
| unsigned int | r_speed | |||
| ) |
set the scrolling speed of the text
This is the procedure that set the scrolling speed of the text if the text is longer than the display digits or the duration of the display if the text is smaller or equal the length of display digits.
- Parameters:
-
SS Pointer to the SevenSeg structure r_speed the Scrolling speed or display time
- Returns:
- true if the set was succesfull, false if the set was not succesfull.
| bool sevenseg_unlock | ( | SevenSeg * | SS | ) |
unlock the SevenSeg structure and stops the print
This is the procedure that check if the print of the current text is run almost one time and then set the status of the display to "unlocked".
- Parameters:
-
SS Pointer to the SevenSeg structure
- Returns:
- true if the display is unlocked, false if the dispaly is still locked.
