New feature: show boot clock during boot.
This commit is contained in:
parent
91653e197f
commit
2e4c173c6c
|
@ -66,11 +66,70 @@ void Display::begin(void) {
|
||||||
//addLogMessage("Display initialized");
|
//addLogMessage("Display initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define BOOT_CLOCK_WIDTH 16
|
||||||
|
#define BOOT_CLOCK_PIXEL_WIDTH 2
|
||||||
|
#define BOOT_CLOCK_PIXELS_PER_SIDE (BOOT_CLOCK_WIDTH / BOOT_CLOCK_PIXEL_WIDTH - 1)
|
||||||
|
#define BOOT_CLOCK_PIXELS (BOOT_CLOCK_PIXELS_PER_SIDE * 4)
|
||||||
|
#define BOOT_CLOCK_FORWARD_AFTER_ms 200
|
||||||
|
// Example: WIDTH=16, PIXEL_WIDTH = 4 --> 3 pixels per side (4 seen, but one would be counted double)
|
||||||
|
// Result: Pixels a / b / c / d
|
||||||
|
// a1 a2 a3 b1
|
||||||
|
// d3 b2
|
||||||
|
// d2 b3
|
||||||
|
// d1 c3 c2 c1
|
||||||
|
//
|
||||||
|
void Display::showBootClock(void) {
|
||||||
|
static unsigned long lastClockUpdate_ts = 0;
|
||||||
|
static int tick = 0;
|
||||||
|
|
||||||
|
if (millis() - lastClockUpdate_ts >= BOOT_CLOCK_FORWARD_AFTER_ms) {
|
||||||
|
++tick;
|
||||||
|
if (tick >= BOOT_CLOCK_PIXELS) {
|
||||||
|
tick = 0;
|
||||||
|
/*
|
||||||
|
u8g2.setDrawColor(0);
|
||||||
|
u8g2.drawBox(u8g2.getDisplayWidth()-BOOT_CLOCK_WIDTH, 0, BOOT_CLOCK_WIDTH, BOOT_CLOCK_WIDTH);
|
||||||
|
u8g2.setDrawColor(1);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
u8g2.setDrawColor(2); // XOR
|
||||||
|
// draw appropriate pixels
|
||||||
|
int x=0, y=0, side, pixelOnSide; // side = 0, 1, 2, 3 for a, b, c, d
|
||||||
|
|
||||||
|
side = tick / BOOT_CLOCK_PIXELS_PER_SIDE;
|
||||||
|
pixelOnSide = tick % BOOT_CLOCK_PIXELS_PER_SIDE;
|
||||||
|
switch (side) {
|
||||||
|
case 0: // top
|
||||||
|
x = u8g2.getDisplayWidth() - BOOT_CLOCK_WIDTH + pixelOnSide * BOOT_CLOCK_PIXEL_WIDTH;
|
||||||
|
y = 0;
|
||||||
|
break;
|
||||||
|
case 1: // right
|
||||||
|
x = u8g2.getDisplayWidth() - BOOT_CLOCK_PIXEL_WIDTH;
|
||||||
|
y = pixelOnSide * BOOT_CLOCK_PIXEL_WIDTH;
|
||||||
|
break;
|
||||||
|
case 2: // bottom
|
||||||
|
x = u8g2.getDisplayWidth() - (1 + pixelOnSide) * BOOT_CLOCK_PIXEL_WIDTH;
|
||||||
|
y = BOOT_CLOCK_WIDTH - BOOT_CLOCK_PIXEL_WIDTH;
|
||||||
|
break;
|
||||||
|
case 3: // left
|
||||||
|
x = u8g2.getDisplayWidth() - BOOT_CLOCK_WIDTH;
|
||||||
|
y = BOOT_CLOCK_WIDTH - (1 + pixelOnSide) * BOOT_CLOCK_PIXEL_WIDTH;
|
||||||
|
}
|
||||||
|
u8g2.drawBox(x, y, BOOT_CLOCK_PIXEL_WIDTH, BOOT_CLOCK_PIXEL_WIDTH);
|
||||||
|
u8g2.setDrawColor(1);
|
||||||
|
u8g2.drawCircle(u8g2.getDisplayWidth()-BOOT_CLOCK_WIDTH/2, BOOT_CLOCK_WIDTH/2, BOOT_CLOCK_PIXEL_WIDTH, U8G2_DRAW_ALL);
|
||||||
|
u8g2.setDrawColor(1);
|
||||||
|
u8g2.sendBuffer();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool Display::showBootSequenceFinished(unsigned int ms_per_step) {
|
bool Display::showBootSequenceFinished(unsigned int ms_per_step) {
|
||||||
static int step = 0;
|
static int step = 0;
|
||||||
static unsigned long lastStep_ms = 0;
|
static unsigned long lastStep_ms = 0;
|
||||||
|
|
||||||
if (step > 4) return true; // all is done; the value "4" corresponds to the number of steps in following case statement!
|
if (step > 4) return true; // all is done; the value "4" corresponds to the number of steps in following case statement!
|
||||||
|
showBootClock();
|
||||||
if (ms_per_step > millis() - lastStep_ms) return false; // do nothing, if last step execution is not long enough ago
|
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);
|
Serial.print("showBootSequence: step="); Serial.println(step);
|
||||||
lastStep_ms = millis();
|
lastStep_ms = millis();
|
||||||
|
@ -80,20 +139,12 @@ bool Display::showBootSequenceFinished(unsigned int ms_per_step) {
|
||||||
currentScreen = BootSequenceScreen;
|
currentScreen = BootSequenceScreen;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
u8g2.drawPixel(100, 10);
|
|
||||||
u8g2.drawPixel(102, 12);
|
|
||||||
u8g2.drawPixel(104, 14);
|
|
||||||
u8g2.drawPixel(106, 16);
|
|
||||||
u8g2.sendBuffer();
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
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;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
u8g2.drawXBMP(60, 0, 16, 16, logo16_glcd_bmp);
|
//u8g2.drawXBMP(60, 0, 16, 16, logo16_glcd_bmp);
|
||||||
u8g2.sendBuffer();
|
//u8g2.sendBuffer();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
break; // empty step to be sure, that last step is displayed long enough
|
break; // empty step to be sure, that last step is displayed long enough
|
||||||
|
|
|
@ -58,5 +58,6 @@ private:
|
||||||
int getTextCharsPerLine(void);
|
int getTextCharsPerLine(void);
|
||||||
void setNormalTextSize(void);
|
void setNormalTextSize(void);
|
||||||
void setLargeTextSize(void);
|
void setLargeTextSize(void);
|
||||||
|
void showBootClock(void);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -247,7 +247,7 @@ void checkForPowerOffRequest() {
|
||||||
|
|
||||||
void loop(void)
|
void loop(void)
|
||||||
{
|
{
|
||||||
if (!display.showBootSequenceFinished(1000)) {
|
if (!display.showBootSequenceFinished(4000)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue