Update UI to be more consistent, further implementation of sd card page / pop-up
This commit is contained in:
parent
0a35c797a8
commit
7a0e3634bc
|
@ -26,6 +26,13 @@
|
|||
// 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
|
||||
#include "src/SdFat/SdFat.h"
|
||||
extern SdFat SD;
|
||||
|
||||
//<Includes !End!>
|
||||
|
||||
// ------------------------------------------------
|
||||
|
@ -75,15 +82,19 @@ Adafruit_NeoPixel pixels_wing(PIXELS_NUM_WING, PIXELS_WING_PIN, NEO_GRB + NEO_KH
|
|||
|
||||
// GUI state globals
|
||||
bool textChanged = false;
|
||||
bool popupOnScreen = false;
|
||||
|
||||
// Various loop handlers
|
||||
void handlerKeyboard();
|
||||
void handlerBatteryLevel();
|
||||
void processRingBuffer();
|
||||
void sdCardInfo();
|
||||
|
||||
// Save some element references for direct access
|
||||
//<Save_References !Start!>
|
||||
gslc_tsElemRef* m_pElemBatteryLevel= NULL;
|
||||
gslc_tsElemRef* m_pElemBtSDNo = NULL;
|
||||
gslc_tsElemRef* m_pElemBtSDYes = NULL;
|
||||
gslc_tsElemRef* m_pElemRd1152 = NULL;
|
||||
gslc_tsElemRef* m_pElemRd96 = NULL;
|
||||
gslc_tsElemRef* m_pElemRdUART0 = NULL;
|
||||
|
@ -116,6 +127,16 @@ bool CbBtnCommon(void* pvGui,void *pvElemRef,gslc_teTouch eTouch,int16_t nX,int1
|
|||
switch (pElem->nId) {
|
||||
//<Button Enums !Start!>
|
||||
case E_ELEM_BTN_SD_FMT:
|
||||
gslc_PopupShow(&m_gui, E_PG_SD_CONFIRM, false);
|
||||
popupOnScreen = true;
|
||||
break;
|
||||
case E_ELEM_SD_NO:
|
||||
gslc_PopupHide(&m_gui);
|
||||
popupOnScreen = false;
|
||||
break;
|
||||
case E_ELEM_SD_YES:
|
||||
gslc_PopupHide(&m_gui);
|
||||
popupOnScreen = false;
|
||||
break;
|
||||
//<Button Enums !End!>
|
||||
default:
|
||||
|
@ -264,13 +285,17 @@ void handlerKeyboard() {
|
|||
if (key.state == BBQ10Keyboard::StatePress) {
|
||||
// Move right through screens
|
||||
if (key.key == KBD_BTN_4) {
|
||||
if (popupOnScreen) {
|
||||
// Do nothing -- need to clear popup first
|
||||
}
|
||||
// Main Screen Flip
|
||||
if (gslc_GetPageCur(&m_gui) == E_PG_MAIN) {
|
||||
else if (gslc_GetPageCur(&m_gui) == E_PG_MAIN) {
|
||||
gslc_ElemSetTxtStr(&m_gui, m_pElemStatusText, "Raspberry Pi");
|
||||
gslc_SetPageCur(&m_gui, E_CONF_RPI);
|
||||
}
|
||||
// Raspberry Pi Screen Flip
|
||||
else if (gslc_GetPageCur(&m_gui) == E_CONF_RPI) {
|
||||
sdCardInfo();
|
||||
gslc_ElemSetTxtStr(&m_gui, m_pElemStatusText, "SD Card");
|
||||
gslc_SetPageCur(&m_gui, E_SD_CARD);
|
||||
}
|
||||
|
@ -357,3 +382,32 @@ void handlerBatteryLevel() {
|
|||
// Update GUI and NeoPixel with battery status information
|
||||
pixels_board.show();
|
||||
}
|
||||
|
||||
void sdCardInfo() {
|
||||
// Clear text box
|
||||
gslc_ElemXTextboxReset(&m_gui, m_pElemSDInfo);
|
||||
|
||||
// Reasonably small buffer for filling text box
|
||||
char textForDisplay[64];
|
||||
|
||||
// FAT Type
|
||||
snprintf(textForDisplay, 64, "Volume is FAT%d\n", int(SD.vol()->fatType()));
|
||||
gslc_ElemXTextboxAdd(&m_gui, m_pElemSDInfo, textForDisplay);
|
||||
|
||||
// Free Space
|
||||
snprintf(textForDisplay, 64, "Free Space (MB): N/A\n (Performance Issues)\n");
|
||||
gslc_ElemXTextboxAdd(&m_gui, m_pElemSDInfo, textForDisplay);
|
||||
|
||||
// Total size
|
||||
float size = 0.000512*SD.card()->cardSize();
|
||||
snprintf(textForDisplay, 64, "Total Space (MB): %.2f\n", size);
|
||||
gslc_ElemXTextboxAdd(&m_gui, m_pElemSDInfo, textForDisplay);
|
||||
|
||||
// Blocks Per Cluster
|
||||
snprintf(textForDisplay, 64, "Blocks Per Cluster: %d\n", int(SD.vol()->blocksPerCluster()));
|
||||
gslc_ElemXTextboxAdd(&m_gui, m_pElemSDInfo, textForDisplay);
|
||||
|
||||
// Cluster Count
|
||||
snprintf(textForDisplay, 64, "Cluster Count: %d\n", SD.vol()->clusterCount());
|
||||
gslc_ElemXTextboxAdd(&m_gui, m_pElemSDInfo, textForDisplay);
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -35,6 +35,9 @@
|
|||
#error Project tab->Target Platform should be tft_espi
|
||||
#endif
|
||||
#include <Adafruit_GFX.h>
|
||||
#include "src/guislice/NotoMono10pt7b.h"
|
||||
#include "src/guislice/NotoMono12pt7b.h"
|
||||
#include "src/guislice/NotoMono16pt7b.h"
|
||||
#include "src/guislice/NotoMono8pt7b.h"
|
||||
//<Fonts !End!>
|
||||
|
||||
|
@ -48,14 +51,17 @@
|
|||
// Enumerations for pages, elements, fonts, images
|
||||
// ------------------------------------------------
|
||||
//<Enum !Start!>
|
||||
enum {E_PG_BASE,E_PG_MAIN,E_CONF_RPI,E_SD_CARD};
|
||||
enum {E_ELEM_BATT_LEVEL,E_ELEM_BTN_SD_FMT,E_ELEM_RD96,E_ELEM_RD_1152
|
||||
,E_ELEM_RD_UART0,E_ELEM_RD_UART5,E_ELEM_STATUS,E_ELEM_TEXT
|
||||
,E_ELEM_TEXT3,E_ELEM_TEXT4,E_ELEM_TX96,E_ELEM_TX_1152
|
||||
,E_ELEM_TX_SD_INFO,E_ELEM_TX_UART1,E_ELEM_TX_UART5,E_STATUS_LINE};
|
||||
enum {E_PG_BASE,E_PG_MAIN,E_CONF_RPI,E_SD_CARD,E_PG_SD_CONFIRM};
|
||||
enum {E_ELEM_BATT_LEVEL,E_ELEM_BOX1,E_ELEM_BTN_SD_FMT,E_ELEM_RD96
|
||||
,E_ELEM_RD_1152,E_ELEM_RD_UART0,E_ELEM_RD_UART5,E_ELEM_SD_NO
|
||||
,E_ELEM_SD_YES,E_ELEM_STATUS,E_ELEM_TEXT,E_ELEM_TEXT14
|
||||
,E_ELEM_TEXT15,E_ELEM_TEXT3,E_ELEM_TEXT4,E_ELEM_TX96
|
||||
,E_ELEM_TX_1152,E_ELEM_TX_SD_INFO,E_ELEM_TX_UART1,E_ELEM_TX_UART5
|
||||
,E_STATUS_LINE};
|
||||
enum {E_GRP_SPD,E_GRP_UART};
|
||||
// Must use separate enum for fonts with MAX_FONT at end to use gslc_FontSet.
|
||||
enum {E_AO_NOTOMONO8PT7B,MAX_FONT};
|
||||
enum {E_AO_NOTOMONO10PT7B,E_AO_NOTOMONO12PT7B,E_AO_NOTOMONO16PT7B
|
||||
,E_AO_NOTOMONO8PT7B,MAX_FONT};
|
||||
//<Enum !End!>
|
||||
|
||||
// ------------------------------------------------
|
||||
|
@ -66,7 +72,7 @@ enum {E_AO_NOTOMONO8PT7B,MAX_FONT};
|
|||
// Define the maximum number of elements and pages
|
||||
// ------------------------------------------------
|
||||
//<ElementDefines !Start!>
|
||||
#define MAX_PAGE 4
|
||||
#define MAX_PAGE 5
|
||||
|
||||
#define MAX_ELEM_PG_BASE 3 // # Elems total on page
|
||||
#define MAX_ELEM_PG_BASE_RAM MAX_ELEM_PG_BASE // # Elems in RAM
|
||||
|
@ -79,6 +85,9 @@ enum {E_AO_NOTOMONO8PT7B,MAX_FONT};
|
|||
|
||||
#define MAX_ELEM_SD_CARD 2 // # Elems total on page
|
||||
#define MAX_ELEM_SD_CARD_RAM MAX_ELEM_SD_CARD // # Elems in RAM
|
||||
|
||||
#define MAX_ELEM_PG_SD_CONFIRM 5 // # Elems total on page
|
||||
#define MAX_ELEM_PG_SD_CONFIRM_RAM MAX_ELEM_PG_SD_CONFIRM // # Elems in RAM
|
||||
//<ElementDefines !End!>
|
||||
|
||||
// ------------------------------------------------
|
||||
|
@ -98,6 +107,8 @@ gslc_tsElem m_asPage2Elem[MAX_ELEM_CONF_RPI_RAM];
|
|||
gslc_tsElemRef m_asPage2ElemRef[MAX_ELEM_CONF_RPI];
|
||||
gslc_tsElem m_asPage3Elem[MAX_ELEM_SD_CARD_RAM];
|
||||
gslc_tsElemRef m_asPage3ElemRef[MAX_ELEM_SD_CARD];
|
||||
gslc_tsElem m_asPopup1Elem[MAX_ELEM_PG_SD_CONFIRM_RAM];
|
||||
gslc_tsElemRef m_asPopup1ElemRef[MAX_ELEM_PG_SD_CONFIRM];
|
||||
gslc_tsXProgress m_sXBarGauge2;
|
||||
gslc_tsXTextbox m_sTextbox1;
|
||||
char m_acTextboxBuf1[952]; // NRows=17 NCols=56
|
||||
|
@ -106,7 +117,7 @@ gslc_tsXCheckbox m_asXRadio2;
|
|||
gslc_tsXCheckbox m_asXRadio3;
|
||||
gslc_tsXCheckbox m_asXRadio4;
|
||||
gslc_tsXTextbox m_sTextbox2;
|
||||
char m_acTextboxBuf2[168]; // NRows=6 NCols=28
|
||||
char m_acTextboxBuf2[224]; // NRows=8 NCols=28
|
||||
|
||||
#define MAX_STR 100
|
||||
|
||||
|
@ -119,6 +130,8 @@ char m_acTextboxBuf2[168]; // NRows=6 NCols=28
|
|||
// Element References for direct access
|
||||
//<Extern_References !Start!>
|
||||
extern gslc_tsElemRef* m_pElemBatteryLevel;
|
||||
extern gslc_tsElemRef* m_pElemBtSDNo;
|
||||
extern gslc_tsElemRef* m_pElemBtSDYes;
|
||||
extern gslc_tsElemRef* m_pElemRd1152;
|
||||
extern gslc_tsElemRef* m_pElemRd96;
|
||||
extern gslc_tsElemRef* m_pElemRdUART0;
|
||||
|
@ -158,6 +171,9 @@ void InitGUIslice_gen()
|
|||
// Load Fonts
|
||||
// ------------------------------------------------
|
||||
//<Load_Fonts !Start!>
|
||||
if (!gslc_FontSet(&m_gui,E_AO_NOTOMONO10PT7B,GSLC_FONTREF_PTR,&NotoMono10pt7b,1)) { return; }
|
||||
if (!gslc_FontSet(&m_gui,E_AO_NOTOMONO12PT7B,GSLC_FONTREF_PTR,&NotoMono12pt7b,1)) { return; }
|
||||
if (!gslc_FontSet(&m_gui,E_AO_NOTOMONO16PT7B,GSLC_FONTREF_PTR,&NotoMono16pt7b,1)) { return; }
|
||||
if (!gslc_FontSet(&m_gui,E_AO_NOTOMONO8PT7B,GSLC_FONTREF_PTR,&NotoMono8pt7b,1)) { return; }
|
||||
//<Load_Fonts !End!>
|
||||
|
||||
|
@ -166,6 +182,7 @@ void InitGUIslice_gen()
|
|||
gslc_PageAdd(&m_gui,E_PG_MAIN,m_asPage1Elem,MAX_ELEM_PG_MAIN_RAM,m_asPage1ElemRef,MAX_ELEM_PG_MAIN);
|
||||
gslc_PageAdd(&m_gui,E_CONF_RPI,m_asPage2Elem,MAX_ELEM_CONF_RPI_RAM,m_asPage2ElemRef,MAX_ELEM_CONF_RPI);
|
||||
gslc_PageAdd(&m_gui,E_SD_CARD,m_asPage3Elem,MAX_ELEM_SD_CARD_RAM,m_asPage3ElemRef,MAX_ELEM_SD_CARD);
|
||||
gslc_PageAdd(&m_gui,E_PG_SD_CONFIRM,m_asPopup1Elem,MAX_ELEM_PG_SD_CONFIRM_RAM,m_asPopup1ElemRef,MAX_ELEM_PG_SD_CONFIRM);
|
||||
|
||||
// Now mark E_PG_BASE as a "base" page which means that it's elements
|
||||
// are always visible. This is useful for common page elements.
|
||||
|
@ -218,20 +235,22 @@ void InitGUIslice_gen()
|
|||
// Create E_ELEM_TEXT3 text label
|
||||
pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_TEXT3,E_CONF_RPI,(gslc_tsRect){2,40,40,21},
|
||||
(char*)"UART",0,E_AO_NOTOMONO8PT7B);
|
||||
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLUE_LT2);
|
||||
|
||||
// Create E_ELEM_TEXT4 text label
|
||||
pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_TEXT4,E_CONF_RPI,(gslc_tsRect){2,120,120,21},
|
||||
(char*)"Speed / Baud",0,E_AO_NOTOMONO8PT7B);
|
||||
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLUE_LT2);
|
||||
|
||||
// Create radio button E_ELEM_RD_UART5
|
||||
pElemRef = gslc_ElemXCheckboxCreate(&m_gui,E_ELEM_RD_UART5,E_CONF_RPI,&m_asXRadio1,
|
||||
(gslc_tsRect){160,80,20,20},true,GSLCX_CHECKBOX_STYLE_ROUND,GSLC_COL_YELLOW,false);
|
||||
(gslc_tsRect){160,80,20,20},true,GSLCX_CHECKBOX_STYLE_ROUND,GSLC_COL_BLUE_LT2,false);
|
||||
gslc_ElemSetGroup(&m_gui,pElemRef,E_GRP_UART);
|
||||
m_pElemRdUART5 = pElemRef;
|
||||
|
||||
// Create radio button E_ELEM_RD_UART0
|
||||
pElemRef = gslc_ElemXCheckboxCreate(&m_gui,E_ELEM_RD_UART0,E_CONF_RPI,&m_asXRadio2,
|
||||
(gslc_tsRect){10,80,20,20},true,GSLCX_CHECKBOX_STYLE_ROUND,GSLC_COL_YELLOW,true);
|
||||
(gslc_tsRect){10,80,20,20},true,GSLCX_CHECKBOX_STYLE_ROUND,GSLC_COL_BLUE_LT2,true);
|
||||
gslc_ElemSetGroup(&m_gui,pElemRef,E_GRP_UART);
|
||||
m_pElemRdUART0 = pElemRef;
|
||||
|
||||
|
@ -247,13 +266,13 @@ void InitGUIslice_gen()
|
|||
|
||||
// Create radio button E_ELEM_RD96
|
||||
pElemRef = gslc_ElemXCheckboxCreate(&m_gui,E_ELEM_RD96,E_CONF_RPI,&m_asXRadio3,
|
||||
(gslc_tsRect){160,160,20,20},true,GSLCX_CHECKBOX_STYLE_ROUND,GSLC_COL_YELLOW,false);
|
||||
(gslc_tsRect){160,160,20,20},true,GSLCX_CHECKBOX_STYLE_ROUND,GSLC_COL_BLUE_LT2,false);
|
||||
gslc_ElemSetGroup(&m_gui,pElemRef,E_GRP_SPD);
|
||||
m_pElemRd96 = pElemRef;
|
||||
|
||||
// Create radio button E_ELEM_RD_1152
|
||||
pElemRef = gslc_ElemXCheckboxCreate(&m_gui,E_ELEM_RD_1152,E_CONF_RPI,&m_asXRadio4,
|
||||
(gslc_tsRect){10,160,20,20},true,GSLCX_CHECKBOX_STYLE_ROUND,GSLC_COL_YELLOW,true);
|
||||
(gslc_tsRect){10,160,20,20},true,GSLCX_CHECKBOX_STYLE_ROUND,GSLC_COL_BLUE_LT2,true);
|
||||
gslc_ElemSetGroup(&m_gui,pElemRef,E_GRP_SPD);
|
||||
m_pElemRd1152 = pElemRef;
|
||||
|
||||
|
@ -274,16 +293,48 @@ void InitGUIslice_gen()
|
|||
// Create textbox
|
||||
pElemRef = gslc_ElemXTextboxCreate(&m_gui,E_ELEM_TX_SD_INFO,E_SD_CARD,&m_sTextbox2,
|
||||
(gslc_tsRect){3,30,313,150},E_AO_NOTOMONO8PT7B,
|
||||
(char*)&m_acTextboxBuf2,6,28);
|
||||
(char*)&m_acTextboxBuf2,8,28);
|
||||
gslc_ElemXTextboxWrapSet(&m_gui,pElemRef,false);
|
||||
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_GREEN);
|
||||
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_GRAY_LT3);
|
||||
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_BLACK,GSLC_COL_BLACK);
|
||||
m_pElemSDInfo = pElemRef;
|
||||
|
||||
// create E_ELEM_BTN_SD_FMT button with text label
|
||||
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,E_ELEM_BTN_SD_FMT,E_SD_CARD,
|
||||
(gslc_tsRect){110,190,100,40},(char*)"FORMAT?",0,E_AO_NOTOMONO8PT7B,&CbBtnCommon);
|
||||
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_RED_DK1,GSLC_COL_RED_DK4,GSLC_COL_RED_DK1);
|
||||
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_RED_DK1,GSLC_COL_GRAY,GSLC_COL_RED_DK1);
|
||||
|
||||
// -----------------------------------
|
||||
// PAGE: E_PG_SD_CONFIRM
|
||||
|
||||
|
||||
// Create E_ELEM_BOX1 box
|
||||
pElemRef = gslc_ElemCreateBox(&m_gui,E_ELEM_BOX1,E_PG_SD_CONFIRM,(gslc_tsRect){0,0,320,240});
|
||||
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_BLACK,GSLC_COL_BLACK,GSLC_COL_BLACK);
|
||||
|
||||
// Create E_ELEM_TEXT14 text label
|
||||
pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_TEXT14,E_PG_SD_CONFIRM,(gslc_tsRect){0,30,320,42},
|
||||
(char*)"Format SD Card?",0,E_AO_NOTOMONO16PT7B);
|
||||
gslc_ElemSetTxtAlign(&m_gui,pElemRef,GSLC_ALIGN_MID_MID);
|
||||
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_RED_LT1);
|
||||
|
||||
// Create E_ELEM_TEXT15 text label
|
||||
pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_TEXT15,E_PG_SD_CONFIRM,(gslc_tsRect){0,90,320,32},
|
||||
(char*)"This will ERASE it!",0,E_AO_NOTOMONO12PT7B);
|
||||
gslc_ElemSetTxtAlign(&m_gui,pElemRef,GSLC_ALIGN_MID_MID);
|
||||
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_RED_LT4);
|
||||
|
||||
// create E_ELEM_SD_NO button with text label
|
||||
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,E_ELEM_SD_NO,E_PG_SD_CONFIRM,
|
||||
(gslc_tsRect){50,160,80,40},(char*)"No",0,E_AO_NOTOMONO10PT7B,&CbBtnCommon);
|
||||
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_BLUE_LT2,GSLC_COL_GRAY,GSLC_COL_BLUE_LT2);
|
||||
m_pElemBtSDNo = pElemRef;
|
||||
|
||||
// create E_ELEM_SD_YES button with text label
|
||||
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,E_ELEM_SD_YES,E_PG_SD_CONFIRM,
|
||||
(gslc_tsRect){170,160,80,40},(char*)"Yes",0,E_AO_NOTOMONO10PT7B,&CbBtnCommon);
|
||||
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_RED_LT1,GSLC_COL_GRAY,GSLC_COL_RED_LT1);
|
||||
m_pElemBtSDYes = pElemRef;
|
||||
//<InitGUI !End!>
|
||||
|
||||
//<Startup !Start!>
|
||||
|
|
|
@ -176,6 +176,9 @@
|
|||
// Could NOT get soft spi working
|
||||
#include "../SdFat/SdFat.h"
|
||||
SdFat SD;
|
||||
SdFat gslc_GetSDCard() {
|
||||
return SD;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -3017,7 +3020,6 @@ bool gslc_DrvRotate(gslc_tsGui* pGui, uint8_t nRotation)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// Private Functions
|
||||
// =======================================================================
|
||||
|
|
|
@ -231,11 +231,11 @@ extern "C" {
|
|||
// Debug diagnostic modes
|
||||
// -----------------------------------------------------------------------------
|
||||
// - Uncomment any of the following to enable specific debug modes
|
||||
//#define DBG_LOG // Enable debugging log output
|
||||
//#define DBG_TOUCH // Enable debugging of touch-presses
|
||||
#define DBG_LOG // Enable debugging log output
|
||||
#define DBG_TOUCH // Enable debugging of touch-presses
|
||||
//#define DBG_FRAME_RATE // Enable diagnostic frame rate reporting
|
||||
//#define DBG_DRAW_IMM // Enable immediate rendering of drawing primitives
|
||||
//#define DBG_DRIVER // Enable graphics driver debug reporting
|
||||
#define DBG_DRIVER // Enable graphics driver debug reporting
|
||||
|
||||
|
||||
// =============================================================================
|
||||
|
|
Reference in a new issue