#include #include #include #include "display.h" // display U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 16, /* clock=*/ 5, /* data=*/ 4); #define LOGO16_GLCD_HEIGHT 16 #define LOGO16_GLCD_WIDTH 16 static const unsigned char PROGMEM logo16_glcd_bmp[] = { 0x00, 0xc0, // B00000000, B11000000, 0x01, 0xc0, // B00000001, B11000000, 0x01, 0xc0, // B00000001, B11000000, 0x03, 0xe0, // B00000011, B11100000, 0xf3, 0xe0, // B11110011, B11100000, 0xfe, 0xf8, // B11111110, B11111000, 0x7e, 0xff, // B01111110, B11111111, 0x33, 0x9f, // B00110011, B10011111, 0x1f, 0xfc, // B00011111, B11111100, 0x0d, 0x70, // B00001101, B01110000, 0x1b, 0xa0, // B00011011, B10100000, 0x3f, 0xe0, // B00111111, B11100000, 0x3f, 0xf0, // B00111111, B11110000, 0x7c, 0xf0, // B01111100, B11110000, 0x70, 0x70, // B01110000, B01110000, 0x00, 0x30 // B00000000, B00110000 }; void Display::setSmallTextSize(void) { u8g2.setFont(/*u8g2_font_profont10_tf*/ u8g2_font_4x6_tf ); } int Display::getTextHeight(void) { return u8g2.getMaxCharHeight(); } int Display::getTextCharsPerLine(void) { return u8g2.getDisplayWidth() / u8g2.getMaxCharWidth(); } void Display::setNormalTextSize(void) { u8g2.setFont(/*u8g2_font_t0_11_tf*/ u8g2_font_mozart_nbp_tf); } //static uint8_t getNormalTextHeight() { return Org_01.yAdvance; } //static uint8_t getNormalTextCharsPerLine() { return 24; } void Display::setLargeTextSize(void) { u8g2.setFont(u8g2_font_9x15B_tf); } //static uint8_t getLargeTextHeight() { return FreeMonoBold9pt7b.yAdvance; } //static uint8_t getLargeTextCharsPerLine() { return 12; } Display::Display() { currentScreen = NoScreen; numberLogLines = 0; setClockName("noname"); setClockSpeed("---"); setTime(5, 0); setClockWeekday("Mon"); setClockHalted(true); setNumberKnownClients(0); for (int i=0; i 4) return true; // all is done; the value "4" corresponds to the number of steps in following case statement! if (ms_per_step > millis() - lastStep_ms) return false; // do nothing, if last step execution is not long enough ago Serial.print("showBootSequence: step="); Serial.println(step); lastStep_ms = millis(); switch (step) { case 0: currentScreen = BootSequenceScreen; break; case 1: u8g2.drawPixel(100, 10); u8g2.drawPixel(102, 12); u8g2.drawPixel(104, 14); u8g2.drawPixel(106, 16); u8g2.sendBuffer(); break; case 2: u8g2.drawLine(100, u8g2.getDisplayHeight()-1, u8g2.getDisplayWidth()-1, u8g2.getDisplayHeight()/2); u8g2.drawCircle(u8g2.getDisplayWidth()-20, u8g2.getDisplayHeight()-10, 10, U8G2_DRAW_UPPER_LEFT | U8G2_DRAW_LOWER_RIGHT); u8g2.sendBuffer(); break; case 3: u8g2.drawXBMP(60, 0, 16, 16, logo16_glcd_bmp); u8g2.sendBuffer(); break; case 4: break; // empty step to be sure, that last step is displayed long enough // if you add a step, then you need to change the condition at the beginning of this method as well (if (step > ...) default: // do nothing break; } ++step; return false; } void Display::showLog(void) { currentScreen = LogScreen; u8g2.clearBuffer(); u8g2.setDrawColor(1); setSmallTextSize(); for (int i=0; i= MAX_NUMBER_LOG_LINES) { for (int i=0; i"); // ***** client list ***** u8g2.drawVLine(79, 0, u8g2.getDisplayHeight()); for (int i=0; i<5; ++i) { u8g2.setDrawColor(1); u8g2.drawBox(81, i * getTextHeight(), 3*3+1, getTextHeight()); u8g2.setCursor(82, (i+1) * getTextHeight()); u8g2.setDrawColor(0); if (i < 10) u8g2.print(0); u8g2.print(i); u8g2.setDrawColor(1); u8g2.setCursor(82+3*3+1+1, (i+1) * getTextHeight()); u8g2.print(clientName[i]); } u8g2.sendBuffer(); }