ArduinoDumbDisplay v0.9.9-r34
DumbDisplay Arduino Library -- https://github.com/trevorwslee/Arduino-DumbDisplay
 
Loading...
Searching...
No Matches
ddtftutil.h
1// ***
2// * assume inclusion TFT_eSPI.h
3// ***
4
5//#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
6
7#ifndef _dd_tft_util_h
8#define _dd_tft_util_h
9
10#include "_dd_misc.h"
11
13 public:
14 TftDDDebugInterface(TFT_eSPI& tft, int x = 0, int y = 0, uint8_t fontSize = 2, uint8_t font = 1, bool indicateSendCommand = false): tft(tft) {
15 this->x = x;
16 this->y = y;
17 this->fontSize = fontSize;
18 this->font = font;
19 this->indicateSendCommand = indicateSendCommand;
20 }
21 public:
22 virtual void logSendCommand(int state) {
23 if (indicateSendCommand) {
24 if (true) {
25 tft.fillRect(x, y, x + 10, y + 10, TFT_WHITE);
26 if (state == 1) {
27 tft.fillCircle(x + 5, y + 5, 5, TFT_RED);
28 }
29 } else {
30 tft.fillRect(x + 2, y + 2, x + 12, y + 12, TFT_WHITE);
31 if (state == 1) {
32 tft.fillCircle(x + 7, y + 7, 5, TFT_RED);
33 }
34 }
35 }
36 }
37 protected:
38 virtual void drawText(const char* text, bool isError) {
39 if (true) {
40 if (isError) {
41 showMsg(text, 80);
42 } else {
43 showMsg(text, 10);
44 }
45 } else {
46 if (isError) {
47 showMsg(text, 80);
48 } else {
49 showMsg(text, 16);
50 }
51 }
52 }
53 private:
54 void showMsg(const char* msg, int xOff) {
55 uint32_t textcolor = tft.textcolor;
56 uint32_t textbgcolor = tft.textbgcolor;
57 uint8_t textsize = tft.textsize;
58 tft.setTextColor(TFT_RED, TFT_WHITE);
59 tft.setTextSize(fontSize);
60 tft.drawString(msg, x + xOff, y, font);
61 tft.setTextColor(textcolor, textbgcolor);
62 tft.setTextSize(textsize);
63 }
64 protected:
65 TFT_eSPI& tft;
66 int x;
67 int y;
68 uint8_t fontSize;
69 uint8_t font;
70 bool indicateSendCommand;
71};
72
73
74// class TftDDDebugInterface: public DDDebugInterface {
75// public:
76// TftDDDebugInterface(TFT_eSPI& tft, int x = 0, int y = 0, uint8_t fontSize = 2, uint8_t font = 1, bool indicateSendCommand = false): tft(tft) {
77// this->x = x;
78// this->y = y;
79// this->fontSize = fontSize;
80// this->font = font;
81// this->indicateSendCommand = indicateSendCommand;
82// }
83// public:
84// virtual void logConnectionState(DDDebugConnectionState connectionState) {
85// const char* state = NULL;
86// switch (connectionState) {
87// case DDDebugConnectionState::DEBUG_NOT_CONNECTED:
88// state = "NCed";
89// break;
90// case DDDebugConnectionState::DEBUG_CONNECTING:
91// state = "Cing ";
92// break;
93// case DDDebugConnectionState::DEBUG_CONNECTED:
94// state = "Ced ";
95// break;
96// case DDDebugConnectionState::DEBUG_RECONNECTING:
97// state = "RCing";
98// break;
99// case DDDebugConnectionState::DEBUG_RECONNECTED:
100// state = "RCed ";
101// break;
102// }
103// if (state != NULL) {
104// showMsg(state, 16);
105// }
106// }
107// virtual void logSendCommand(int state) {
108// if (indicateSendCommand) {
109// tft.fillRect(x + 2, y + 2, x + 12, y + 12, TFT_WHITE);
110// if (state == 1) {
111// tft.fillCircle(x + 7, y + 7, 5, TFT_RED);
112// }
113// }
114// }
115// virtual void logError(const String& errMsg) {
116// showMsg("Err", 80);
117// }
118// protected:
119// void showMsg(const char* msg, int xOff) {
120// uint32_t textcolor = tft.textcolor;
121// uint32_t textbgcolor = tft.textbgcolor;
122// uint8_t textsize = tft.textsize;
123// tft.setTextColor(TFT_RED, TFT_WHITE);
124// tft.setTextSize(fontSize);
125// tft.drawString(msg, x + xOff, y, font);
126// tft.setTextColor(textcolor, textbgcolor);
127// tft.setTextSize(textsize);
128// }
129// private:
130// TFT_eSPI& tft;
131// int x;
132// int y;
133// uint8_t fontSize;
134// uint8_t font;
135// bool indicateSendCommand;
136// };
137
138#endif
Definition: _dd_misc.h:7
Definition: ddtftutil.h:12
virtual void logSendCommand(int state)
Definition: ddtftutil.h:22