Bind
C++ UI toolkit for Arduino
 
Loading...
Searching...
No Matches
BindGaugeCompact.hpp
1#ifndef __BINDGAUGECOMPACT_HPP
2#define __BINDGAUGECOMPACT_HPP
3#include "BindView.hpp"
4#include "BindUtils.hpp"
5// TODO: Extract each class to a serprate .h and .c file! Now!
6
43{
44
45public:
51 BindGaugeCompact(const char *cstr);
52
57
58 int16_t x;
59 int16_t y;
60 uint8_t cmdId = 0;
61 int16_t dimSize = 100;
62 float value = 0;
63 float maxValue = 100.0f;
64 uint8_t drawArc = 0;
65 float arcGreenMaxVal = 0;
66 float arcYellowMaxVal = 0;
67 float arcRedMaxVal = 0;
68
74 void setlabel(const char *cstr)
75 {
76 str = cstr;
77 }
78
88 uint16_t getBytes(uint8_t *out) override
89 {
90 offset = 0;
91 strLength = strlen(str);
92 if (strLength > MAX_STRING_LENGTH_TERMINAL)
93 {
94 strLength = MAX_STRING_LENGTH_TERMINAL;
95 }
96 copyAndOffset(out, &offset, &objID, sizeof(objID));
97 copyAndOffset(out, &offset, &x, sizeof(x));
98 copyAndOffset(out, &offset, &y, sizeof(y));
99 copyAndOffset(out, &offset, &tag, sizeof(tag));
100 copyAndOffset(out, &offset, &cmdId, sizeof(cmdId));
101 copyAndOffset(out, &offset, &dimSize, sizeof(dimSize));
102 copyAndOffset(out, &offset, &value, sizeof(value));
103 copyAndOffset(out, &offset, &maxValue, sizeof(maxValue));
104 copyAndOffset(out, &offset, &drawArc, sizeof(drawArc));
105 copyAndOffset(out, &offset, &arcGreenMaxVal, sizeof(arcGreenMaxVal));
106 copyAndOffset(out, &offset, &arcYellowMaxVal, sizeof(arcYellowMaxVal));
107 copyAndOffset(out, &offset, &arcRedMaxVal, sizeof(arcRedMaxVal));
108 copyAndOffset(out, &offset, str, strLength);
109 return offset;
110 }
111
112private:
113 uint8_t objID = BIND_ID_GAUGE2;
114 uint16_t offset = 0;
115 int strLength = 0;
116 const char *str;
117 static int16_t tagIndex;
118};
119
120#endif /* __BINDGAUGECOMPACT_HPP */
Represents a compact gauge view for the BindCanvas framework.
Definition BindGaugeCompact.hpp:43
float value
The current value of the gauge.
Definition BindGaugeCompact.hpp:62
BindGaugeCompact()
Constructs a BindGaugeCompact object with a default label.
Definition BindGaugeCompact.hpp:56
uint8_t drawArc
Indicates whether to draw an arc for the gauge. 0=False, 1=True.
Definition BindGaugeCompact.hpp:64
int16_t dimSize
The dimensions (size) of the gauge.
Definition BindGaugeCompact.hpp:61
float maxValue
The maximum value that the gauge can represent.
Definition BindGaugeCompact.hpp:63
float arcRedMaxVal
The maximum value for the red arc section.
Definition BindGaugeCompact.hpp:67
uint16_t getBytes(uint8_t *out) override
Gets the bytes representing the BindGaugeCompact object for data synchronization.
Definition BindGaugeCompact.hpp:88
int16_t y
The y-coordinate position of the gauge on the canvas.
Definition BindGaugeCompact.hpp:59
uint8_t cmdId
The command ID associated with the gauge. See the notes for possible cmdId values.
Definition BindGaugeCompact.hpp:60
float arcGreenMaxVal
The maximum value for the green arc section.
Definition BindGaugeCompact.hpp:65
void setlabel(const char *cstr)
Sets the label to be displayed on the gauge.
Definition BindGaugeCompact.hpp:74
int16_t x
The x-coordinate position of the gauge on the canvas.
Definition BindGaugeCompact.hpp:58
float arcYellowMaxVal
The maximum value for the yellow arc section.
Definition BindGaugeCompact.hpp:66
Definition BindView.hpp:22