Bind
C++ UI toolkit for Arduino
 
Loading...
Searching...
No Matches
BindKnob.hpp
1#ifndef __BINDKNOB_H
2#define __BINDKNOB_H
3#include "BindView.hpp"
4#include "BindUtils.hpp"
5// TODO: Extract the class to a serprate .h and .c file! Now!
28class BindKnob : public BindView
29{
30
31public:
40 BindKnob(const char *cstr)
41 {
42 setlabel(cstr);
43 }
44
51 BindKnob() : BindKnob("Knob"){}
52
53 int16_t x;
54 int16_t y;
55 uint8_t cmdId = 0;
56 int16_t dimSize;
57 int16_t minValue;
58 int16_t maxValue;
59 int16_t value;
60
70 void setlabel(const char *cstr)
71 {
72 str = cstr;
73 }
74
84 uint16_t getBytes(uint8_t *out) override
85 {
86 offset = 0;
87 strLength = strlen(str);
88 if (strLength > MAX_STRING_LENGTH_TERMINAL)
89 {
90 strLength = MAX_STRING_LENGTH_TERMINAL;
91 }
92 copyAndOffset(out, &offset, &objID, sizeof(objID));
93 copyAndOffset(out, &offset, &x, sizeof(x));
94 copyAndOffset(out, &offset, &y, sizeof(y));
95 copyAndOffset(out, &offset, &tag, sizeof(tag));
96 copyAndOffset(out, &offset, &cmdId, sizeof(cmdId));
97 copyAndOffset(out, &offset, &dimSize, sizeof(dimSize));
98 copyAndOffset(out, &offset, &minValue, sizeof(minValue));
99 copyAndOffset(out, &offset, &maxValue, sizeof(maxValue));
100 copyAndOffset(out, &offset, &value, sizeof(value));
101 copyAndOffset(out, &offset, str, strLength);
102 return offset;
103 }
104
105private:
106 uint8_t objID = BIND_ID_KNOB;
107 uint16_t offset = 0;
108 int strLength = 0;
109 const char *str;
110};
111#endif /* __BINDKNOB_H */
The BindKnob class represents a knob UI element for use with BindCanvas.
Definition BindKnob.hpp:29
int16_t y
Y-coordinate position of the knob.
Definition BindKnob.hpp:54
void setlabel(const char *cstr)
Sets the label text for the knob.
Definition BindKnob.hpp:70
int16_t minValue
Minimum value of the knob's range.
Definition BindKnob.hpp:57
uint16_t getBytes(uint8_t *out) override
Retrieves the bytes representing the knob for synchronization.
Definition BindKnob.hpp:84
int16_t dimSize
Dimensions or size of the knob.
Definition BindKnob.hpp:56
int16_t value
Current value of the knob.
Definition BindKnob.hpp:59
int16_t maxValue
Maximum value of the knob's range.
Definition BindKnob.hpp:58
int16_t x
X-coordinate position of the knob.
Definition BindKnob.hpp:53
uint8_t cmdId
Command ID for the knob. See the notes for possible cmdId values.
Definition BindKnob.hpp:55
BindKnob(const char *cstr)
Constructs a BindKnob with a custom label.
Definition BindKnob.hpp:40
BindKnob()
Constructs a BindKnob with a default label.
Definition BindKnob.hpp:51
Definition BindView.hpp:22