-
Notifications
You must be signed in to change notification settings - Fork 0
/
displayfuncs.h
131 lines (104 loc) · 3.13 KB
/
displayfuncs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#ifdef USE_OLED
#include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
#include "SSD1306Wire.h" //
// for external display wired in to sda a scl
// ----------tput back in for oled ----------
//SSD1306Wire oled(0x3c, 21, 22);
//21 SDA (5 down from top right), 22 SCL(2 down from top right) - usb at bottom
SSD1306Wire oled(0x3c, SDA_PIN, SCL_PIN);
unsigned long iLastoledStatus;
bool bon;
bool bOledIsConnected = true;
void fn_oledStatus(bool bShowNow) {
if (!bOledIsConnected) return;
if (!bShowNow) if (millis() - iLastoledStatus < 50) return;
iLastoledStatus = millis();
///unsigned int istartmillis = millis();
oled.clear();
oled.setFont(ArialMT_Plain_24);
if (eepromStore.bShowGrams) {
oled.drawString(0, 0, String(fgrams, 3) + " Gram ");
}
else {
oled.drawString(0, 0, String(fgrains, 1) + " grains");
}
oled.setFont(ArialMT_Lato_Regular_13);
oled.drawString(0, 25, sDispensingStatus);
oled.setFont(ArialMT_Plain_10);
if (!eepromStore.bShowGrams) {
oled.drawString(0, 50, String(fgrams, 3) + " Gram");
}
else {
oled.drawString(0, 50, String(fgrains, 1) + " grains");
}
oled.setFont(ArialMT_Plain_10);
#ifdef USE_EEPROM
oled.drawString(0, 40, "Target: " + String(eepromStore.iTargetWeight, 2));
if (bTareHapened) {
oled.drawString(100, 40, "T");
}
#endif
#ifdef USE_NETWORK
oled.setFont(ArialMT_Plain_10);
#ifdef USE_ACCESS_POINT
oled.drawString(0, 30, "svr:" + sServerIP());
oled.drawString(0, 40, sWifi );
oled.drawString(0, 49, "MyIp:" + sIP + " Prt:" + String(eepromStore.iUDPSendPort));
#else
//oled.drawString(0, 40, sWifi + " Port:" + String(eepromStore.iUDPSendPort));
#ifdef UDP_SERVER_SEND
oled.drawString(0, 49, "svr:" + sServerIP());
#else
// oled.drawString(0, 49,"my iP:" + sIP);
#endif
#endif
#endif
int ix = 100;
if (bon) {
oled.drawString(ix, 49, "/");
bon = false;
} else {
oled.drawString(ix, 49, "-");
bon = true;
}
oled.display();
}
void fn_SetupOLED() {
unsigned int istartmillis = millis();
oled.init();
//oled.flipScreenVertically();
oled.setFont(ArialMT_Plain_10);
oled.clear();
unsigned int itimeneeded = millis() - istartmillis;
// by experimentastion : if the oled is connected, it needs 25 seconds to start, less than 10 seconds if not connected
if (itimeneeded < 10) bOledIsConnected = false;
// if (bdebugSerial) Serial.println("OLED time needed to start:" + String(itimeneeded));
//if (bdebugSerial and bOledIsConnected == false)if (bdebugSerial) Serial.println("OLED NOT Connected!!!!!:" );
}
void fn_oledText(String sTooled, int ifont =0 ) {
oled.clear();
oled.setFont(ArialMT_Plain_16);
if(sTooled.length()>=20) oled.setFont(ArialMT_Plain_10);
oled.setFont(ArialMT_Plain_16);
if (ifont == 1) {
oled.setFont(ArialMT_Plain_10);
}
if (ifont == 2) {
oled.setFont(ArialMT_Lato_Regular_13);
}
if (ifont == 3) {
oled.setFont(ArialMT_Plain_16);
}
if (ifont == 4) {
oled.setFont(ArialMT_Plain_24);
}
oled.drawString(0, 0, sTooled);
oled.display();
}
void fn_oledot(bool bshow) {
int x = oled.getWidth() - 6;
int y = 6;
if (bshow) oled.fillCircle(x, y, 3); else oled.drawCircle(x,y, 3);
oled.display();
}
#endif