Friedrich-Alexander-Universität Erlangen-Nürnberg  /   Technische Fakultät  /   Department Informatik

 

7seg.h
Go to the documentation of this file.
1 #ifndef _7SEG_H
2 #define _7SEG_H
3 
4 #include <stdint.h>
5 
6 #include "check.h"
7 
8 /**
9  * \addtogroup SEG 7seg (Seven Segment Display)
10  *
11  * \brief Controls the two 7-segment displays on the board
12  *
13  * The two 7-segment displays of the SPiCboard share one common
14  * port of the MCU. The two displays can be connected and
15  * disconnected from the port using two transistors. By quickly
16  * and periodically connecting and disconnecting the displays
17  * an observer will not be able to notice when a display is
18  * disabled and both displays can be used apparently simultaneously.
19  *
20  * The module uses the 8-bit <b>Timer 2</b> of the ATmega328PB
21  * to multiplex the two 7-segment displays
22  *
23  * \note As the timer is used, interrupts must be enabled for the display to work
24  * (if one of the 7 segment displays seems to be not working
25  * it is quite likely that interrupts are not enabled!)
26  *
27  * \sa timer.h
28  *
29  * @{
30  * \file 7seg.h
31  * \version \$Rev: 9414 $
32  */
33 
34 /**
35  * \brief Prints a number in the range [-9; 99] on the 7-segment display
36  *
37  * \param nmbr the number to print
38  *
39  * \retval 0 success
40  * \retval -1 nmbr is smaller than -9
41  * \retval -2 nmbr is greater than 99
42  */
43 int8_t sb_7seg_showNumber(int8_t nmbr);
44 
45 /**
46  * \brief Prints the hexadecimal representation of an 8-bit unsigned integer on the 7-segment display
47  *
48  * \param nmbr the number to print
49  *
50  * \retval 0 on success
51  * \retval !0 on error
52  */
53 int8_t sb_7seg_showHexNumber(uint8_t nmbr);
54 
55 /**
56  * \brief Prints a 2 character string on the 7-segment display
57  *
58  * Supported characters are in the group [-_ 0-9A-Za-z] (contains space).
59  * Read <a href="http://en.wikipedia.org/wiki/Seven-segment_display_character_representations">this</a>
60  * article for possible representations of these characters. Two
61  * characters of the set should never have the same representation.
62  * No differentiation is made between upper- and lowercase characters.
63  *
64  * \param str the 0-terminated string
65  *
66  * \retval 0 success
67  * \retval -1 character at position 0 not printable
68  * \retval -2 character at position 1 not printable
69  * \retval -3 both characters not printable
70  * \retval -4 str is an empty string
71  */
72 int8_t sb_7seg_showString(const char *str);
73 
74 /**
75  * \brief Set the LEDs of the 7-segment display manually
76  *
77  * The bitfield contains one bit for each of the 7 segment LEDs of a block.
78  * A set bit enables and a cleared bit disables the corresponding LED.
79  * The most significant bit determines the block:
80  * If set, the first block (tens' place) will be used, if cleared the second block (ones' place)
81  * \image html 7seg.png
82  * For example a value of 0x86 (decimal 134, binary representation: 1000 0110) will enlight the LEDs 1 and 2 of the first block.
83  *
84  * \param mask 8-bit bitfield describing the desired 7 segment display state
85  */
86 void sb_7seg_setMask(uint8_t mask);
87 
88 /**
89  * \brief Disables the 7-segment displays
90  *
91  * Any running alarms are unregistered.
92  */
93 void sb_7seg_disable(void);
94 
95 /** @}*/
96 
97 #endif
98 
void sb_7seg_setMask(uint8_t mask)
Set the LEDs of the 7-segment display manually.
void sb_7seg_disable(void)
Disables the 7-segment displays.
int8_t sb_7seg_showString(const char *str)
Prints a 2 character string on the 7-segment display.
int8_t sb_7seg_showHexNumber(uint8_t nmbr)
Prints the hexadecimal representation of an 8-bit unsigned integer on the 7-segment display...
int8_t sb_7seg_showNumber(int8_t nmbr)
Prints a number in the range [-9; 99] on the 7-segment display.