Enumerate pinouts directory and show list of files available to display

This commit is contained in:
KemoNine 2020-09-27 23:33:35 -04:00
parent 4c51a6fb7d
commit a660ebc092
3 changed files with 30 additions and 19 deletions

View File

@ -40,6 +40,11 @@ These libraries are used by the project and can be installed via the Arduino IDE
- Button for accessing password selection pop-up to help with password entry over serial
- This should be configured via a text file on the sd card
- Way to display pinouts stored on micro sd card
- Max number of files is 20
- Max filename length is 24 (this includes the ```.``` and extension of the file)
- The pinouts should be stored as bmp files *up to* 24 bit
- Pinouts should be sized as close to 320x240 as possible
- Pinouts should be stored at ```/pinouts``` on the root of the SD card
- Configuration read from muxes (if attached)
## Implementation (Complete)

View File

@ -30,8 +30,14 @@
// The adagfx driver was updated to be able to retun a reference to the sd card
// This will NOT work w/o the driver tweak
// The implementation of gslc_GetSDCard only lives in the ada cpp driver so we need to extern it here
#define MAX_FILE_NAME_CHARS 21 // Add 1 to the max limit for null termination of filenames (SdFat API need)
#define MAX_PINOUTS 24
#define DIRECTORY_PINOUTS "/pinouts"
#include "src/SdFat/SdFat.h"
extern SdFat SD;
SdFile dirFile;
SdFile file;
char fileName[MAX_FILE_NAME_CHARS]; // Account for null termination
//<Includes !End!>
@ -275,25 +281,25 @@ void setup() {
gslc_InputMapAdd(&m_gui, GSLC_INPUT_PIN_ASSERT, KBD_SW_OK, GSLC_ACTION_SELECT, 0);
// Setup list of diagrams
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "Raspberry Pi");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "Friendly Arm M4");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "Orange Pi v1");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "Banana Pi");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "O-Droid HC2");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "Arduino (AVR)");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "Ardunio (ARM)");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "Cisco Console");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "APC Console");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "Raritan Console");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "Adafruit Feather");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "Adafruit Metro");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "[Unused 01]");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "[Unused 02]");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "[Unused 03]");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "[Unused 04]");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "[Unused 05]");
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, "[Unused 06]");
gslc_ElemXListboxSetSel(&m_gui, m_pElemLsDiagrams, listDiagramSelection);
// List files in pinouts directory and add to main list of available pinout files
if (!dirFile.open(DIRECTORY_PINOUTS, O_RDONLY)) {
SD.errorHalt("open root failed");
}
int n = 0;
while (n < MAX_PINOUTS && file.openNext(&dirFile, O_RDONLY)) {
n++;
// Skip directories and hidden files.
if (!file.isSubDir() && !file.isHidden()) {
// Save dirIndex of file in directory.
file.getName(fileName, MAX_FILE_NAME_CHARS * sizeof(char));
#if defined(DBG_LOG) || defined(DBG_TOUCH) || defined(DBG_FRAME_RATE) || defined(DBG_DRAW_IMM) || defined(DBG_DRIVER)
Serial.println(fileName);
#endif
gslc_ElemXListboxAddItem(&m_gui, m_pElemLsDiagrams, fileName);
}
file.close();
}
// Set diagrams slider max equal to the number of elements
listDiagramsSize = gslc_ElemXListboxGetItemCnt(&m_gui, m_pElemLsDiagrams);

View File

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB