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

Function replaceVariables

ESP32_AP-Flasher/src/contentmanager.cpp:669–693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

667}
668
669void replaceVariables(String &format) {
670 size_t startIndex = 0;
671 size_t openBraceIndex, closeBraceIndex;
672
673 time_t now;
674 time(&now);
675 struct tm timedef;
676 localtime_r(&now, &timedef);
677 char timeBuffer[80];
678 strftime(timeBuffer, sizeof(timeBuffer), "%H:%M:%S", &timedef);
679 setVarDB("ap_time", timeBuffer, false);
680
681 while ((openBraceIndex = format.indexOf('{', startIndex)) != -1 &&
682 (closeBraceIndex = format.indexOf('}', openBraceIndex + 1)) != -1) {
683 const std::string variableName = format.substring(openBraceIndex + 1, closeBraceIndex).c_str();
684 const std::string varKey = "{" + variableName + "}";
685 const auto var = varDB.find(variableName);
686 if (var != varDB.end()) {
687 format.replace(varKey.c_str(), var->second.value);
688 } else {
689 format.replace(varKey.c_str(), "-");
690 }
691 startIndex = closeBraceIndex + 1;
692 }
693}
694
695void drawString(TFT_eSprite &spr, String content, int16_t posx, int16_t posy, String font, byte align, uint16_t color, uint16_t size, uint16_t bgcolor) {
696 // drawString(spr,"test",100,10,"bahnschrift30",TC_DATUM,TFT_RED);

Callers 2

drawStringFunction · 0.85
drawTextBoxFunction · 0.85

Calls 3

setVarDBFunction · 0.85
findMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected