Start implementation of SD Card info screen

This commit is contained in:
KemoNine 2020-09-12 20:05:58 -04:00
parent 2db44b6849
commit 89e83c277e
3 changed files with 100 additions and 33 deletions

View file

@ -41,7 +41,6 @@ int batteryPercent;
#define TFT_CS 9
#define TFT_DC 10
Adafruit_ILI9341 tft(TFT_CS, TFT_DC);
#include <Fonts/FreeMono9pt7b.h>
#define CHARS_HORIZONTAL 29
#define CHARS_ROWS 11
#define CHARS_TOTAL CHARS_HORIZONTAL * CHARS_ROWS
@ -89,6 +88,7 @@ gslc_tsElemRef* m_pElemRd1152 = NULL;
gslc_tsElemRef* m_pElemRd96 = NULL;
gslc_tsElemRef* m_pElemRdUART0 = NULL;
gslc_tsElemRef* m_pElemRdUART5 = NULL;
gslc_tsElemRef* m_pElemSDInfo = NULL;
gslc_tsElemRef* m_pElemStatusText = NULL;
gslc_tsElemRef* m_pElemText = NULL;
//<Save_References !End!>
@ -103,8 +103,27 @@ static int16_t DebugOut(char ch) { if (ch == (char)'\n') Serial.println(""); els
// ------------------------------------------------
// Callback Methods
// ------------------------------------------------
//<Button Callback !Start!>
//<Button Callback !End!>
// 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) {
//<Button Enums !Start!>
case E_ELEM_BTN_SD_FMT:
break;
//<Button Enums !End!>
default:
break;
}
}
return true;
}
//<Checkbox Callback !Start!>
//<Checkbox Callback !End!>
//<Keypad Callback !Start!>
@ -243,13 +262,23 @@ void handlerKeyboard() {
// Process key press events
if (key.state == BBQ10Keyboard::StatePress) {
// Flip to config UI if the right most button is pressed when on home screen
if (gslc_GetPageCur(&m_gui) == E_PG_MAIN && key.key == KBD_BTN_4) {
gslc_SetPageCur(&m_gui,E_CONF_RPI);
}
// Flip to main screen if the right most button is pressed when in config UI
else if (gslc_GetPageCur(&m_gui) == E_CONF_RPI && key.key == KBD_BTN_4) {
gslc_SetPageCur(&m_gui,E_PG_MAIN);
// Move right through screens
if (key.key == KBD_BTN_4) {
// Main Screen Flip
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) {
gslc_ElemSetTxtStr(&m_gui, m_pElemStatusText, "SD Card");
gslc_SetPageCur(&m_gui, E_SD_CARD);
}
// SD Card Info screen Flip
else if (gslc_GetPageCur(&m_gui) == E_SD_CARD) {
gslc_ElemSetTxtStr(&m_gui, m_pElemStatusText, "Serial Console");
gslc_SetPageCur(&m_gui, E_PG_MAIN);
}
}
// Add keys to the key buffer that are mapped to UI functions (only for config screens)
else if (key.key == KBD_SW_UP
@ -323,7 +352,6 @@ void handlerBatteryLevel() {
gslc_ElemXProgressSetVal(&m_gui, m_pElemBatteryLevel, batteryPercent);
gslc_tsXProgress* pGauge = (gslc_tsXProgress*)gslc_GetXDataFromRef(&m_gui,m_pElemBatteryLevel,GSLC_TYPEX_PROGRESS,__LINE__);
pGauge->colGauge = colorForHeaderElements;
gslc_ElemSetTxtCol(&m_gui, m_pElemBatteryLevel, colorForHeaderElements);
gslc_ElemSetTxtCol(&m_gui, m_pElemStatusText, colorForHeaderElements);
// Update GUI and NeoPixel with battery status information

Binary file not shown.

View file

@ -35,7 +35,6 @@
#error Project tab->Target Platform should be tft_espi
#endif
#include <Adafruit_GFX.h>
#include "src/guislice/NotoMono12pt7b.h"
#include "src/guislice/NotoMono8pt7b.h"
//<Fonts !End!>
@ -49,14 +48,14 @@
// Enumerations for pages, elements, fonts, images
// ------------------------------------------------
//<Enum !Start!>
enum {E_PG_MAIN,E_CONF_RPI};
enum {E_ELEM_BATT_LEVEL,E_ELEM_CONFIG_RPI_TITLE,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_UART1,E_ELEM_TX_UART5};
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_GRP_SPD,E_GRP_UART};
// Must use separate enum for fonts with MAX_FONT at end to use gslc_FontSet.
enum {E_AO_NOTOMONO12PT7B,E_AO_NOTOMONO8PT7B,MAX_FONT};
enum {E_AO_NOTOMONO8PT7B,MAX_FONT};
//<Enum !End!>
// ------------------------------------------------
@ -67,13 +66,19 @@ enum {E_AO_NOTOMONO12PT7B,E_AO_NOTOMONO8PT7B,MAX_FONT};
// Define the maximum number of elements and pages
// ------------------------------------------------
//<ElementDefines !Start!>
#define MAX_PAGE 2
#define MAX_PAGE 4
#define MAX_ELEM_PG_MAIN 3 // # Elems total on page
#define MAX_ELEM_PG_BASE 3 // # Elems total on page
#define MAX_ELEM_PG_BASE_RAM MAX_ELEM_PG_BASE // # Elems in RAM
#define MAX_ELEM_PG_MAIN 1 // # Elems total on page
#define MAX_ELEM_PG_MAIN_RAM MAX_ELEM_PG_MAIN // # Elems in RAM
#define MAX_ELEM_CONF_RPI 11 // # Elems total on page
#define MAX_ELEM_CONF_RPI 10 // # Elems total on page
#define MAX_ELEM_CONF_RPI_RAM MAX_ELEM_CONF_RPI // # Elems in RAM
#define MAX_ELEM_SD_CARD 2 // # Elems total on page
#define MAX_ELEM_SD_CARD_RAM MAX_ELEM_SD_CARD // # Elems in RAM
//<ElementDefines !End!>
// ------------------------------------------------
@ -85,17 +90,23 @@ gslc_tsFont m_asFont[MAX_FONT];
gslc_tsPage m_asPage[MAX_PAGE];
//<GUI_Extra_Elements !Start!>
gslc_tsElem m_asBasePage1Elem[MAX_ELEM_PG_BASE_RAM];
gslc_tsElemRef m_asBasePage1ElemRef[MAX_ELEM_PG_BASE];
gslc_tsElem m_asPage1Elem[MAX_ELEM_PG_MAIN_RAM];
gslc_tsElemRef m_asPage1ElemRef[MAX_ELEM_PG_MAIN];
gslc_tsElem m_asPage2Elem[MAX_ELEM_CONF_RPI_RAM];
gslc_tsElemRef m_asPage2ElemRef[MAX_ELEM_CONF_RPI];
gslc_tsXProgress m_sXBarGauge1;
gslc_tsElem m_asPage3Elem[MAX_ELEM_SD_CARD_RAM];
gslc_tsElemRef m_asPage3ElemRef[MAX_ELEM_SD_CARD];
gslc_tsXProgress m_sXBarGauge2;
gslc_tsXTextbox m_sTextbox1;
char m_acTextboxBuf1[952]; // NRows=17 NCols=56
gslc_tsXCheckbox m_asXRadio1;
gslc_tsXCheckbox m_asXRadio2;
gslc_tsXCheckbox m_asXRadio3;
gslc_tsXCheckbox m_asXRadio4;
gslc_tsXTextbox m_sTextbox2;
char m_acTextboxBuf2[168]; // NRows=6 NCols=28
#define MAX_STR 100
@ -112,9 +123,11 @@ extern gslc_tsElemRef* m_pElemRd1152;
extern gslc_tsElemRef* m_pElemRd96;
extern gslc_tsElemRef* m_pElemRdUART0;
extern gslc_tsElemRef* m_pElemRdUART5;
extern gslc_tsElemRef* m_pElemSDInfo;
extern gslc_tsElemRef* m_pElemStatusText;
extern gslc_tsElemRef* m_pElemText;
extern gslc_tsElemRef* m_pTextSlider;
extern gslc_tsElemRef* m_pTextSliderSDInfo;
//<Extern_References !End!>
// Define debug message function
@ -145,13 +158,19 @@ void InitGUIslice_gen()
// Load Fonts
// ------------------------------------------------
//<Load_Fonts !Start!>
if (!gslc_FontSet(&m_gui,E_AO_NOTOMONO12PT7B,GSLC_FONTREF_PTR,&NotoMono12pt7b,1)) { return; }
if (!gslc_FontSet(&m_gui,E_AO_NOTOMONO8PT7B,GSLC_FONTREF_PTR,&NotoMono8pt7b,1)) { return; }
//<Load_Fonts !End!>
//<InitGUI !Start!>
gslc_PageAdd(&m_gui,E_PG_BASE,m_asBasePage1Elem,MAX_ELEM_PG_BASE_RAM,m_asBasePage1ElemRef,MAX_ELEM_PG_BASE);
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);
// 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.
gslc_SetPageBase(&m_gui, E_PG_BASE);
// NOTE: The current page defaults to the first page added. Here we explicitly
// ensure that the main page is the correct page no matter the add order.
@ -161,19 +180,27 @@ void InitGUIslice_gen()
gslc_SetBkgndColor(&m_gui,GSLC_COL_BLACK);
// -----------------------------------
// PAGE: E_PG_MAIN
// PAGE: E_PG_BASE
// Create progress bar E_ELEM_BATT_LEVEL
pElemRef = gslc_ElemXProgressCreate(&m_gui,E_ELEM_BATT_LEVEL,E_PG_MAIN,&m_sXBarGauge1,
pElemRef = gslc_ElemXProgressCreate(&m_gui,E_ELEM_BATT_LEVEL,E_PG_BASE,&m_sXBarGauge2,
(gslc_tsRect){263,5,50,15},0,100,0,GSLC_COL_GREEN,false);
m_pElemBatteryLevel = pElemRef;
// Create E_ELEM_STATUS text label
pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_STATUS,E_PG_MAIN,(gslc_tsRect){2,2,250,21},
(char*)"UART0 / 1151200",0,E_AO_NOTOMONO8PT7B);
pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_STATUS,E_PG_BASE,(gslc_tsRect){2,2,250,21},
(char*)"Serial Console",0,E_AO_NOTOMONO8PT7B);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_GREEN);
m_pElemStatusText = pElemRef;
// Create E_STATUS_LINE line
pElemRef = gslc_ElemCreateLine(&m_gui,E_STATUS_LINE,E_PG_BASE,0,25,320,25);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_BLACK,GSLC_COL_GRAY_DK1,GSLC_COL_GRAY_DK1);
// -----------------------------------
// PAGE: E_PG_MAIN
// Create textbox
pElemRef = gslc_ElemXTextboxCreate(&m_gui,E_ELEM_TEXT,E_PG_MAIN,&m_sTextbox1,
@ -188,12 +215,6 @@ void InitGUIslice_gen()
// PAGE: E_CONF_RPI
// Create E_ELEM_CONFIG_RPI_TITLE text label
pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_CONFIG_RPI_TITLE,E_CONF_RPI,(gslc_tsRect){2,2,316,32},
(char*)"Raspberry Pi Config",0,E_AO_NOTOMONO12PT7B);
gslc_ElemSetTxtAlign(&m_gui,pElemRef,GSLC_ALIGN_MID_MID);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_GREEN);
// 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);
@ -245,6 +266,24 @@ void InitGUIslice_gen()
pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_TX96,E_CONF_RPI,(gslc_tsRect){190,160,40,21},
(char*)"9600",0,E_AO_NOTOMONO8PT7B);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_GRAY_LT3);
// -----------------------------------
// PAGE: E_SD_CARD
// 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);
gslc_ElemXTextboxWrapSet(&m_gui,pElemRef,false);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_GREEN);
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);
//<InitGUI !End!>
//<Startup !Start!>