// // FILE: [_controller.ino] // Created by GUIslice Builder version: [0.15.b004] // // GUIslice Builder Generated File // // For the latest guides, updates and support view: // https://github.com/ImpulseAdventure/GUIslice // // // ------------------------------------------------ // Headers to include // ------------------------------------------------ // // Varous system includes #include // Various library includes #include #include #include #include #include // Various local includes #include "_controller_GSLC.h" // SD Card stuff // 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 // // ------------------------------------------------ // Program Globals // ------------------------------------------------ // Battery level measurement #define VBATPIN A6 float measuredVBat; int batteryPercent; // TFT Setup #define TFT_CS 9 #define TFT_DC 10 Adafruit_ILI9341 tft(TFT_CS, TFT_DC); #define CHARS_HORIZONTAL 29 #define CHARS_ROWS 11 #define CHARS_TOTAL CHARS_HORIZONTAL * CHARS_ROWS CircularBuffer textBuffer; // Keyboard BBQ10Keyboard keyboard; #define KBD_BTN_1 0x06 #define KBD_BTN_2 0x11 #define KBD_BTN_3 0x07 #define KBD_BTN_4 0x12 #define KBD_SW_UP 0x01 #define KBD_SW_DN 0x02 #define KBD_SW_LF 0x03 #define KBD_SW_RT 0x04 #define KBD_SW_OK 0x05 CircularBuffer uiKeyBuffer; // Upstream keyboard definitions that will be really important later #define _REG_CFG 2 #define CFG_OVERFLOW_INT (1 << 1) #define CFG_KEY_INT (1 << 4) #define CFG_USE_MODS (1 << 7) // Should Alt, Sym and Shifts modify the keys reported #define CFG_REPORT_MODS (1 << 6) // Should Alt, Sym and Shifts be reported as well // NeoPixels #define PIXELS_NUM_BOARD 1 #define PIXELS_NUM_WING 1 #define PIXELS_WING_PIN 11 Adafruit_NeoPixel pixels_board(PIXELS_NUM_BOARD, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800); Adafruit_NeoPixel pixels_wing(PIXELS_NUM_WING, PIXELS_WING_PIN, NEO_GRB + NEO_KHZ800); // GUI state globals bool textChanged = false; bool popupOnScreen = false; int listDiagramsSize = -1; int listDiagramSelection = -1; int listDiagramsRowsShown = 0; // Various loop handlers void handlerKeyboard(); void handlerBatteryLevel(); void processRingBuffer(); void sdCardInfo(); void listNext(gslc_tsElemRef*); void listPrevious(gslc_tsElemRef*); // Save some element references for direct access // gslc_tsElemRef* m_SliderDiagrams = NULL; gslc_tsElemRef* m_pElemBatteryLevel= NULL; gslc_tsElemRef* m_pElemLsDiagrams = NULL; gslc_tsElemRef* m_pElemRd1152 = NULL; gslc_tsElemRef* m_pElemRd96 = NULL; gslc_tsElemRef* m_pElemRdUART0 = NULL; gslc_tsElemRef* m_pElemRdUART5 = NULL; gslc_tsElemRef* m_pElemRdUARTA = NULL; gslc_tsElemRef* m_pElemSDInfo = NULL; gslc_tsElemRef* m_pElemStatusText = NULL; gslc_tsElemRef* m_pElemText = NULL; gslc_tsElemRef* pImgFthM0Bsc = NULL; gslc_tsElemRef* pImgKbdFw = NULL; gslc_tsElemRef* pImgPi4Overview = NULL; gslc_tsElemRef* pImgPi4Pins = NULL; gslc_tsElemRef* pImgPiOrientation = NULL; gslc_tsElemRef* pImgRpi = NULL; // // Keyboard map related #define MAX_INPUT_MAP 5 gslc_tsInputMap m_asInputMap[MAX_INPUT_MAP]; // Define debug message function static int16_t DebugOut(char ch) { if (ch == (char)'\n') Serial.println(""); else Serial.write(ch); return 0; } // ------------------------------------------------ // Callback Methods // ------------------------------------------------ // Common Button callback bool CbBtnCommon(void* pvGui,void *pvElemRef,gslc_teTouch eTouch,int16_t nX,int16_t nY) { // Typecast the parameters to match the GUI and element types gslc_tsGui* pGui = (gslc_tsGui*)(pvGui); gslc_tsElemRef* pElemRef = (gslc_tsElemRef*)(pvElemRef); gslc_tsElem* pElem = gslc_GetElemFromRef(pGui,pElemRef); if ( eTouch == GSLC_TOUCH_UP_IN ) { // From the element's ID we can determine which button was pressed. switch (pElem->nId) { //