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