|
@@ -57,8 +57,21 @@ public:
|
57
|
57
|
static void WriteVariable(uint16_t adr, int16_t value);
|
58
|
58
|
static void WriteVariable(uint16_t adr, uint16_t value);
|
59
|
59
|
static void WriteVariable(uint16_t adr, uint8_t value);
|
|
60
|
+ static void WriteVariable(uint16_t adr, int8_t value);
|
60
|
61
|
static void WriteVariable(uint16_t adr, long value);
|
61
|
62
|
|
|
63
|
+ // Utility functions for bridging ui_api and dbus
|
|
64
|
+ template<typename T, float(*Getter)(const T), T selector, typename WireType=uint16_t>
|
|
65
|
+ static void SetVariable(DGUS_VP_Variable &var) {
|
|
66
|
+ WriteVariable(var.VP, (WireType)Getter(selector));
|
|
67
|
+ }
|
|
68
|
+
|
|
69
|
+ template<typename T, void(*Setter)(const float V, const T), T selector>
|
|
70
|
+ static void GetVariable(DGUS_VP_Variable &var, void *val_ptr) {
|
|
71
|
+ uint16_t newvalue = swap16(*(uint16_t*)val_ptr);
|
|
72
|
+ Setter(newvalue, selector);
|
|
73
|
+ }
|
|
74
|
+
|
62
|
75
|
// Until now I did not need to actively read from the display. That's why there is no ReadVariable
|
63
|
76
|
// (I extensively use the auto upload of the display)
|
64
|
77
|
|
|
@@ -83,11 +96,15 @@ private:
|
83
|
96
|
static void WritePGM(const char str[], uint8_t len);
|
84
|
97
|
static void ProcessRx();
|
85
|
98
|
|
|
99
|
+ static inline uint16_t swap16(const uint16_t value) { return (value & 0xffU) << 8U | (value >> 8U); }
|
86
|
100
|
static rx_datagram_state_t rx_datagram_state;
|
87
|
101
|
static uint8_t rx_datagram_len;
|
88
|
102
|
static bool Initialized, no_reentrance;
|
89
|
103
|
};
|
90
|
104
|
|
|
105
|
+#define GET_VARIABLE(f, t, V...) (&DGUSDisplay::GetVariable<decltype(t), f, t, ##V>)
|
|
106
|
+#define SET_VARIABLE(f, t, V...) (&DGUSDisplay::SetVariable<decltype(t), f, t, ##V>)
|
|
107
|
+
|
91
|
108
|
extern DGUSDisplay dgusdisplay;
|
92
|
109
|
|
93
|
110
|
// compile-time x^y
|