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