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
42{
43
44public:
50 BindGaugeCompact(const char *cstr);
51
56
57 int16_t x;
58 int16_t y;
59 uint8_t cmdId = 0;
60 int16_t dimSize = 100;
61 float value = 0;
62 float maxValue = 100.0f;
63 uint8_t drawArc = 0;
64 float arcGreenMaxVal = 0;
65 float arcYellowMaxVal = 0;
66 float arcRedMaxVal = 0;
67
73 void setlabel(const char *cstr)
74 {
75 str = cstr;
76 }
77
87 uint16_t getBytes(uint8_t *out) override
88 {
89 offset = 0;
90 strLength = strlen(str);
91 if (strLength > MAX_STRING_LENGTH_TERMINAL)
92 {
93 strLength = MAX_STRING_LENGTH_TERMINAL;
94 }
95 copyAndOffset(out, &offset, &objID, sizeof(objID));
96 copyAndOffset(out, &offset, &x, sizeof(x));
97 copyAndOffset(out, &offset, &y, sizeof(y));
98 copyAndOffset(out, &offset, &tag, sizeof(tag));
99 copyAndOffset(out, &offset, &cmdId, sizeof(cmdId));
100 copyAndOffset(out, &offset, &dimSize, sizeof(dimSize));
101 copyAndOffset(out, &offset, &value, sizeof(value));
102 copyAndOffset(out, &offset, &maxValue, sizeof(maxValue));
103 copyAndOffset(out, &offset, &drawArc, sizeof(drawArc));
104 copyAndOffset(out, &offset, &arcGreenMaxVal, sizeof(arcGreenMaxVal));
105 copyAndOffset(out, &offset, &arcYellowMaxVal, sizeof(arcYellowMaxVal));
106 copyAndOffset(out, &offset, &arcRedMaxVal, sizeof(arcRedMaxVal));
107 copyAndOffset(out, &offset, str, strLength);
108 return offset;
109 }
110
111private:
112 uint8_t objID = BIND_ID_GAUGE2;
113 uint16_t offset = 0;
114 int strLength = 0;
115 const char *str;
116 static int16_t tagIndex;
117};
118
119#endif /* __BINDGAUGECOMPACT_HPP */
Represents a compact gauge view for the BindCanvas framework.
Definition BindGaugeCompact.hpp:42
float value
The current value of the gauge.
Definition BindGaugeCompact.hpp:61
BindGaugeCompact()
Constructs a BindGaugeCompact object with a default label.
Definition BindGaugeCompact.hpp:55
uint8_t drawArc
Indicates whether to draw an arc for the gauge. 0=False, 1=True.
Definition BindGaugeCompact.hpp:63
int16_t dimSize
The dimensions (size) of the gauge.
Definition BindGaugeCompact.hpp:60
float maxValue
The maximum value that the gauge can represent.
Definition BindGaugeCompact.hpp:62
float arcRedMaxVal
The maximum value for the red arc section.
Definition BindGaugeCompact.hpp:66
uint16_t getBytes(uint8_t *out) override
Gets the bytes representing the BindGaugeCompact object for data synchronization.
Definition BindGaugeCompact.hpp:87
int16_t y
The y-coordinate position of the gauge on the canvas.
Definition BindGaugeCompact.hpp:58
uint8_t cmdId
The command ID associated with the gauge. See the notes for possible cmdId values.
Definition BindGaugeCompact.hpp:59
float arcGreenMaxVal
The maximum value for the green arc section.
Definition BindGaugeCompact.hpp:64
void setlabel(const char *cstr)
Sets the label to be displayed on the gauge.
Definition BindGaugeCompact.hpp:73
int16_t x
The x-coordinate position of the gauge on the canvas.
Definition BindGaugeCompact.hpp:57
float arcYellowMaxVal
The maximum value for the yellow arc section.
Definition BindGaugeCompact.hpp:65
Definition BindView.hpp:22