MCPcopy Create free account
hub / github.com/bmorcelli/Launcher / loopSD

Function loopSD

src/sd_functions.cpp:296–411  ·  view source on GitHub ↗

** Function: loopSD ** Where you choose what to do wuth your SD Files **********************************************************************/

Source from the content-addressed store, hash-verified

294** Where you choose what to do wuth your SD Files
295**********************************************************************/
296String loopSD(bool filePicker) {
297 // Function using loopOptions to store and handle files
298 returnToMenu = false;
299 fileToUse = ""; // resets global variable
300 int index = 0;
301 int Menuindex = 0;
302 String Folder = "/";
303 String _Folder = ""; // Check if Folder changed
304 String PreFolder = "/";
305 bool isFolder = false;
306 bool isOperator = false;
307 bool LongPressDetected = false;
308 bool read_fs = true;
309 bool bkf = false;
310RESTART:
311 if (_Folder != Folder || read_fs) {
312 readFs(Folder, options);
313 if (options.size() == 0) return ""; // Failed reading SD card.
314 _Folder = Folder;
315 index = 0;
316 bkf = false;
317 read_fs = false;
318 }
319 index = loopOptions(options, false, FGCOLOR, BGCOLOR, false, index);
320 // First Exit
321 if (index < 0) goto BACK_FOLDER;
322 // Check if it is Folder or operator (> Back)
323 if (options[index].color == uint16_t(FGCOLOR - 0x1111)) isFolder = true;
324 else isFolder = false;
325 if (options[index].color == uint16_t(ALCOLOR)) isOperator = true;
326 else isOperator = false;
327 if (filePicker && !isFolder && !isOperator) return fileToUse;
328
329 // Long Press Detection
330 LongPressDetected = false;
331#ifndef E_PAPER_DISPLAY
332 LongPress = true;
333 SelPress = true; // it was just pressed
334 LongPressTmp = launcherMillis();
335 while (launcherMillis() - LongPressTmp < 300 && SelPress) {
336 check(AnyKeyPress);
337 vTaskDelay(20 / portTICK_PERIOD_MS);
338 }
339 if (check(SelPress)) LongPressDetected = true;
340 LongPress = false;
341 SelPress = false;
342#else
343 // Always behave as if it was long pressed
344 // But shows Option to enter on folders
345 LongPressDetected = true;
346#endif
347 // Menu for if it is a Folder
348 if (isFolder) {
349 // Short press on folder opens the folder
350 if (!LongPressDetected) {
351 PreFolder = Folder;
352 Folder = fileToUse;
353 launcherConsolePrintf(

Callers 3

dumpPartitionFunction · 0.85
restorePartitionFunction · 0.85
loopFunction · 0.85

Calls 13

readFsFunction · 0.85
loopOptionsFunction · 0.85
launcherMillisFunction · 0.85
checkFunction · 0.85
launcherConsolePrintfFunction · 0.85
createFolderFunction · 0.85
deleteFromSdFunction · 0.85
pasteFileFunction · 0.85
updateFromSDFunction · 0.85
copyFileFunction · 0.85
renameFileFunction · 0.70
clearMethod · 0.45

Tested by

no test coverage detected