ESP3D  3.0
Firmware for ESP boards connected to 3D Printer
basicdisplay.cpp
Go to the documentation of this file.
1 /*
2  advanceddisplay.cpp - display functions class
3 
4  Copyright (c) 2014 Luc Lebosse. All rights reserved.
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 #include "../../include/esp3d_config.h"
22 #if defined (DISPLAY_DEVICE) && (DISPLAY_UI_TYPE == UI_TYPE_BASIC)
23 
24 #include "basicdisplay.h"
25 #include "../../core/settings_esp3d.h"
26 #include "../../core/esp3doutput.h"
27 
28 #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
29 #include "Wire.h"
30 #include "esp3d_logo.h"
31 #if DISPLAY_DEVICE == OLED_I2C_SSD1306
32 #include <SSD1306Wire.h>
33 SSD1306Wire esp3d_screen(DISPLAY_I2C_ADDR, DISPLAY_I2C_PIN_SDA, DISPLAY_I2C_PIN_SCL);
34 #include "basic_SSD1306.h"
35 #endif //DISPLAY_DEVICE == OLED_I2C_SSD1306
36 #if DISPLAY_DEVICE == OLED_I2C_SSDSH1106
37 #include <SH1106Wire.h>
38 SH1106Wire esp3d_screen(DISPLAY_I2C_ADDR, (DISPLAY_I2C_PIN_SDA==-1)?SDA:DISPLAY_I2C_PIN_SDA, (DISPLAY_I2C_PIN_SCL==-1)?SCL:DISPLAY_I2C_PIN_SCL);
39 #include "basic_SSDSH1106.h"
40 #endif //DISPLAY_DEVICE == OLED_I2C_SSDSH1106
41 #endif //DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
42 #if (DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
43 #include <TFT_eSPI.h>
44 TFT_eSPI esp3d_screen = TFT_eSPI();
45 #include "esp3d_logob.h"
46 #if (DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240)
47 #include "basic_ILI9341_320X240.h"
48 #endif //(DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240)
49 #if (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
50 #include "basic_ILI9488_480X320.h"
51 #endif //(DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
52 #endif //(DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
53 #if defined (WIFI_FEATURE)
54 #include "../wifi/wificonfig.h"
55 #endif // WIFI_FEATURE
56 #if defined (ETH_FEATURE)
57 #include "../ethernet/ethconfig.h"
58 #endif //ETH_FEATURE
59 #if defined (BLUETOOTH_FEATURE)
60 #include "../bluetooth/BT_service.h"
61 #endif //BLUETOOTH_FEATURE
62 #if defined (WIFI_FEATURE) || defined (ETH_FEATURE) || defined (BLUETOOTH_FEATURE)
63 #include "../network/netconfig.h"
64 #endif //WIFI_FEATURE || ETH_FEATURE) ||BLUETOOTH_FEATURE
65 #define DISPLAY_REFRESH_TIME 1000
66 
67 
69 {
70  bool res = false;
71 #if defined(DISPLAY_TOUCH_DRIVER)
72 #if DISPLAY_TOUCH_DRIVER == XPT2046_SPI
73  uint16_t calibrationData[5];
74  clear_screen();
75  //display instructions
76  uint size = getStringWidth("Touch corners as indicated");
77  setTextFont(FONTCALIBRATION);
78  drawString("Touch corners as indicated", (SCREEN_WIDTH-size)/2, (SCREEN_HEIGHT-16)/2, CALIBRATION_FG);
79  esp3d_screen.calibrateTouch(calibrationData, CALIBRATION_CORNER, CALIBRATION_BG, 15);
80  res = true;
81  for (uint8_t i = 0; i < 5; i++) {
82  if(!Settings_ESP3D::write_uint32 (ESP_CALIBRATION_1+(4*i), calibrationData[i])) {
83  res= false;
84  }
85  }
87  res= false;
88  }
89  clear_screen();
90  if(res) {
91  SetStatus("Calibration done");
92  } else {
93  SetStatus("Calibration error");
94  }
95  update_screen(true);
96 #endif //XPT2046_SPI
97 
98 #endif //DISPLAY_TOUCH_DRIVER
99  return res;
100 }
101 
103 
104 bool Display::splash()
105 {
106  //log_esp3d("Splash");
108  return false;
109  }
110  if (!_splash_displayed) {
111  drawXbm((_screenwidth-ESP3D_Logo_width)/2, (_screenheight-ESP3D_Logo_height)/2, ESP3D_Logo_width, ESP3D_Logo_height, SPLASH_FG, SPLASH_BG,ESP3D_Logo);
112  //log_esp3d("Display Splash");
113  _splash_displayed = true;
114  return true;
115  }
116  return false;
117 }
118 
119 bool Display::showStatus(bool force)
120 {
121  //Display Status
122  bool refresh_status = force;
123  static String status;
124  if (status != _status) {
125  status = _status;
126  refresh_status = true;
127  }
128 
129  setTextFont(FONTSTATUS);
130  uint16_t size = sizetoFitSpace(status.c_str(), STATUS_AREA_W);
131  //check the need for resize
132  if (size < status.length()) {
133  static int status_shift = -1;
134  refresh_status = true;
135  status+=" ";
136  //log_esp3d("current %s", status.c_str());
137  if (status_shift != -1) {
138  if( (uint16_t)(status_shift)> status.length()) {
139  status_shift = -1;
140  }
141  }
142  //log_esp3d("shift %d", status_shift);
143  if (status_shift > 0) {
144  status.remove(0,status_shift);
145  }
146  //log_esp3d("shifted %s", status.c_str());
147  size = sizetoFitSpace(status.c_str(), STATUS_AREA_W);
148  //log_esp3d("size available %d existing %d",size, status.length());
149  if (size < status.length()) {
150  //cut
151  status = status.substring(0,size);
152  status_shift++;
153  } else {
154  status_shift = -1;
155  }
156  //log_esp3d("sized %s", status.c_str());
157  }
158  if (refresh_status) {
159  //clear area
161  drawString(status.c_str(), STATUS_AREA_X, STATUS_AREA_Y, STATUS_FG);
162  }
163  return refresh_status;
164 }
165 
166 bool Display::display_signal(bool force)
167 {
168  static int sig = -1;
169  bool refresh_signal = false;
170  bool refresh_label = false;
171  static String label;
172 #if defined (WIFI_FEATURE)
173  if (WiFiConfig::started()) {
174 
175  if (WiFi.getMode() == WIFI_AP) {
176  if (sig != 100) {
177  sig = 100;
178  refresh_signal = true;
179  }
180  if (label != WiFiConfig::AP_SSID()) {
181  label = WiFiConfig::AP_SSID();
182  refresh_label = true;
183  }
184  } else {
185  if (WiFi.isConnected()) {
186  if (sig != WiFiConfig::getSignal (WiFi.RSSI ())) {
187  sig = WiFiConfig::getSignal (WiFi.RSSI ());
188  refresh_signal = true;
189  }
190  if (label != WiFi.SSID()) {
191  label = WiFi.SSID();
192  refresh_label = true;
193  }
194  } else {
195  if (sig != -1) {
196  sig = -1;
197  refresh_signal = true;
198  }
199  if (label != "") {
200  label = "";
201  refresh_label = true;
202  }
203  }
204  }
205  //Display SSID
206  setTextFont(FONTSSID);
207  uint16_t size = sizetoFitSpace(label.c_str(), SSID_AREA_W);
208  //check the need for resize
209  if (size < label.length()) {
210  refresh_label = true;
211  static int label_shift = -1;
212  label+=" ";
213  //log_esp3d("current %s", label.c_str());
214  if (label_shift != -1) {
215  if((uint16_t)(label_shift)> label.length()) {
216  label_shift = -1;
217  }
218  }
219  //log_esp3d("shift %d", label_shift);
220  if (label_shift > 0) {
221  label.remove(0,label_shift);
222  }
223  //log_esp3d("shifted %s", label.c_str());
224  size = sizetoFitSpace(label.c_str(), SSID_AREA_W);
225  //log_esp3d("size available %d existing %d",size, label.length());
226  if (size < label.length()) {
227  //cut
228  label = label.substring(0,size);
229  label_shift++;
230  } else {
231  label_shift = -1;
232  }
233  //log_esp3d("sized %s", label.c_str());
234  }
235  if (refresh_label || force) {
236  //clear area
238  drawString(label.c_str(), SSID_AREA_X, SSID_AREA_Y, SSID_FG);
239  }
240  }
241 #endif // WIFI_FEATURE
242 
243 #if defined (ETH_FEATURE)
244  if (EthConfig::started()) {
245  if (sig != -2) {
246  sig = -2;
247  refresh_signal = true;
248  }
249  //display connection speed
250  if(ETH.linkUp()) {
251  String tmp = ETH.linkSpeed();
252  tmp+= "Mbps";
253  if (label != tmp) {
254  label = tmp;
255  refresh_label = true;
256  }
257  } else {
258  if (label !="") {
259  label ="";
260  refresh_label = true;
261  }
262  }
263  if (refresh_label || force) {
264  setTextFont(FONTSSID);
265  //clear area
267  drawString(label.c_str(), SSID_AREA_X, SSID_AREA_Y, SSID_FG);
268  }
269  }
270 #endif //ETH_FEATURE
271 
272 #if defined (BLUETOOTH_FEATURE)
273  if (bt_service.started()) {
274  if (sig!=-3) {
275  sig = -3;
276  refresh_signal = true;
277  }
278 
279  //Display hostname
280  if (label != bt_service.hostname()) {
281  refresh_label = true;
282  label = bt_service.hostname();
283  }
284  setTextFont(FONTSSID);
285  uint16_t size = sizetoFitSpace(label.c_str(), SSID_AREA_W);
286  //check the need for resize
287  if (size < label.length()) {
288  refresh_label = true;
289  static int label_shift = -1;
290  label+=" ";
291  //log_esp3d("current %s", hostname.c_str());
292  if (label_shift > label.length()) {
293  label_shift = -1;
294  }
295  //log_esp3d("shift %d", label_shift);
296  if (label_shift > 0) {
297  label.remove(0,label_shift);
298  }
299  //log_esp3d("shifted %s", hostname.c_str());
300  size = sizetoFitSpace(label.c_str(), SSID_AREA_W);
301  //log_esp3d("size available %d existing %d",size, hostname.length());
302  if (size < label.length()) {
303  //cut
304  label = label.substring(0,size);
305  label_shift++;
306  } else {
307  label_shift = -1;
308  }
309  //log_esp3d("sized %s", hostname.c_str());
310  }
311  if( refresh_label || force) {
312  //clear area
314  if (label.length()>0) {
315  drawString(label.c_str(), SSID_AREA_X, SSID_AREA_Y, SSID_FG);
316  }
317  }
318  }
319 #endif //BLUETOOTH_FEATURE
320 
321  if (refresh_signal || force) {
322  String s;
323  //set current font size
324  setTextFont(FONTSIGNAL);
327  if (sig > 0) {
328  //Signal %
329  s = String(sig);
330  s+="%";
331  //Signal Icon according %
332  if (sig > 0) {
334  } else {
336  }
337 
338  if (sig >= 25) {
340  } else {
342  }
343 
344  if (sig >= 50) {
346  } else {
348  }
349 
350  if (sig >= 75) {
352  } else {
354  }
355 
356  }
357  //No signal / no connection
358  if (sig == -1) {
359  s = " X";
360  }
361  //Ethernet is connected
362  if (sig == -2) {
363  s = "Eth";
364  }
365  //BT is active
366  if (sig == -3) {
367  s = "BT";
368  }
369  //Show Connection type
370  drawString(s.c_str(), SIGNAL_X, SIGNAL_Y, SIGNAL_FG);
371  }
372  if (refresh_signal || refresh_label || force) {
373  return true;
374  } else {
375  return false;
376  }
377 }
378 
379 bool Display::display_IP(bool force)
380 {
381  bool refresh_label = force;
382  static String label;
383 #if defined (WIFI_FEATURE) || defined (ETH_FEATURE) || defined (BLUETOOTH_FEATURE)
384  if (NetConfig::started()) {
385  String s;
386  switch(NetConfig::getMode()) {
387 #if defined (WIFI_FEATURE)
388  case ESP_WIFI_STA:
389  s = WiFi.localIP().toString();
390  break;
391  case ESP_WIFI_AP:
392  s = WiFi.softAPIP().toString();
393  break;
394 #endif //WIFI_FEATURE
395 #if defined (ETH_FEATURE)
396  case ESP_ETH_STA:
397  s = ETH.localIP().toString();
398  break;
399 #endif //ETH_FEATURE
400 #if defined (BLUETOOTH_FEATURE)
401  case ESP_BT:
402  s = bt_service.isConnected()?"Connected":"";
403  break;
404 #endif //BLUETOOTH_FEATURE
405  default:
406  s="";
407  break;
408  }
409  if (s!= label) {
410  label = s;
411  refresh_label = true;
412  }
413  if (refresh_label) {
414  if (label.length()>0) {
415  setTextFont(FONTIP);
417  drawString(label.c_str(), IP_AREA_X, IP_AREA_Y, IP_FG);
418  }
419  }
420  } else {
421  if (label != "") {
422  label = "";
423  refresh_label = true;
425  }
426  }
427 #endif //WIFI_FEATURE || ETH_FEATURE || BLUETOOTH_FEATURE
428  return refresh_label;
429 }
430 
431 bool Display::main_screen(bool force)
432 {
433  bool res = false;
434  if (display_signal(force)) {
435  res = true;
436  }
437  if (display_IP(force)) {
438  res = true;
439  }
440  if (showStatus(force)) {
441  res = true;
442  }
443  if (res) {
444  return true;
445  } else {
446  return false;
447  }
448 }
449 
450 uint16_t Display::sizetoFitSpace(const char * string, uint16_t maxwidth)
451 {
452  String s = string;
453  while (getStringWidth(s.c_str()) > maxwidth) {
454  if (s.length() > 0) {
455  s.remove(s.length()-1);
456  } else {
457  return 0;
458  }
459  }
460  return s.length();
461 }
462 
463 void Display::show_screenID(uint8_t screenID)
464 {
465  clear_screen();
466  _screenID = screenID;
467  update_screen(true);
468 }
469 
471 {
472  _started = false;
473  _screenID = SPLASH_SCREEN;
474  _splash_displayed=false;
475  _screenwidth = SCREEN_WIDTH;
476  _screenheight = SCREEN_HEIGHT;
477 }
478 
480 {
481  end();
482 }
483 
484 bool Display::begin()
485 {
486  bool res = true;
487  _started = false;
488  //log_esp3d("Init Display");
489 #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
490 #if defined(DISPLAY_I2C_PIN_RST)
491  pinMode(DISPLAY_I2C_PIN_RST,OUTPUT);
492  digitalWrite(DISPLAY_I2C_PIN_RST, LOW); // turn the LED on (HIGH is the voltage level)
493  delay(10); // wait for a second
494  digitalWrite(DISPLAY_I2C_PIN_RST, HIGH); // turn the LED off by making the voltage LOW
495 #endif //DISPLAY_I2C_PIN_RST
496  esp3d_screen.init();
497  esp3d_screen.clear();
498 #if defined(DISPLAY_FLIP_VERTICALY)
499  esp3d_screen.flipScreenVertically();
500 #endif
501 #endif //DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
502 #if (DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
503 #if defined (DISPLAY_LED_PIN) && (DISPLAY_LED_PIN!=-1)
504  pinMode(DISPLAY_LED_PIN, OUTPUT); // sets the digital pin 13 as output
505  digitalWrite(DISPLAY_LED_PIN, HIGH);
506 #endif //DISPLAY_LED_PIN
507  esp3d_screen.begin(); // Initialise the display
508 #if defined(DISPLAY_FLIP_VERTICALY)
509  esp3d_screen.setRotation(3);
510 #else
511  esp3d_screen.setRotation(1);
512 #endif
513  esp3d_screen.fillScreen(SCREEN_BG); // Black screen fill
514 #endif //(DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
516  update_screen();
517 #if defined(DISPLAY_TOUCH_DRIVER)
519  uint16_t calibrationData[5];
520  for (uint8_t i = 0; i < 5; i++) {
521  calibrationData[i] = Settings_ESP3D::read_uint32 (ESP_CALIBRATION_1+(4*i));
522  }
523  esp3d_screen.setTouch(calibrationData);
524  }
525 #endif //DISPLAY_TOUCH_DRIVER
526  res = true;
527  if (!res) {
528  end();
529  }
530  _started = res;
531  return _started;
532 }
533 
534 void Display::end()
535 {
536  if(!_started) {
537  return;
538  }
539  _status ="";
540  _started = false;
541  _screenID = SPLASH_SCREEN;
542  _splash_displayed=false;
543  clear_screen();
544 }
545 
546 void Display::SetStatus(const char * status)
547 {
548  _status= status;
549 }
550 
552 {
553  //log_esp3d("clear screen");
554 #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
555  esp3d_screen.clear();
556 #endif //#if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
557 #if (DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
558  //log_esp3d("Fill black");
559  esp3d_screen.fillScreen(SCREEN_BG); // Black screen fill
560 #endif //(DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
561 }
562 
563 void Display::update_screen(bool force)
564 {
566  return;
567  }
568  static uint32_t last_update = millis();
569  bool need_update = force;
570  if (((millis()- last_update) > DISPLAY_REFRESH_TIME) || force) {
571  last_update = millis();
572 
573  switch(_screenID) {
574  case SPLASH_SCREEN:
575  if (!_splash_displayed) {
576  need_update = splash();
577  }
578  break;
579  case MAIN_SCREEN:
580  need_update = main_screen(force);
581  break;
582  default:
583  break;
584  }
585  if (need_update) {
586 #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
587  esp3d_screen.display();
588  //log_esp3d("Update display");
589 #endif //DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
590  Hal::wait(0);
591  }
592  }
593 }
594 
595 void Display::handle()
596 {
598  return;
599  }
600  if (_started) {
601  update_screen();
602  }
603 }
604 
605 // Draw a line from position 0 to position 1
606 void Display::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t color)
607 {
609  return;
610  }
611 #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
612  esp3d_screen.setColor((color == TFT_BLACK)?BLACK:WHITE);
613  esp3d_screen.drawLine(x0, y0, x1, y1);
614 #endif //#if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
615 #if (DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
616  esp3d_screen.drawLine(x0, y0, x1, y1, color);
617 #endif (DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
618 }
619 
620 // Draw the border of a rectangle at the given location
621 void Display::drawRect(int16_t x, int16_t y, int16_t width, int16_t height, int16_t color)
622 {
624  return;
625  }
626 #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
627  esp3d_screen.setColor((color == TFT_BLACK)?BLACK:WHITE);
628  esp3d_screen.drawRect(x, y, width, height);
629 #endif //#if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
630 #if (DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
631  esp3d_screen.drawRect(x, y, width, height, color);
632 #endif //(DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
633 }
634 
635 // Fill the rectangle
636 void Display::fillRect(int16_t x, int16_t y, int16_t width, int16_t height, int16_t color)
637 {
639  return;
640  }
641 #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
642  esp3d_screen.setColor((color == TFT_BLACK)?BLACK:WHITE);
643  esp3d_screen.fillRect(x, y, width, height);
644 #endif //#if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
645 #if (DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
646  esp3d_screen.fillRect(x, y, width, height, color);
647 #endif //(DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
648 }
649 
650 void Display::setTextFont(uint8_t font)
651 {
652 #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
653  switch(font) {
654  case 3:
655  esp3d_screen.setFont(ArialMT_Plain_16);
656  break;
657  case 2:
658  default:
659  esp3d_screen.setFont(ArialMT_Plain_10);
660  }
661 #endif //#if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
662 #if (DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
663  esp3d_screen.setTextFont(font);
664 #endif //(DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
665 }
666 
667 void Display::drawString(const char *string, int32_t poX, int32_t poY, int16_t color)
668 {
670  return;
671  }
672 #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
673  esp3d_screen.setColor((color == TFT_BLACK)?BLACK:WHITE);
674  esp3d_screen.drawString(poX, poY, string);
675 #endif //#if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
676 #if (DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
677  esp3d_screen.setTextColor(color);
678  esp3d_screen.drawString(string, poX, poY);
679 #endif //(DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
680 }
681 
682 // Draw a XBM
683 void Display::drawXbm(int16_t x, int16_t y, int16_t width, int16_t height, int16_t color, const uint8_t *xbm)
684 {
686  return;
687  }
688 #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
689  (void)color;
690  esp3d_screen.drawXbm(x, y, width, height, xbm);
691 #endif //#if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
692 #if (DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
693  esp3d_screen.drawXBitmap(x, y, xbm, width, height,color);
694 #endif //(DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
695 }
696 
697 void Display::drawXbm(int16_t x, int16_t y, int16_t width, int16_t height, uint16_t fgcolor, uint16_t bgcolor, const uint8_t *xbm)
698 {
700  return;
701  }
702 #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
703  (void)fgcolor;
704  (void)bgcolor;
705  esp3d_screen.drawXbm(x, y, width, height, xbm);
706 #endif //#if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
707 #if (DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
708  esp3d_screen.drawXBitmap(x, y, xbm, width, height, fgcolor, bgcolor);
709 #endif //(DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
710 }
711 
712 uint16_t Display::getStringWidth(const char* text)
713 {
714 #if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
715  return esp3d_screen.getStringWidth(text, strlen(text));
716 #endif //#if DISPLAY_DEVICE == OLED_I2C_SSD1306 || DISPLAY_DEVICE == OLED_I2C_SSDSH1106
717 #if (DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
718  return esp3d_screen.textWidth(text);
719 #endif //(DISPLAY_DEVICE == TFT_SPI_ILI9341_320X240) || (DISPLAY_DEVICE == TFT_SPI_ILI9488_480X320)
720 }
721 
722 void Display::progress(uint8_t v)
723 {
725  return;
726  }
727  static uint8_t previous = 0;
728  if (previous > v) {
729  //clear
730  fillRect(10, _screenheight-2, _screenwidth-20, 2, SCREEN_BG);
731  }
732  //log_esp3d("%d", v);
733  previous = v;
734  //display bar
735  drawRect(10, _screenheight-2, ((_screenwidth-20) * v)/100, 2, PROGRESS_FG);
736  //update screen
737  update_screen(true);
738 }
739 
740 void display_progress(uint8_t v)
741 {
743 }
744 
745 #endif //DISPLAY_DEVICE
SIGNAL_Y
#define SIGNAL_Y
Definition: basic_ILI9341_320X240.h:47
Settings_ESP3D::write_byte
static bool write_byte(int pos, const uint8_t value)
Definition: settings_esp3d.cpp:749
SPLASH_BG
#define SPLASH_BG
Definition: basic_ILI9341_320X240.h:27
SIGNAL_ICON_Y
#define SIGNAL_ICON_Y
Definition: basic_ILI9341_320X240.h:52
SIGNAL_FG
#define SIGNAL_FG
Definition: basic_ILI9341_320X240.h:30
Display::show_screenID
void show_screenID(uint8_t screenID)
esp3d_logo.h
ESP3DOutput::isOutput
static bool isOutput(uint8_t flag, bool fromsettings=false)
Definition: esp3doutput.cpp:78
STATUS_AREA_H
#define STATUS_AREA_H
Definition: basic_ILI9341_320X240.h:71
SIGNAL_ICON_W
#define SIGNAL_ICON_W
Definition: basic_ILI9341_320X240.h:53
Hal::wait
static void wait(uint32_t milliseconds)
Definition: hal.cpp:226
SSID_AREA_W
#define SSID_AREA_W
Definition: basic_ILI9341_320X240.h:60
basicdisplay.h
Display::end
void end()
SCREEN_HEIGHT
#define SCREEN_HEIGHT
Definition: advanced_ILI9341_320X240.h:22
ESP_WIFI_STA
#define ESP_WIFI_STA
Definition: netconfig.h:41
STATUS_AREA_W
#define STATUS_AREA_W
Definition: basic_ILI9341_320X240.h:70
FONTIP
#define FONTIP
Definition: basic_ILI9341_320X240.h:41
SPLASH_SCREEN
#define SPLASH_SCREEN
Definition: advanceddisplay.h:21
CALIBRATION_FG
#define CALIBRATION_FG
Definition: advanced_SSDSH1106.h:25
Display::begin
bool begin()
SIGNAL_ICON_SPACER_X
#define SIGNAL_ICON_SPACER_X
Definition: basic_ILI9341_320X240.h:56
SSID_AREA_H
#define SSID_AREA_H
Definition: basic_ILI9341_320X240.h:61
SIGNAL_H
#define SIGNAL_H
Definition: basic_ILI9341_320X240.h:49
display_progress
void display_progress(uint8_t v)
IP_AREA_W
#define IP_AREA_W
Definition: basic_ILI9341_320X240.h:65
Display::~Display
~Display()
STATUS_AREA_X
#define STATUS_AREA_X
Definition: basic_ILI9341_320X240.h:68
SIGNAL_ICON_H
#define SIGNAL_ICON_H
Definition: basic_ILI9341_320X240.h:54
basic_SSDSH1106.h
IP_AREA_X
#define IP_AREA_X
Definition: basic_ILI9341_320X240.h:63
SSID_AREA_Y
#define SSID_AREA_Y
Definition: basic_ILI9341_320X240.h:59
Display::SetStatus
void SetStatus(const char *status)
Settings_ESP3D::write_uint32
static bool write_uint32(int pos, const uint32_t value)
Definition: settings_esp3d.cpp:970
SIGNAL_ICON_W_BAR
#define SIGNAL_ICON_W_BAR
Definition: basic_ILI9341_320X240.h:55
SIGNAL_ICON_X
#define SIGNAL_ICON_X
Definition: basic_ILI9341_320X240.h:51
Display
Definition: advanceddisplay.h:29
FONTSIGNAL
#define FONTSIGNAL
Definition: basic_ILI9341_320X240.h:39
basic_SSD1306.h
WiFiConfig::getSignal
static int32_t getSignal(int32_t RSSI)
Definition: wificonfig.cpp:107
TFT_BLACK
#define TFT_BLACK
Definition: basic_SSD1306.h:25
EthConfig::started
static bool started()
FONTSTATUS
#define FONTSTATUS
Definition: basic_ILI9341_320X240.h:42
NetConfig::getMode
static uint8_t getMode()
Definition: netconfig.cpp:207
CALIBRATION_BG
#define CALIBRATION_BG
Definition: advanced_ILI9341_320X240.h:25
ESP_CALIBRATION_1
#define ESP_CALIBRATION_1
Definition: settings_esp3d.h:84
ESP3D_Logo_width
#define ESP3D_Logo_width
Definition: esp3d_logo.h:24
CALIBRATION_CORNER
#define CALIBRATION_CORNER
Definition: advanced_ILI9341_320X240.h:26
ESP_CALIBRATION
#define ESP_CALIBRATION
Definition: settings_esp3d.h:48
Display::Display
Display()
FONTSSID
#define FONTSSID
Definition: basic_ILI9341_320X240.h:40
MAIN_SCREEN
#define MAIN_SCREEN
Definition: advanceddisplay.h:23
SIGNAL_W
#define SIGNAL_W
Definition: basic_ILI9341_320X240.h:48
Display::update_screen
void update_screen(bool force=false)
ESP_BT
#define ESP_BT
Definition: netconfig.h:43
Settings_ESP3D::read_uint32
static uint32_t read_uint32(int pos, bool *haserror=NULL)
Definition: settings_esp3d.cpp:919
STATUS_AREA_Y
#define STATUS_AREA_Y
Definition: basic_ILI9341_320X240.h:69
SIGNAL_X
#define SIGNAL_X
Definition: basic_ILI9341_320X240.h:46
SSID_AREA_X
#define SSID_AREA_X
Definition: basic_ILI9341_320X240.h:58
IP_AREA_H
#define IP_AREA_H
Definition: basic_ILI9341_320X240.h:66
ESP_ETH_STA
#define ESP_ETH_STA
Definition: netconfig.h:44
ESP_SCREEN_CLIENT
#define ESP_SCREEN_CLIENT
Definition: esp3doutput.h:28
SPLASH_FG
#define SPLASH_FG
Definition: basic_ILI9341_320X240.h:26
BTService::started
bool started()
NetConfig::started
static bool started()
Definition: netconfig.h:74
Display::progress
void progress(uint8_t v)
Settings_ESP3D::read_byte
static uint8_t read_byte(int pos, bool *haserror=NULL)
Definition: settings_esp3d.cpp:715
SSID_FG
#define SSID_FG
Definition: basic_ILI9341_320X240.h:31
IP_AREA_Y
#define IP_AREA_Y
Definition: basic_ILI9341_320X240.h:64
STATUS_FG
#define STATUS_FG
Definition: basic_ILI9341_320X240.h:33
basic_ILI9341_320X240.h
esp3d_display
Display esp3d_display
bt_service
BTService bt_service
Display::display_IP
bool display_IP(bool force=false)
Display::handle
void handle()
BTService::isConnected
bool isConnected()
Display::startCalibration
bool startCalibration()
IP_FG
#define IP_FG
Definition: basic_ILI9341_320X240.h:32
ESP_WIFI_AP
#define ESP_WIFI_AP
Definition: netconfig.h:42
BTService::hostname
const char * hostname()
SCREEN_BG
#define SCREEN_BG
Definition: basic_ILI9341_320X240.h:28
esp3d_logob.h
ESP3D_Logo_height
#define ESP3D_Logo_height
Definition: esp3d_logo.h:25
FONTCALIBRATION
#define FONTCALIBRATION
Definition: basic_ILI9341_320X240.h:43
Display::clear_screen
void clear_screen()
WiFiConfig::started
static bool started()
Definition: wificonfig.cpp:270
WiFiConfig::AP_SSID
static const char * AP_SSID()
Definition: wificonfig.cpp:387
SCREEN_WIDTH
#define SCREEN_WIDTH
Definition: advanced_ILI9341_320X240.h:21
basic_ILI9488_480X320.h
PROGRESS_FG
#define PROGRESS_FG
Definition: basic_ILI9341_320X240.h:29