Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
s7seg.hpp
1 /*
2  Title --- display/s7seg.hpp
3 
4  Copyright (C) 2013 Giacomo Trudu - wicker25[at]gmail[dot]com
5 
6  This file is part of Rpi-hw.
7 
8  Rpi-hw is free software: you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation version 3 of the License.
11 
12  Rpi-hw is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with Rpi-hw. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 
22 #ifndef _RPI_HW_DISPLAY_S7SEG_HPP_
23 #define _RPI_HW_DISPLAY_S7SEG_HPP_
24 
25 #include <rpi-hw/types.hpp>
26 #include <rpi-hw/exception.hpp>
27 #include <rpi-hw/math.hpp>
28 
29 #include <rpi-hw/iface/base.hpp>
30 #include <rpi-hw/iface/output.hpp>
31 
32 namespace rpihw { // Begin main namespace
33 
34 /*!
35  @namespace rpihw::display
36  @brief Namespace of the displays.
37 */
38 
39 namespace display { // Begin displays namespace
40 
41 /*!
42  @class s7seg
43  @brief Seven-segment display controller.
44 
45  @example display/s7seg.cpp
46 */
47 class s7seg {
48 
49 public:
50 
51  //! Display segments.
52  enum Segments {
53 
54  SEGMENT_A = 0,
55  SEGMENT_B = 1,
56  SEGMENT_C = 2,
57  SEGMENT_D = 3,
58  SEGMENT_E = 4,
59  SEGMENT_F = 5,
60  SEGMENT_G = 6,
61  SEGMENT_DP = 7
62  };
63 
64  //! Outputs of digits.
65  static const uint8_t output[12];
66 
67  /*!
68  @brief Constructor method.
69  @param[in] a The GPIO pin connected to the segment a.
70  @param[in] b The GPIO pin connected to the segment b.
71  @param[in] c The GPIO pin connected to the segment c.
72  @param[in] d The GPIO pin connected to the segment d.
73  @param[in] e The GPIO pin connected to the segment e.
74  @param[in] f The GPIO pin connected to the segment f.
75  @param[in] g The GPIO pin connected to the segment g.
76  */
77  s7seg( uint8_t a, uint8_t b, uint8_t c, uint8_t d,
78  uint8_t e, uint8_t f, uint8_t g );
79 
80  /*!
81  @brief Constructor method.
82  @param[in] a The GPIO pin connected to the segment a.
83  @param[in] b The GPIO pin connected to the segment b.
84  @param[in] c The GPIO pin connected to the segment c.
85  @param[in] d The GPIO pin connected to the segment d.
86  @param[in] e The GPIO pin connected to the segment e.
87  @param[in] f The GPIO pin connected to the segment f.
88  @param[in] g The GPIO pin connected to the segment g.
89  @param[in] dp The GPIO pin connected to the segment dp (decimal point).
90  */
91  s7seg( uint8_t a, uint8_t b, uint8_t c, uint8_t d,
92  uint8_t e, uint8_t f, uint8_t g, uint8_t dp );
93 
94  //! Destructor method.
95  virtual ~s7seg();
96 
97  /*!
98  @brief Sets the value of the display.
99  @param[in] value The new value of the display.
100  */
101  void set( float value );
102 
103  /*!
104  @brief Returns the value of the display.
105  @return The current value of the display.
106  */
107  float get() const;
108 
109 protected:
110 
111  //! Output interface to the display.
113 
114  //! Value of the display.
115  float m_value;
116 };
117 
118 } // End of displays namespace
119 
120 } // End of main namespace
121 
122 
123 // Include inline methods
124 #include <rpi-hw/display/s7seg-inl.hpp>
125 
126 #endif /* _RPI_HW_DISPLAY_S7SEG_HPP_ */
Output interface.
Definition: output.hpp:43
iface::output * m_display
Output interface to the display.
Definition: s7seg.hpp:112
s7seg(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f, uint8_t g)
Constructor method.
float m_value
Value of the display.
Definition: s7seg.hpp:115
static const uint8_t output[12]
Outputs of digits.
Definition: s7seg.hpp:65
Segments
Display segments.
Definition: s7seg.hpp:52
Seven-segment display controller.
Definition: s7seg.hpp:47
void set(float value)
Sets the value of the display.
virtual ~s7seg()
Destructor method.