Loading...
Searching...
No Matches
BindColorPicker.hpp
1#ifndef __BINDCOLORPICKER_HPP
2#define __BINDCOLORPICKER_HPP
3#include "BindView.hpp"
4#include "BindUtils.hpp"
5
55 class BindColorPicker : public BindView
56{
57
58 public:
59
60 BindColorPicker()
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
123 private:
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
BindColorPicker Class.
Definition BindColorPicker.hpp:56
BindColorPicker::dimSize
int16_t dimSize
The dimensions (size) of the color picker.
Definition BindColorPicker.hpp:68
BindColorPicker::cmdId
uint8_t cmdId
Command identifier to add or refresh the color picker. See the notes for possible cmdId values.
Definition BindColorPicker.hpp:67
BindColorPicker::blue
uint8_t blue
The initial value for the blue component of the selected color (0-255).
Definition BindColorPicker.hpp:71
BindColorPicker::green
uint8_t green
The initial value for the green component of the selected color (0-255).
Definition BindColorPicker.hpp:70
BindColorPicker::getBytes
uint16_t getBytes(uint8_t *out) override
Serialize the color picker object into bytes.
Definition BindColorPicker.hpp:108
BindColorPicker::setCallback
void setCallback(void(*callback)(uint8_t, uint8_t, uint8_t))
Set the Callback function for the color picker.
Definition BindColorPicker.hpp:84
BindColorPicker::y
int16_t y
The y-coordinate position of the color picker on the screen.
Definition BindColorPicker.hpp:66
BindColorPicker::red
uint8_t red
The initial value for the red component of the selected color (0-255).
Definition BindColorPicker.hpp:69
BindColorPicker::x
int16_t x
The x-coordinate position of the color picker on the screen.
Definition BindColorPicker.hpp:65
BindView
Definition BindView.hpp:22