Bind
C++ UI toolkit for Arduino
 
Loading...
Searching...
No Matches
BindChart.hpp
1#ifndef __BINDCHART_HPP
2#define __BINDCHART_HPP
3#include "BindView.hpp"
4#include "BindUtils.hpp"
5
31class BindChart : public BindView
32{
33
34public:
35 BindChart();
36 int16_t x = 0;
37 int16_t y = 0;
38 uint8_t cmdId = 0;
39 int16_t width = 200;
40 int16_t height = 100;
41 int16_t maxY = 10;
42 int16_t minY = -10;
43 int16_t maxX = 20;
44 bool autoSize = true;
45 int32_t color = YELLOW;
46
56 uint16_t getBytes(uint8_t *out) override
57 {
58 offset = 0;
59 copyAndOffset(out, &offset, &objID, sizeof(objID));
60 copyAndOffset(out, &offset, &x, sizeof(x));
61 copyAndOffset(out, &offset, &y, sizeof(y));
62 copyAndOffset(out, &offset, &tag, sizeof(tag));
63 copyAndOffset(out, &offset, &cmdId, sizeof(cmdId));
64 copyAndOffset(out, &offset, &width, sizeof(width));
65 copyAndOffset(out, &offset, &height, sizeof(height));
66 copyAndOffset(out, &offset, &maxY, sizeof(maxY));
67 copyAndOffset(out, &offset, &minY, sizeof(minY));
68 copyAndOffset(out, &offset, &maxX, sizeof(maxX));
69 copyAndOffset(out, &offset, &autoSize, sizeof(autoSize));
70 copyAndOffset(out, &offset, &color, sizeof(color));
71 return offset;
72 }
73
84 uint16_t getDataBytes(uint8_t *out, float chartData)
85 {
86 offset = 0;
87 copyAndOffset(out, &offset, &dataID, sizeof(dataID));
88 copyAndOffset(out, &offset, &tag, sizeof(tag));
89 copyAndOffset(out, &offset, &cmdId, sizeof(cmdId));
90 copyAndOffset(out, &offset, &chartData, sizeof(chartData));
91 copyAndOffset(out, &offset, &color, sizeof(color));
92 return offset;
93 }
94
95private:
96 uint8_t objID = BIND_ID_CHART;
97 uint8_t dataID = BIND_ID_CHART_DATA;
98 uint16_t offset = 0;
99 static int16_t tagIndex;
100};
101
102#endif /* __BINDCHART_HPP */
Represents a customizable chart element for BindCanvas.
Definition BindChart.hpp:32
uint8_t cmdId
Command ID for the chart. See the notes for possible cmdId values.
Definition BindChart.hpp:38
int16_t minY
Minimum Y-axis value of the chart.
Definition BindChart.hpp:42
int16_t maxY
Maximum Y-axis value of the chart.
Definition BindChart.hpp:41
uint16_t getBytes(uint8_t *out) override
Generates and returns the byte data representing the chart configuration.
Definition BindChart.hpp:56
int16_t maxX
Maximum X-axis value of the chart.
Definition BindChart.hpp:43
int16_t width
Width of the chart.
Definition BindChart.hpp:39
int16_t height
Height of the chart.
Definition BindChart.hpp:40
uint16_t getDataBytes(uint8_t *out, float chartData)
Generates and returns the byte data representing chart data.
Definition BindChart.hpp:84
bool autoSize
Flag to enable auto-sizing based on data.
Definition BindChart.hpp:44
int16_t y
Y-coordinate position of the chart.
Definition BindChart.hpp:37
int32_t color
Color of the chart.
Definition BindChart.hpp:45
int16_t x
X-coordinate position of the chart.
Definition BindChart.hpp:36
Definition BindView.hpp:22