Loading...
Searching...
No Matches
BindSeekBar.hpp
1#ifndef __BINDSEEKBAR_HPP
2#define __BINDSEEKBAR_HPP
3#include "BindView.hpp"
4#include "BindUtils.hpp"
23 class BindSeekBar : public BindView
24{
25
26 public:
30 BindSeekBar(){
31 this->tag = tagIndex++;
32 }
33
34 int16_t x;
35 int16_t y;
36 uint8_t cmdId = 0;
37 int16_t value = 0;
38 int16_t maxValue = 100;
39 int16_t width = 200;
40
52 void setCallback(void (*callback)(int16_t))
53 {
54 changeCallback = callback;
55 }
56
57 void invokeCallback(int16_t valueIn)
58 {
59 this->value = valueIn;
60 if (changeCallback != NULL)
61 {
62 changeCallback(valueIn);
63 }
64 }
65
76 uint16_t getBytes(uint8_t *out) override
77 {
78 offset = 0;
79 copyAndOffset(out, &offset, &objID, sizeof(objID));
80 copyAndOffset(out, &offset, &x, 2);
81 copyAndOffset(out, &offset, &y, 2);
82 copyAndOffset(out, &offset, &tag, 2);
83 copyAndOffset(out, &offset, &cmdId, sizeof(cmdId));
84 copyAndOffset(out, &offset, &value, sizeof(value));
85 copyAndOffset(out, &offset, &maxValue, sizeof(maxValue));
86 copyAndOffset(out, &offset, &width, sizeof(width));
87 return offset;
88 }
89
90 private:
91 uint8_t objID = BIND_ID_SEEK_BAR;
92 uint16_t offset = 0;
93 static int16_t tagIndex;
94 void (*changeCallback)(int16_t) = NULL;
95};
96
97#endif /* __BINDSEEKBAR_HPP */
BindSeekBar
Represents a SeekBar object in the Bind framework.
Definition BindSeekBar.hpp:24
BindSeekBar::cmdId
uint8_t cmdId
Command identifier. See the notes for possible cmdId values.
Definition BindSeekBar.hpp:36
BindSeekBar::getBytes
uint16_t getBytes(uint8_t *out) override
Serialize the SeekBar data into a byte array.
Definition BindSeekBar.hpp:76
BindSeekBar::x
int16_t x
X-coordinate position of the SeekBar.
Definition BindSeekBar.hpp:34
BindSeekBar::width
int16_t width
Width of the SeekBar.
Definition BindSeekBar.hpp:39
BindSeekBar::value
int16_t value
Current value selected on the SeekBar.
Definition BindSeekBar.hpp:37
BindSeekBar::setCallback
void setCallback(void(*callback)(int16_t))
Set the Callback function for the SeekBar.
Definition BindSeekBar.hpp:52
BindSeekBar::maxValue
int16_t maxValue
Maximum value of the SeekBar.
Definition BindSeekBar.hpp:38
BindSeekBar::BindSeekBar
BindSeekBar()
Default constructor to create a BindSeekBar with default properties.
Definition BindSeekBar.hpp:30
BindSeekBar::y
int16_t y
Y-coordinate position of the SeekBar.
Definition BindSeekBar.hpp:35
BindView
Definition BindView.hpp:22