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 - 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 - This should be configured via a text file on the sd card
- Way to display pinouts stored on micro 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) - Configuration read from muxes (if attached)
## Implementation (Complete) ## Implementation (Complete)

View file

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

View file

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB