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