MCPcopy Create free account
hub / github.com/BruceDevices/firmware / listFiles

Function listFiles

src/core/display.cpp:997–1039  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

995***************************************************************************************/
996#define MAX_ITEMS (int)(tftHeight - 20) / (LH * FM)
997Opt_Coord listFiles(int index, std::vector<FileList> fileList) {
998 Opt_Coord coord;
999 tft.drawPixel(0, 0, bruceConfig.bgColor);
1000 if (index == 0) {
1001 tft.fillScreen(bruceConfig.bgColor);
1002 tft.drawRoundRect(5, 5, tftWidth - 10, tftHeight - 10, 5, bruceConfig.priColor);
1003 }
1004 tft.setCursor(10, 10);
1005 tft.setTextSize(FM);
1006 int i = 0;
1007 int arraySize = fileList.size();
1008 int start = 0;
1009 if (index >= MAX_ITEMS) {
1010 start = index - MAX_ITEMS + 1;
1011 if (start < 0) start = 0;
1012 }
1013 int nchars = (tftWidth - 20) / (6 * tft.getTextSize());
1014 String txt = ">";
1015 while (i < arraySize) {
1016 if (i >= start) {
1017 tft.setCursor(10, tft.getCursorY());
1018 if (fileList[i].folder == true)
1019 tft.setTextColor(getColorVariation(bruceConfig.priColor), bruceConfig.bgColor);
1020 else if (fileList[i].operation == true) tft.setTextColor(ALCOLOR, bruceConfig.bgColor);
1021 else { tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor); }
1022
1023 if (index == i) {
1024 txt = ">";
1025 coord.x = 10 + FM * LW;
1026 coord.y = tft.getCursorY();
1027 coord.size = nchars;
1028 coord.fgcolor =
1029 fileList[i].folder ? getColorVariation(bruceConfig.priColor) : bruceConfig.priColor;
1030 coord.bgcolor = bruceConfig.bgColor;
1031 } else txt = " ";
1032 txt += fileList[i].filename + " ";
1033 tft.println(txt.substring(0, nchars));
1034 }
1035 i++;
1036 if (i == (start + MAX_ITEMS) || i == arraySize) break;
1037 }
1038 return coord;
1039}
1040
1041// desenhos do menu principal, sprite "draw" com 80x80 pixels
1042

Callers 1

loopSDFunction · 0.70

Calls 11

getColorVariationFunction · 0.85
sizeMethod · 0.80
drawPixelMethod · 0.45
fillScreenMethod · 0.45
drawRoundRectMethod · 0.45
setCursorMethod · 0.45
setTextSizeMethod · 0.45
getTextSizeMethod · 0.45
getCursorYMethod · 0.45
setTextColorMethod · 0.45
printlnMethod · 0.45

Tested by

no test coverage detected