SegLCDLib
Loading...
Searching...
No Matches
SegLCD_HT1621_LCM59011.h
Go to the documentation of this file.
1#ifndef SEGLCD_HT1621_LCM59011_H
2#define SEGLCD_HT1621_LCM59011_H
3
4#include <SegDriver_HT1621.h>
5
27 public:
28 typedef enum : uint8_t {
29 UNIT_A = (1 << 0), // 0x02:0x80
30 UNIT_M = (1 << 1), // 0x06:0x80
31 UNIT_PERCENT = (1 << 2), // 0x08:0x10
32 UNIT_H = (1 << 3), // 0x0A:0x08
33 } UnitFlags;
34
35 typedef enum : uint8_t {
36 LABEL_MCB = (1 << 0), // 0x00:0x80
37 } LabelFlags;
38
39 typedef enum : uint32_t {
40 // Address 0x08
41 SYMBOL_WHEEL = (1UL << 0), // 0x08:0x20
42 SYMBOL_ECO = (1UL << 1), // 0x08:0x40
43 SYMBOL_UPS = (1UL << 2), // 0x08:0x80
44
45 // Address 0x0A
46 SYMBOL_GSM = (1UL << 3), // 0x0A:0x10
47 SYMBOL_BLUETOOTH = (1UL << 4), // 0x0A:0x20
48
49 // Address 0x0C
50 SYMBOL_SUN = (1UL << 5), // 0x0C:0x01
51 SYMBOL_LIGHTNING = (1UL << 6), // 0x0C:0x02
52 SYMBOL_PLUG = (1UL << 7), // 0x0C:0x04
53 SYMBOL_WARNING = (1UL << 8), // 0x0C:0x08
54 SYMBOL_OUTLINE = (1UL << 9), // 0x0C:0x80
56
57 SegLCD_HT1621_LCM59011(uint8_t chipselect, uint8_t data, uint8_t write, uint8_t read = -1);
58 void init() override;
59 void setBatteryLevel(uint8_t level);
60 void setSignalLevel(uint8_t level);
61 void setUnits(uint8_t units);
62 void clearUnits(uint8_t units);
63 void setLabels(uint8_t labels);
64 void clearLabels(uint8_t labels);
65 void setSymbols(uint32_t symbols);
66 void clearSymbols(uint32_t symbols);
67 void setWarningSymbol(bool state, uint8_t index = 0);
68 size_t write(uint8_t ch) override;
69
70 private:
71 static constexpr uint8_t RAM_SIZE = 7;
72 static constexpr uint8_t DIGITS = 4;
73
74 // Colon
75 static constexpr uint8_t COLON_ADDRESS = 0x04;
76 static constexpr uint8_t COLON_BIT = 0x80;
77 static constexpr uint8_t COLON_COL = 2; // Colon between D2 and D3
78 static constexpr uint8_t FLAG_COLON_DISPLAYED = 0x01;
79
80 // Battery: spans 0x0A and 0x0C
81 static constexpr uint8_t MAX_BATTERY_LEVEL = 6;
82
83 // Signal (wifi bars)
84 static constexpr uint8_t MAX_SIGNAL_LEVEL = 4;
85 static constexpr uint8_t SIGNAL_ADDRESS = 0x08;
86 static constexpr uint8_t SIGNAL_MASK = 0x0F;
87
88 // Unit bit constants
89 static constexpr uint8_t UNIT_BIT_A = 0x80; // at 0x02
90 static constexpr uint8_t UNIT_BIT_M = 0x80; // at 0x06
91 static constexpr uint8_t UNIT_BIT_PERCENT = 0x10; // at 0x08
92 static constexpr uint8_t UNIT_BIT_H = 0x08; // at 0x0A
93
94 // Label bit constants
95 static constexpr uint8_t LABEL_BIT_MCB = 0x80; // at 0x00
96
97 // Symbol bit constants — address 0x08
98 static constexpr uint8_t SYMBOL_BIT_WHEEL = 0x20;
99 static constexpr uint8_t SYMBOL_BIT_ECO = 0x40;
100 static constexpr uint8_t SYMBOL_BIT_UPS = 0x80;
101
102 // Symbol bit constants — address 0x0A
103 static constexpr uint8_t SYMBOL_BIT_GSM = 0x10;
104 static constexpr uint8_t SYMBOL_BIT_BLUETOOTH = 0x20;
105
106 // Symbol bit constants — address 0x0C
107 static constexpr uint8_t SYMBOL_BIT_SUN = 0x01;
108 static constexpr uint8_t SYMBOL_BIT_LIGHTNING = 0x02;
109 static constexpr uint8_t SYMBOL_BIT_PLUG = 0x04;
110 static constexpr uint8_t SYMBOL_BIT_WARNING = 0x08;
111 static constexpr uint8_t SYMBOL_BIT_OUTLINE = 0x80;
112
113 // Label/Symbol mapping structures
114 struct FlagBit {
115 uint32_t flag;
116 uint8_t bit;
117 };
118
120 uint8_t address;
121 FlagBit bits[8]; // terminated by {0, 0}
122 };
123
124 static const AddressMapping* _getUnitMap(size_t &count) {
125 static constexpr AddressMapping map[] = {
126 {0x02, {{UNIT_A, UNIT_BIT_A}}},
127 {0x06, {{UNIT_M, UNIT_BIT_M}}},
128 {0x08, {{UNIT_PERCENT, UNIT_BIT_PERCENT}}},
129 {0x0A, {{UNIT_H, UNIT_BIT_H}}},
130 };
131 count = sizeof(map) / sizeof(map[0]);
132 return map;
133 }
134
135 static const AddressMapping* _getSymbolMap(size_t &count) {
136 static constexpr AddressMapping map[] = {
137 {0x08, {
141 }},
142 {0x0A, {
145 }},
146 {0x0C, {
152 }},
153 };
154 count = sizeof(map) / sizeof(map[0]);
155 return map;
156 }
157
158 void _setColon(uint8_t row, uint8_t col, bool state) override;
159
160 void _updateUnits(uint8_t units, bool set);
161 void _updateLabels(uint8_t labels, bool set);
162 void _updateSymbols(uint32_t symbols, bool set);
163
164 uint8_t _mapSegments(uint8_t val);
165};
166#endif
HT1621 LCD segment display driver.
Definition SegDriver_HT1621.h:12
LCM59011 LCD (HT1621).
Definition SegLCD_HT1621_LCM59011.h:26
static constexpr uint8_t COLON_BIT
Definition SegLCD_HT1621_LCM59011.h:76
void _updateSymbols(uint32_t symbols, bool set)
Definition SegLCD_HT1621_LCM59011.cpp:74
static constexpr uint8_t COLON_COL
Definition SegLCD_HT1621_LCM59011.h:77
void setSymbols(uint32_t symbols)
Definition SegLCD_HT1621_LCM59011.cpp:107
static const AddressMapping * _getSymbolMap(size_t &count)
Definition SegLCD_HT1621_LCM59011.h:135
static constexpr uint8_t MAX_SIGNAL_LEVEL
Definition SegLCD_HT1621_LCM59011.h:84
static constexpr uint8_t RAM_SIZE
Definition SegLCD_HT1621_LCM59011.h:71
void init() override
Initialize GPIO pins for communication.
Definition SegLCD_HT1621_LCM59011.cpp:8
static constexpr uint8_t SYMBOL_BIT_WARNING
Definition SegLCD_HT1621_LCM59011.h:110
uint8_t _mapSegments(uint8_t val)
Definition SegLCD_HT1621_LCM59011.cpp:156
UnitFlags
Definition SegLCD_HT1621_LCM59011.h:28
@ UNIT_A
Definition SegLCD_HT1621_LCM59011.h:29
@ UNIT_M
Definition SegLCD_HT1621_LCM59011.h:30
@ UNIT_H
Definition SegLCD_HT1621_LCM59011.h:32
@ UNIT_PERCENT
Definition SegLCD_HT1621_LCM59011.h:31
static constexpr uint8_t DIGITS
Definition SegLCD_HT1621_LCM59011.h:72
static constexpr uint8_t SYMBOL_BIT_GSM
Definition SegLCD_HT1621_LCM59011.h:103
void clearUnits(uint8_t units)
Definition SegLCD_HT1621_LCM59011.cpp:95
LabelFlags
Definition SegLCD_HT1621_LCM59011.h:35
@ LABEL_MCB
Definition SegLCD_HT1621_LCM59011.h:36
static constexpr uint8_t LABEL_BIT_MCB
Definition SegLCD_HT1621_LCM59011.h:95
void _setColon(uint8_t row, uint8_t col, bool state) override
Virtual method for setting colon.
Definition SegLCD_HT1621_LCM59011.cpp:120
void setWarningSymbol(bool state, uint8_t index=0)
Definition SegLCD_HT1621_LCM59011.cpp:115
static constexpr uint8_t UNIT_BIT_H
Definition SegLCD_HT1621_LCM59011.h:92
static constexpr uint8_t SIGNAL_MASK
Definition SegLCD_HT1621_LCM59011.h:86
size_t write(uint8_t ch) override
Definition SegLCD_HT1621_LCM59011.cpp:126
static constexpr uint8_t SYMBOL_BIT_PLUG
Definition SegLCD_HT1621_LCM59011.h:109
static constexpr uint8_t COLON_ADDRESS
Definition SegLCD_HT1621_LCM59011.h:75
void clearSymbols(uint32_t symbols)
Definition SegLCD_HT1621_LCM59011.cpp:111
static constexpr uint8_t FLAG_COLON_DISPLAYED
Definition SegLCD_HT1621_LCM59011.h:78
void setSignalLevel(uint8_t level)
Definition SegLCD_HT1621_LCM59011.cpp:38
static constexpr uint8_t UNIT_BIT_M
Definition SegLCD_HT1621_LCM59011.h:90
static constexpr uint8_t SYMBOL_BIT_SUN
Definition SegLCD_HT1621_LCM59011.h:107
SymbolFlags
Definition SegLCD_HT1621_LCM59011.h:39
@ SYMBOL_UPS
Definition SegLCD_HT1621_LCM59011.h:43
@ SYMBOL_ECO
Definition SegLCD_HT1621_LCM59011.h:42
@ SYMBOL_WHEEL
Definition SegLCD_HT1621_LCM59011.h:41
@ SYMBOL_BLUETOOTH
Definition SegLCD_HT1621_LCM59011.h:47
@ SYMBOL_OUTLINE
Definition SegLCD_HT1621_LCM59011.h:54
@ SYMBOL_SUN
Definition SegLCD_HT1621_LCM59011.h:50
@ SYMBOL_LIGHTNING
Definition SegLCD_HT1621_LCM59011.h:51
@ SYMBOL_WARNING
Definition SegLCD_HT1621_LCM59011.h:53
@ SYMBOL_GSM
Definition SegLCD_HT1621_LCM59011.h:46
@ SYMBOL_PLUG
Definition SegLCD_HT1621_LCM59011.h:52
static constexpr uint8_t SIGNAL_ADDRESS
Definition SegLCD_HT1621_LCM59011.h:85
static constexpr uint8_t SYMBOL_BIT_OUTLINE
Definition SegLCD_HT1621_LCM59011.h:111
void setLabels(uint8_t labels)
Definition SegLCD_HT1621_LCM59011.cpp:99
void _updateUnits(uint8_t units, bool set)
Definition SegLCD_HT1621_LCM59011.cpp:51
static constexpr uint8_t SYMBOL_BIT_ECO
Definition SegLCD_HT1621_LCM59011.h:99
void clearLabels(uint8_t labels)
Definition SegLCD_HT1621_LCM59011.cpp:103
static constexpr uint8_t UNIT_BIT_A
Definition SegLCD_HT1621_LCM59011.h:89
void setBatteryLevel(uint8_t level)
Definition SegLCD_HT1621_LCM59011.cpp:17
static constexpr uint8_t UNIT_BIT_PERCENT
Definition SegLCD_HT1621_LCM59011.h:91
static constexpr uint8_t SYMBOL_BIT_BLUETOOTH
Definition SegLCD_HT1621_LCM59011.h:104
static constexpr uint8_t MAX_BATTERY_LEVEL
Definition SegLCD_HT1621_LCM59011.h:81
void setUnits(uint8_t units)
Definition SegLCD_HT1621_LCM59011.cpp:91
static constexpr uint8_t SYMBOL_BIT_UPS
Definition SegLCD_HT1621_LCM59011.h:100
static const AddressMapping * _getUnitMap(size_t &count)
Definition SegLCD_HT1621_LCM59011.h:124
static constexpr uint8_t SYMBOL_BIT_WHEEL
Definition SegLCD_HT1621_LCM59011.h:98
static constexpr uint8_t SYMBOL_BIT_LIGHTNING
Definition SegLCD_HT1621_LCM59011.h:108
void _updateLabels(uint8_t labels, bool set)
Definition SegLCD_HT1621_LCM59011.cpp:68
Definition SegLCD_HT1621_LCM59011.h:119
FlagBit bits[8]
Definition SegLCD_HT1621_LCM59011.h:121
uint8_t address
Definition SegLCD_HT1621_LCM59011.h:120
Definition SegLCD_HT1621_LCM59011.h:114
uint8_t bit
Definition SegLCD_HT1621_LCM59011.h:116
uint32_t flag
Definition SegLCD_HT1621_LCM59011.h:115