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