Bind
C++ UI toolkit for Arduino
 
Loading...
Searching...
No Matches
BindColorPicker.hpp
1#ifndef __BINDCOLORPICKER_HPP
2#define __BINDCOLORPICKER_HPP
3#include "BindView.hpp"
4#include "BindUtils.hpp"
5
56{
57
58public:
59
61 {
62 this->tag = tagIndex++;
63 }
64
65 int16_t x = 0;
66 int16_t y = 0;
67 uint8_t cmdId = 0;
68 int16_t dimSize = 200;
69 uint8_t red = 0;
70 uint8_t green = 0;
71 uint8_t blue = 0;
72
84 void setCallback(void (*callback)(uint8_t, uint8_t, uint8_t))
85 {
86 clickCallback = callback;
87 }
88
89 void invokeCallback(uint8_t redIn, uint8_t greenIn, uint8_t blueIn)
90 {
91 this->red = redIn;
92 this->green = greenIn;
93 this->blue = blueIn;
94 if (clickCallback != nullptr)
95 {
96 clickCallback(redIn, greenIn, blueIn);
97 }
98 }
99
108 uint16_t getBytes(uint8_t *out) override
109 {
110 offset = 0;
111 copyAndOffset(out, &offset, &objID, sizeof(objID));
112 copyAndOffset(out, &offset, &x, sizeof(x));
113 copyAndOffset(out, &offset, &y, sizeof(y));
114 copyAndOffset(out, &offset, &tag, sizeof(tag));
115 copyAndOffset(out, &offset, &cmdId, sizeof(cmdId));
116 copyAndOffset(out, &offset, &dimSize, sizeof(dimSize));
117 copyAndOffset(out, &offset, &red, sizeof(red));
118 copyAndOffset(out, &offset, &green, sizeof(green));
119 copyAndOffset(out, &offset, &blue, sizeof(blue));
120 return offset;
121 }
122
123private:
124 uint8_t objID = BIND_ID_COLOR_PICKER;
125 uint16_t offset = 0;
126 static int16_t tagIndex;
127 void (*clickCallback)(uint8_t, uint8_t, uint8_t) = nullptr;
128};
129
130#endif /* __BINDCOLORPICKER_HPP */
BindColorPicker Class.
Definition BindColorPicker.hpp:56
int16_t dimSize
The dimensions (size) of the color picker.
Definition BindColorPicker.hpp:68
uint8_t cmdId
Command identifier to add or refresh the color picker. See the notes for possible cmdId values.
Definition BindColorPicker.hpp:67
uint8_t blue
The initial value for the blue component of the selected color (0-255).
Definition BindColorPicker.hpp:71
uint8_t green
The initial value for the green component of the selected color (0-255).
Definition BindColorPicker.hpp:70
uint16_t getBytes(uint8_t *out) override
Serialize the color picker object into bytes.
Definition BindColorPicker.hpp:108
void setCallback(void(*callback)(uint8_t, uint8_t, uint8_t))
Set the Callback function for the color picker.
Definition BindColorPicker.hpp:84
int16_t y
The y-coordinate position of the color picker on the screen.
Definition BindColorPicker.hpp:66
uint8_t red
The initial value for the red component of the selected color (0-255).
Definition BindColorPicker.hpp:69
int16_t x
The x-coordinate position of the color picker on the screen.
Definition BindColorPicker.hpp:65
Definition BindView.hpp:22