BeRTOS
Data Structures | Defines | Functions
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.

Note:
These tables contain all the printable characters on a 7 segment digit encoded for common cathode and common anode display type.

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:

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:
SSPointer to the SevenSeg structure
Returns:
true if the clear was succesfull, false if the clear was not succesfull.

Definition at line 508 of file led_7seg.c.

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:
SSPointer to the SevenSeg structure

Definition at line 325 of file led_7seg.c.

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:
SSPointer 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.

Definition at line 364 of file led_7seg.c.

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:
SSPointer to the SevenSeg structure
Returns:
true if the display is now locked, false if the display was already locked.

Definition at line 403 of file led_7seg.c.

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:
SSPointer to the SevenSeg structure
sstringString to be displayed
Returns:
0 if all went well, -1 if the display is locked, -2 if the string too long.

Definition at line 217 of file led_7seg.c.

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:
SSPointer to the SevenSeg structure
blinkif true the display will blink
digitif 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.

Definition at line 432 of file led_7seg.c.

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:
SSPointer to the SevenSeg structure
runoncetrue 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.

Definition at line 464 of file led_7seg.c.

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:
SSPointer to the SevenSeg structure
r_speedthe Scrolling speed or display time
Returns:
true if the set was succesfull, false if the set was not succesfull.

Definition at line 486 of file led_7seg.c.

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:
SSPointer to the SevenSeg structure
Returns:
true if the display is unlocked, false if the dispaly is still locked.

Definition at line 379 of file led_7seg.c.