Bind
C++ UI framework for Arduino
 
Loading...
Searching...
No Matches
BindCanvasSettings.hpp
1#ifndef __BINDCANVASSETTINGS_HPP
2#define __BINDCANVASSETTINGS_HPP
3#include "BindView.hpp"
4#include "BindUtils.hpp"
5
6// Screen orientation is not set or specified.
7#define SCREEN_ORIENTATION_UNSET -2
8// Screen orientation is unspecified, allowing the system to decide.
9#define SCREEN_ORIENTATION_UNSPECIFIED -1
10// Landscape mode: screen width > height.
11#define SCREEN_ORIENTATION_LANDSCAPE 0
12// Portrait mode: screen height > width.
13#define SCREEN_ORIENTATION_PORTRAIT 1
14// User-defined orientation.
15#define SCREEN_ORIENTATION_USER 2
16// Based on the previous activity's orientation.
17#define SCREEN_ORIENTATION_BEHIND 3
18// Orientation determined by device sensors.
19#define SCREEN_ORIENTATION_SENSOR 4
20// Disable sensor-based orientation.
21#define SCREEN_ORIENTATION_NOSENSOR 5
22// Landscape orientation based on sensors.
23#define SCREEN_ORIENTATION_SENSOR_LANDSCAPE 6
24// Portrait orientation based on sensors.
25#define SCREEN_ORIENTATION_SENSOR_PORTRAIT 7
26// Reverse landscape orientation.
27#define SCREEN_ORIENTATION_REVERSE_LANDSCAPE 8
28// Reverse portrait orientation.
29#define SCREEN_ORIENTATION_REVERSE_PORTRAIT 9
30// Full sensor-based control over orientation.
31#define SCREEN_ORIENTATION_FULL_SENSOR 10
32// User-defined landscape orientation.
33#define SCREEN_ORIENTATION_USER_LANDSCAPE 11
34// User-defined portrait orientation.
35#define SCREEN_ORIENTATION_USER_PORTRAIT 12
36// Full user control over orientation, including reverse.
37#define SCREEN_ORIENTATION_FULL_USER 13
38// Lock the current screen orientation.
39#define SCREEN_ORIENTATION_LOCKED 14
40
59{
60public:
65 {
66 setLabel("BindApp");
67 }
68
69 int8_t screenOrientation = 0;
70 int32_t backColor;
72 bool resetScreen = false;
73
80 void setLabel(const char *cstr)
81 {
82 str = cstr;
83 }
84
85 [[deprecated("Use setLabel instead")]]
86 void setlabel(const char *cstr)
87 {
88 setLabel(cstr);
89 }
90
104 uint16_t getBytes(uint8_t *out, int8_t _screenOrientation, int32_t _backColor, int32_t _actionBarColor, const char *cstr)
105 {
106 screenOrientation = _screenOrientation;
107 backColor = _backColor;
108 actionBarColor = _actionBarColor;
109 str = cstr;
110 return getBytes(out);
111 }
112
122 uint16_t getBytes(uint8_t *out) override
123 {
124 offset = 0;
125 strLength = strlen(str);
126 if (strLength > MAX_STRING_LENGTH_TERMINAL)
127 {
128 strLength = MAX_STRING_LENGTH_TERMINAL;
129 }
130 copyAndOffset(out, &offset, &objID, sizeof(objID));
131 copyAndOffset(out, &offset, &screenOrientation, sizeof(screenOrientation));
132 copyAndOffset(out, &offset, &backColor, sizeof(backColor));
133 copyAndOffset(out, &offset, &actionBarColor, sizeof(actionBarColor));
134 copyAndOffset(out, &offset, &resetScreen, sizeof(resetScreen));
135 copyAndOffset(out, &offset, str, strLength);
136 resetScreen = false;
137 return offset;
138 }
139
140private:
141 uint8_t objID = BIND_ID_SETTINGS;
142 uint16_t offset = 0;
143 int strLength = 0;
144 const char *str;
145};
146#endif /* __BINDCANVASSETTINGS_HPP */
Represents the configuration settings for a BindCanvas application screen.
Definition BindCanvasSettings.hpp:59
int32_t backColor
Background color in 32-bit format.
Definition BindCanvasSettings.hpp:70
void setLabel(const char *cstr)
Sets the label for the BindCanvas application screen.
Definition BindCanvasSettings.hpp:80
BindCanvasSettings()
Constructs a BindCanvasSettings object with default label "BindApp.".
Definition BindCanvasSettings.hpp:64
int32_t actionBarColor
Action bar color in 32-bit format.
Definition BindCanvasSettings.hpp:71
int8_t screenOrientation
Screen orientation value.
Definition BindCanvasSettings.hpp:69
uint16_t getBytes(uint8_t *out, int8_t _screenOrientation, int32_t _backColor, int32_t _actionBarColor, const char *cstr)
Generates and returns the byte data representing the screen configuration.
Definition BindCanvasSettings.hpp:104
bool resetScreen
Flag to reset the screen.
Definition BindCanvasSettings.hpp:72
uint16_t getBytes(uint8_t *out) override
Generates and returns the byte data representing the screen configuration.
Definition BindCanvasSettings.hpp:122
Definition BindView.hpp:26