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
42 class BindGaugeCompact : public BindView
43{
44
45 public:
51 BindGaugeCompact(const char *cstr);
52
56 BindGaugeCompact():BindGaugeCompact("Gauge"){}
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
79 [[deprecated("Use setLabel instead")]]
80 void setlabel(const char *cstr)
81 {
82 setLabel(cstr);
83 }
84
94 uint16_t getBytes(uint8_t *out) override
95 {
96 offset = 0;
97 strLength = strlen(str);
98 if (strLength > MAX_STRING_LENGTH_TERMINAL)
99 {
100 strLength = MAX_STRING_LENGTH_TERMINAL;
101 }
102 copyAndOffset(out, &offset, &objID, sizeof(objID));
103 copyAndOffset(out, &offset, &x, sizeof(x));
104 copyAndOffset(out, &offset, &y, sizeof(y));
105 copyAndOffset(out, &offset, &tag, sizeof(tag));
106 copyAndOffset(out, &offset, &cmdId, sizeof(cmdId));
107 copyAndOffset(out, &offset, &dimSize, sizeof(dimSize));
108 copyAndOffset(out, &offset, &value, sizeof(value));
109 copyAndOffset(out, &offset, &maxValue, sizeof(maxValue));
110 copyAndOffset(out, &offset, &drawArc, sizeof(drawArc));
111 copyAndOffset(out, &offset, &arcGreenMaxVal, sizeof(arcGreenMaxVal));
112 copyAndOffset(out, &offset, &arcYellowMaxVal, sizeof(arcYellowMaxVal));
113 copyAndOffset(out, &offset, &arcRedMaxVal, sizeof(arcRedMaxVal));
114 copyAndOffset(out, &offset, str, strLength);
115 return offset;
116 }
117
118 private:
119 uint8_t objID = BIND_ID_GAUGE2;
120 uint16_t offset = 0;
121 int strLength = 0;
122 const char *str;
123 static int16_t tagIndex;
124};
125
126#endif /* __BINDGAUGECOMPACT_HPP */
BindGaugeCompact
Represents a compact gauge view for the BindCanvas framework.
Definition BindGaugeCompact.hpp:43
BindGaugeCompact::value
float value
The current value of the gauge.
Definition BindGaugeCompact.hpp:62
BindGaugeCompact::BindGaugeCompact
BindGaugeCompact()
Constructs a BindGaugeCompact object with a default label.
Definition BindGaugeCompact.hpp:56
BindGaugeCompact::setLabel
void setLabel(const char *cstr)
Sets the label to be displayed on the gauge.
Definition BindGaugeCompact.hpp:74
BindGaugeCompact::drawArc
uint8_t drawArc
Indicates whether to draw an arc for the gauge. 0=False, 1=True.
Definition BindGaugeCompact.hpp:64
BindGaugeCompact::dimSize
int16_t dimSize
The dimensions (size) of the gauge.
Definition BindGaugeCompact.hpp:61
BindGaugeCompact::maxValue
float maxValue
The maximum value that the gauge can represent.
Definition BindGaugeCompact.hpp:63
BindGaugeCompact::arcRedMaxVal
float arcRedMaxVal
The maximum value for the red arc section.
Definition BindGaugeCompact.hpp:67
BindGaugeCompact::getBytes
uint16_t getBytes(uint8_t *out) override
Gets the bytes representing the BindGaugeCompact object for data synchronization.
Definition BindGaugeCompact.hpp:94
BindGaugeCompact::y
int16_t y
The y-coordinate position of the gauge on the canvas.
Definition BindGaugeCompact.hpp:59
BindGaugeCompact::cmdId
uint8_t cmdId
The command ID associated with the gauge. See the notes for possible cmdId values.
Definition BindGaugeCompact.hpp:60
BindGaugeCompact::arcGreenMaxVal
float arcGreenMaxVal
The maximum value for the green arc section.
Definition BindGaugeCompact.hpp:65
BindGaugeCompact::x
int16_t x
The x-coordinate position of the gauge on the canvas.
Definition BindGaugeCompact.hpp:58
BindGaugeCompact::arcYellowMaxVal
float arcYellowMaxVal
The maximum value for the yellow arc section.
Definition BindGaugeCompact.hpp:66
BindView
Definition BindView.hpp:26