Initial setup of diagram list
This commit is contained in:
parent
21adc36934
commit
caaf8cba13
|
@ -83,16 +83,23 @@ Adafruit_NeoPixel pixels_wing(PIXELS_NUM_WING, PIXELS_WING_PIN, NEO_GRB + NEO_KH
|
|||
// 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
|
||||
//<Save_References !Start!>
|
||||
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;
|
||||
|
@ -137,11 +144,57 @@ bool CbBtnCommon(void* pvGui,void *pvElemRef,gslc_teTouch eTouch,int16_t nX,int1
|
|||
//<Keypad Callback !End!>
|
||||
//<Spinner Callback !Start!>
|
||||
//<Spinner Callback !End!>
|
||||
//<Listbox Callback !Start!>
|
||||
//<Listbox Callback !End!>
|
||||
bool CbListbox(void* pvGui, void* pvElemRef, int16_t nSelId)
|
||||
{
|
||||
gslc_tsGui* pGui = (gslc_tsGui*)(pvGui);
|
||||
gslc_tsElemRef* pElemRef = (gslc_tsElemRef*)(pvElemRef);
|
||||
gslc_tsElem* pElem = gslc_GetElemFromRef(pGui, pElemRef);
|
||||
char acTxt[MAX_STR + 1];
|
||||
|
||||
if (pElemRef == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// From the element's ID we can determine which listbox was active.
|
||||
switch (pElem->nId) {
|
||||
//<Listbox Enums !Start!>
|
||||
case E_ELEM_LS_DIA:
|
||||
if (nSelId != XLISTBOX_SEL_NONE) {
|
||||
gslc_ElemXListboxGetItem(&m_gui, pElemRef, nSelId, acTxt, MAX_STR);
|
||||
}
|
||||
break;
|
||||
|
||||
//<Listbox Enums !End!>
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//<Draw Callback !Start!>
|
||||
//<Draw Callback !End!>
|
||||
//<Slider Enums !Start!>
|
||||
bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos)
|
||||
{
|
||||
gslc_tsGui* pGui = (gslc_tsGui*)(pvGui);
|
||||
gslc_tsElemRef* pElemRef = (gslc_tsElemRef*)(pvElemRef);
|
||||
gslc_tsElem* pElem = gslc_GetElemFromRef(pGui,pElemRef);
|
||||
int16_t nVal;
|
||||
|
||||
// From the element's ID we can determine which slider was updated.
|
||||
switch (pElem->nId) {
|
||||
//<Slider Enums !Start!>
|
||||
case E_SLR_DIAGRAMS:
|
||||
// Fetch the slider position
|
||||
nVal = gslc_ElemXSliderGetPos(pGui,m_SliderDiagrams);
|
||||
break;
|
||||
|
||||
//<Slider Enums !End!>
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//<Slider Enums !End!>
|
||||
//<Tick Callback !Start!>
|
||||
//<Tick Callback !End!>
|
||||
|
@ -219,6 +272,36 @@ void setup() {
|
|||
gslc_InputMapAdd(&m_gui, GSLC_INPUT_PIN_ASSERT, KBD_SW_RT, GSLC_ACTION_FOCUS_PREV, 0);
|
||||
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);
|
||||
|
||||
// Set diagrams slider max equal to the number of elements
|
||||
listDiagramsSize = gslc_ElemXListboxGetItemCnt(&m_gui, m_pElemLsDiagrams);
|
||||
gslc_tsXSlider* pSlider = (gslc_tsXSlider*)gslc_GetXDataFromRef(&m_gui,m_SliderDiagrams,GSLC_TYPEX_SLIDER,__LINE__);
|
||||
pSlider->nPosMax = listDiagramsSize;
|
||||
|
||||
// Figure out how many rows are shown for diagrams list and cache (needed for scrolling)
|
||||
gslc_tsXListbox* pListBox = (gslc_tsXListbox*)gslc_GetXDataFromRef(&m_gui,m_pElemLsDiagrams,GSLC_TYPEX_LISTBOX,__LINE__);
|
||||
listDiagramsRowsShown = pListBox->nRows;
|
||||
|
||||
// Set neopixels to standard start state
|
||||
pixels_wing.clear();
|
||||
pixels_wing.show();
|
||||
|
@ -286,6 +369,12 @@ void handlerKeyboard() {
|
|||
}
|
||||
// Raspberry Pi Screen Flip
|
||||
else if (gslc_GetPageCur(&m_gui) == E_CONF_RPI) {
|
||||
sdCardInfo();
|
||||
gslc_ElemSetTxtStr(&m_gui, m_pElemStatusText, "Wiring Diagrams");
|
||||
gslc_SetPageCur(&m_gui, E_WIRING);
|
||||
}
|
||||
// Wiring Diagram Screen Flip
|
||||
else if (gslc_GetPageCur(&m_gui) == E_WIRING) {
|
||||
sdCardInfo();
|
||||
gslc_ElemSetTxtStr(&m_gui, m_pElemStatusText, "SD Card");
|
||||
gslc_SetPageCur(&m_gui, E_SD_CARD);
|
||||
|
@ -298,10 +387,24 @@ void handlerKeyboard() {
|
|||
}
|
||||
// Add keys to the key buffer that are mapped to UI functions (only for config screens)
|
||||
else if (key.key == KBD_SW_UP
|
||||
|| key.key == KBD_SW_DN
|
||||
|| key.key == KBD_SW_LF
|
||||
|| key.key == KBD_SW_RT
|
||||
|| key.key == KBD_SW_OK) {
|
||||
|| key.key == KBD_SW_LF) {
|
||||
if (gslc_GetPageCur(&m_gui) == E_WIRING) {
|
||||
listPreviousDiagrams();
|
||||
}
|
||||
else {
|
||||
uiKeyBuffer.push(key.key);
|
||||
}
|
||||
}
|
||||
else if (key.key == KBD_SW_DN
|
||||
|| key.key == KBD_SW_RT) {
|
||||
if (gslc_GetPageCur(&m_gui) == E_WIRING) {
|
||||
listNextDiagrams();
|
||||
}
|
||||
else {
|
||||
uiKeyBuffer.push(key.key);
|
||||
}
|
||||
}
|
||||
else if (key.key == KBD_SW_OK) {
|
||||
uiKeyBuffer.push(key.key);
|
||||
}
|
||||
// Process keys 'normally'
|
||||
|
@ -376,6 +479,31 @@ void handlerBatteryLevel() {
|
|||
pixels_board.show();
|
||||
}
|
||||
|
||||
// ------------------------------------------------
|
||||
// List next/previous handlers (no way to do this with the std kbd stuff)
|
||||
// ------------------------------------------------
|
||||
void diagramsScrollUpdate() {
|
||||
gslc_ElemXListboxSetSel(&m_gui, m_pElemLsDiagrams, listDiagramSelection);
|
||||
gslc_ElemXSliderSetPos(&m_gui, m_SliderDiagrams, listDiagramSelection);
|
||||
gslc_ElemXListboxSetScrollPos(&m_gui, m_pElemLsDiagrams, listDiagramSelection);
|
||||
}
|
||||
void listNextDiagrams() {
|
||||
listDiagramSelection++;
|
||||
if (listDiagramSelection >= listDiagramsSize) {
|
||||
listDiagramSelection = -1;
|
||||
}
|
||||
diagramsScrollUpdate();
|
||||
}
|
||||
|
||||
void listPreviousDiagrams() {
|
||||
listDiagramSelection--;
|
||||
if (listDiagramSelection < -1) {
|
||||
listDiagramSelection = listDiagramsSize-1;
|
||||
}
|
||||
diagramsScrollUpdate();
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------
|
||||
// SD Card Info
|
||||
// ------------------------------------------------
|
||||
|
|
Binary file not shown.
|
@ -22,7 +22,9 @@
|
|||
//<Includes !Start!>
|
||||
// Include extended elements
|
||||
#include "src/guislice/XCheckbox.h"
|
||||
#include "src/guislice/XListbox.h"
|
||||
#include "src/guislice/XProgress.h"
|
||||
#include "src/guislice/XSlider.h"
|
||||
#include "src/guislice/XTextbox.h"
|
||||
//<Includes !End!>
|
||||
|
||||
|
@ -48,11 +50,12 @@
|
|||
// 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_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_WIRING,E_SD_CARD};
|
||||
enum {E_ELEM_BATT_LEVEL,E_ELEM_LS_DIA,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_SLR_DIAGRAMS
|
||||
,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};
|
||||
|
@ -66,7 +69,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
|
||||
|
@ -77,6 +80,9 @@ enum {E_AO_NOTOMONO8PT7B,MAX_FONT};
|
|||
#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_WIRING 3 // # Elems total on page
|
||||
#define MAX_ELEM_WIRING_RAM MAX_ELEM_WIRING // # Elems in RAM
|
||||
|
||||
#define MAX_ELEM_SD_CARD 1 // # Elems total on page
|
||||
#define MAX_ELEM_SD_CARD_RAM MAX_ELEM_SD_CARD // # Elems in RAM
|
||||
//<ElementDefines !End!>
|
||||
|
@ -96,8 +102,10 @@ 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_tsElem m_asPage3Elem[MAX_ELEM_SD_CARD_RAM];
|
||||
gslc_tsElemRef m_asPage3ElemRef[MAX_ELEM_SD_CARD];
|
||||
gslc_tsElem m_asPage3Elem[MAX_ELEM_WIRING_RAM];
|
||||
gslc_tsElemRef m_asPage3ElemRef[MAX_ELEM_WIRING];
|
||||
gslc_tsElem m_asPage4Elem[MAX_ELEM_SD_CARD_RAM];
|
||||
gslc_tsElemRef m_asPage4ElemRef[MAX_ELEM_SD_CARD];
|
||||
gslc_tsXProgress m_sXBarGauge2;
|
||||
gslc_tsXTextbox m_sTextbox1;
|
||||
char m_acTextboxBuf1[952]; // NRows=17 NCols=56
|
||||
|
@ -105,8 +113,12 @@ gslc_tsXCheckbox m_asXRadio1;
|
|||
gslc_tsXCheckbox m_asXRadio2;
|
||||
gslc_tsXCheckbox m_asXRadio3;
|
||||
gslc_tsXCheckbox m_asXRadio4;
|
||||
gslc_tsXTextbox m_sTextbox2;
|
||||
char m_acTextboxBuf2[696]; // NRows=12 NCols=58
|
||||
gslc_tsXListbox m_sListbox1;
|
||||
// - Note that XLISTBOX_BUF_OH_R is extra required per item
|
||||
char m_acListboxBuf1[512 + XLISTBOX_BUF_OH_R];
|
||||
gslc_tsXSlider m_sListScroll1;
|
||||
gslc_tsXTextbox m_sTextbox3;
|
||||
char m_acTextboxBuf3[696]; // NRows=12 NCols=58
|
||||
|
||||
#define MAX_STR 100
|
||||
|
||||
|
@ -118,7 +130,9 @@ char m_acTextboxBuf2[696]; // NRows=12 NCols=58
|
|||
|
||||
// Element References for direct access
|
||||
//<Extern_References !Start!>
|
||||
extern gslc_tsElemRef* m_SliderDiagrams;
|
||||
extern gslc_tsElemRef* m_pElemBatteryLevel;
|
||||
extern gslc_tsElemRef* m_pElemLsDiagrams;
|
||||
extern gslc_tsElemRef* m_pElemRd1152;
|
||||
extern gslc_tsElemRef* m_pElemRd96;
|
||||
extern gslc_tsElemRef* m_pElemRdUART0;
|
||||
|
@ -127,7 +141,7 @@ 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 gslc_tsElemRef* m_pTextSlider3;
|
||||
//<Extern_References !End!>
|
||||
|
||||
// Define debug message function
|
||||
|
@ -165,7 +179,8 @@ void InitGUIslice_gen()
|
|||
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);
|
||||
gslc_PageAdd(&m_gui,E_WIRING,m_asPage3Elem,MAX_ELEM_WIRING_RAM,m_asPage3ElemRef,MAX_ELEM_WIRING);
|
||||
gslc_PageAdd(&m_gui,E_SD_CARD,m_asPage4Elem,MAX_ELEM_SD_CARD_RAM,m_asPage4ElemRef,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.
|
||||
|
@ -269,14 +284,43 @@ void InitGUIslice_gen()
|
|||
(char*)"9600",0,E_AO_NOTOMONO8PT7B);
|
||||
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_GRAY_LT3);
|
||||
|
||||
// -----------------------------------
|
||||
// PAGE: E_WIRING
|
||||
|
||||
|
||||
// Create wrapping box for listbox E_ELEM_LS_DIA and scrollbar
|
||||
pElemRef = gslc_ElemCreateBox(&m_gui,GSLC_ID_AUTO,E_WIRING,(gslc_tsRect){3,30,313,200});
|
||||
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_BLACK,GSLC_COL_BLUE_LT2);
|
||||
|
||||
// Create listbox
|
||||
pElemRef = gslc_ElemXListboxCreate(&m_gui,E_ELEM_LS_DIA,E_WIRING,&m_sListbox1,
|
||||
(gslc_tsRect){3+2,30+4,313-23,200-7},E_AO_NOTOMONO8PT7B,
|
||||
(uint8_t*)&m_acListboxBuf1,sizeof(m_acListboxBuf1),-1);
|
||||
gslc_ElemXListboxSetSize(&m_gui, pElemRef, 12, 1); // 12 rows, 1 columns
|
||||
gslc_ElemXListboxItemsSetSize(&m_gui, pElemRef, XLISTBOX_SIZE_AUTO, XLISTBOX_SIZE_AUTO);
|
||||
gslc_ElemSetTxtMarginXY(&m_gui, pElemRef, 5, 0);
|
||||
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_GRAY_LT3);
|
||||
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_BLACK,GSLC_COL_BLUE_LT2);
|
||||
gslc_ElemXListboxSetSelFunc(&m_gui, pElemRef, &CbListbox);
|
||||
gslc_ElemXListboxItemsSetGap(&m_gui, pElemRef, 2,GSLC_COL_BLACK);
|
||||
gslc_ElemSetFrameEn(&m_gui,pElemRef,true);
|
||||
m_pElemLsDiagrams = pElemRef;
|
||||
|
||||
// Create vertical scrollbar for listbox
|
||||
pElemRef = gslc_ElemXSliderCreate(&m_gui,E_SLR_DIAGRAMS,E_WIRING,&m_sListScroll1,
|
||||
(gslc_tsRect){3+313-21,30+4,20,200-8},0,0,0,5,true);
|
||||
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_BLACK,GSLC_COL_GRAY);
|
||||
gslc_ElemXSliderSetPosFunc(&m_gui,pElemRef,&CbSlidePos);
|
||||
m_SliderDiagrams = pElemRef;
|
||||
|
||||
// -----------------------------------
|
||||
// PAGE: E_SD_CARD
|
||||
|
||||
|
||||
// Create textbox
|
||||
pElemRef = gslc_ElemXTextboxCreate(&m_gui,E_ELEM_TX_SD_INFO,E_SD_CARD,&m_sTextbox2,
|
||||
pElemRef = gslc_ElemXTextboxCreate(&m_gui,E_ELEM_TX_SD_INFO,E_SD_CARD,&m_sTextbox3,
|
||||
(gslc_tsRect){3,30,323,200},E_AO_NOTOMONO8PT7B,
|
||||
(char*)&m_acTextboxBuf2,12,58);
|
||||
(char*)&m_acTextboxBuf3,12,58);
|
||||
gslc_ElemXTextboxWrapSet(&m_gui,pElemRef,true);
|
||||
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_GRAY_LT3);
|
||||
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_BLACK,GSLC_COL_BLACK);
|
||||
|
|
Reference in a new issue