MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / doTimestamp

Function doTimestamp

ESP32_AP-Flasher/src/makeimage.cpp:386–415  ·  view source on GitHub ↗

The "ts_option" is a bitmapped variable with a default value of 1 which is black on white, long format @ bottom right. b2, b1, b0: 0 - no timestamp 1 - bottom right 2 - top right 3 - bottom left 4 - top left 5 -> 7 reserved b3: 0 - long format (year-month-day hr:min) 1 - short format (month-day hr:min) b4: 0 - black on white 1 - white on black b5 -> b7: reserved

Source from the content-addressed store, hash-verified

384// b5 -> b7: reserved
385//
386void doTimestamp(TFT_eSprite *spr, uint8_t ts_option) {
387 time_t now = time(nullptr);
388 struct tm *timeinfo = localtime(&now);
389 char buffer[20];
390 strftime(buffer, sizeof(buffer),
391 (ts_option & 0x8) ? "%m-%d %H:%M" : "%Y-%m-%d %H:%M",timeinfo);
392 int ts_chars = strlen(buffer);
393
394 uint16_t char_color;
395 uint16_t bg_color;
396
397 if(ts_option & 0x10) {
398 char_color = TFT_WHITE;
399 bg_color= TFT_BLACK;
400 }
401 else {
402 char_color = TFT_BLACK;
403 bg_color = TFT_WHITE;
404 }
405
406 ts_option = (ts_option & 0x3) - 1;
407
408 int32_t ts_x = (ts_option & 2) ? 1 : spr->width() - ts_chars * 6 - 2;
409 int32_t ts_y = (ts_option & 1) ? 1 : spr->height() - 10;
410
411 spr->drawRect(ts_x - 1, ts_y - 1, ts_chars * 6 + 1, 9, bg_color);
412 spr->setTextColor(char_color, bg_color);
413 spr->setCursor(ts_x,ts_y);
414 spr->print(buffer);
415}
416
417void spr2buffer(TFT_eSprite &spr, String &fileout, imgParam &imageParams) {
418 long t = millis();

Callers 1

spr2bufferFunction · 0.85

Calls 7

strlenFunction · 0.85
widthMethod · 0.80
heightMethod · 0.80
drawRectMethod · 0.80
setCursorMethod · 0.80
setTextColorMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected