|
@@ -27,15 +27,6 @@
|
27
|
27
|
#include <maa/aio.h>
|
28
|
28
|
#include <maa/gpio.h>
|
29
|
29
|
|
30
|
|
-//
|
31
|
|
-// A
|
32
|
|
-// ---
|
33
|
|
-// F | | B
|
34
|
|
-// -G-
|
35
|
|
-// E | | C
|
36
|
|
-// ---
|
37
|
|
-// D
|
38
|
|
-
|
39
|
30
|
#define SEG_A 0b00000001
|
40
|
31
|
#define SEG_B 0b00000010
|
41
|
32
|
#define SEG_C 0b00000100
|
|
@@ -50,32 +41,84 @@
|
50
|
41
|
|
51
|
42
|
#define PULSE_LENGTH 50
|
52
|
43
|
|
53
|
|
-#define HIGH 1
|
54
|
|
-#define LOW 0
|
|
44
|
+#define HIGH 1
|
|
45
|
+#define LOW 0
|
55
|
46
|
|
56
|
47
|
namespace upm {
|
57
|
48
|
|
|
49
|
+/**
|
|
50
|
+ * @brief C++ API for Seven segments screen
|
|
51
|
+ *
|
|
52
|
+ * This file defines the TM1637 C++ interface for lib4digitdisplay
|
|
53
|
+ *
|
|
54
|
+ * @snippet 4digitdisplay.cxx Interesting
|
|
55
|
+ *
|
|
56
|
+ * A
|
|
57
|
+ * ---
|
|
58
|
+ * F | | B
|
|
59
|
+ * -G-
|
|
60
|
+ * E | | C
|
|
61
|
+ * ---
|
|
62
|
+ * D
|
|
63
|
+ *
|
|
64
|
+ */
|
58
|
65
|
class TM1637 {
|
59
|
66
|
public:
|
|
67
|
+ /**
|
|
68
|
+ * Instanciates a TM1637 object
|
|
69
|
+ *
|
|
70
|
+ * @param di data pin
|
|
71
|
+ * @param dcki clock pin
|
|
72
|
+ */
|
60
|
73
|
TM1637 (uint8_t di, uint8_t dcki);
|
|
74
|
+ /**
|
|
75
|
+ * TM1637 object destructor, this will close all used Gpio
|
|
76
|
+ * pins (di and dcki)
|
|
77
|
+ */
|
61
|
78
|
~TM1637 ();
|
|
79
|
+
|
|
80
|
+ /**
|
|
81
|
+ * Set the brightness of the seven segment display
|
|
82
|
+ *
|
|
83
|
+ * @param level The brightness level of leds
|
|
84
|
+ */
|
62
|
85
|
maa_result_t setBrightness (uint8_t level);
|
|
86
|
+
|
|
87
|
+ /**
|
|
88
|
+ * Set the the segment screen data and number of segments
|
|
89
|
+ *
|
|
90
|
+ * @param segments[] data to write on the segments, each elemnt
|
|
91
|
+ * in array is segment
|
|
92
|
+ * @param length number of elements in segments array
|
|
93
|
+ * @param pos data writing offset
|
|
94
|
+ */
|
63
|
95
|
maa_result_t setSegments (const uint8_t segments[], uint8_t length = 4, uint8_t pos = 0);
|
|
96
|
+
|
|
97
|
+ /**
|
|
98
|
+ * Write message on the screen.
|
|
99
|
+ *
|
|
100
|
+ * @param msg The message to be written on the sreen
|
|
101
|
+ */
|
64
|
102
|
maa_result_t write (std::string msg);
|
65
|
|
-
|
|
103
|
+
|
|
104
|
+ /**
|
|
105
|
+ * Return name of the component
|
|
106
|
+ */
|
66
|
107
|
std::string name()
|
67
|
108
|
{
|
68
|
109
|
return m_name;
|
69
|
110
|
}
|
|
111
|
+
|
70
|
112
|
private:
|
71
|
113
|
maa_result_t start();
|
72
|
114
|
maa_result_t stop();
|
73
|
115
|
maa_result_t writeByte (uint8_t value);
|
74
|
116
|
maa_result_t pinMode (maa_gpio_context ctx, gpio_dir_t mode);
|
75
|
117
|
|
76
|
|
- std::string m_name;
|
77
|
118
|
maa_gpio_context m_clkPinCtx;
|
78
|
119
|
maa_gpio_context m_dataPinCtx;
|
|
120
|
+
|
|
121
|
+ std::string m_name;
|
79
|
122
|
uint8_t m_brightness;
|
80
|
123
|
};
|
81
|
124
|
|