Bind
C++ UI toolkit for Arduino
 
Loading...
Searching...
No Matches
BindTerminal.hpp
1#ifndef __BINDTERMINAL_HPP
2#define __BINDTERMINAL_HPP
3#include "BindView.hpp"
4#include "BindUtils.hpp"
5
24class BindTerminal : public BindView
25{
26
27public:
29 int16_t x = 0;
30 int16_t y = 0;
31 uint8_t cmdId = 0;
32 int16_t width = 200;
33 int16_t height = 100;
34 int16_t textSize = 10;
35 int32_t backColor = UBUNTU;
36
46 uint16_t getBytes(uint8_t *out) override
47 {
48 offset = 0;
49 copyAndOffset(out, &offset, &objID, sizeof(objID));
50 copyAndOffset(out, &offset, &x, sizeof(x));
51 copyAndOffset(out, &offset, &y, sizeof(y));
52 copyAndOffset(out, &offset, &tag, sizeof(tag));
53 copyAndOffset(out, &offset, &cmdId, sizeof(cmdId));
54 copyAndOffset(out, &offset, &width, sizeof(width));
55 copyAndOffset(out, &offset, &height, sizeof(height));
56 copyAndOffset(out, &offset, &textSize, sizeof(textSize));
57 copyAndOffset(out, &offset, &backColor, sizeof(backColor));
58 return offset;
59 }
60
76 uint16_t getDataBytes(uint8_t *out, const char *str, int32_t textColor, bool autoScroll, bool newLine, bool bold, bool italic)
77 {
78 offset = 0;
79 strLength = strlen(str);
80 if (strLength > MAX_STRING_LENGTH_TERMINAL)
81 {
82 strLength = MAX_STRING_LENGTH_TERMINAL;
83 }
84 copyAndOffset(out, &offset, &dataID, sizeof(dataID));
85 copyAndOffset(out, &offset, &tag, sizeof(tag));
86 copyAndOffset(out, &offset, &cmdId, sizeof(cmdId));
87 copyAndOffset(out, &offset, &textColor, sizeof(textColor));
88 copyAndOffset(out, &offset, &newLine, sizeof(newLine));
89 copyAndOffset(out, &offset, &bold, sizeof(bold));
90 copyAndOffset(out, &offset, &italic, sizeof(italic));
91 copyAndOffset(out, &offset, &autoScroll, sizeof(autoScroll));
92 copyAndOffset(out, &offset, str, strLength);
93 return offset;
94 }
95
96private:
97 uint8_t objID = BIND_ID_TERMINAL;
98 uint8_t dataID = BIND_ID_TERMINAL_DATA;
99 uint16_t offset = 0;
100 int strLength = 0;
101 static int16_t tagIndex;
102};
103#endif /* __BINDTERMINAL_HPP */
Represents a terminal display for BindCanvas.
Definition BindTerminal.hpp:25
int16_t textSize
Text size of the displayed text.
Definition BindTerminal.hpp:34
uint16_t getDataBytes(uint8_t *out, const char *str, int32_t textColor, bool autoScroll, bool newLine, bool bold, bool italic)
Generates and returns the byte data representing text to be displayed in the terminal.
Definition BindTerminal.hpp:76
int16_t x
X-coordinate position of the terminal.
Definition BindTerminal.hpp:29
int16_t y
Y-coordinate position of the terminal.
Definition BindTerminal.hpp:30
int16_t width
Width of the terminal.
Definition BindTerminal.hpp:32
uint8_t cmdId
Command ID for the terminal. See the notes for possible cmdId values.
Definition BindTerminal.hpp:31
uint16_t getBytes(uint8_t *out) override
Generates and returns the byte data representing the terminal's configuration.
Definition BindTerminal.hpp:46
int32_t backColor
Background color of the terminal.
Definition BindTerminal.hpp:35
int16_t height
Height of the terminal.
Definition BindTerminal.hpp:33
Definition BindView.hpp:22