LCD Screen Glitching, Resetting

Hey! This is my first post here, so I'll try to format this right. I'm trying to have a GUI on an LCD screen (Arduino MEGA) with 2 pages. One page shows a list, the other has a few boxes for text input that is appended to the end of the list on the main page. The GUI itself is all set up perfectly fine - I used the GUISlice library which I found really nice. It's adding the text from here to there that's the problem. Here's a code snippet which I feel is the problem:

          char* hr = gslc_ElemGetTxtStr(pGui, m_pElemVal4);
          char* mn = gslc_ElemGetTxtStr(pGui, m_pElemVal3);
          char* tsk = gslc_ElemGetTxtStr(pGui, m_pElemInTxt2);
          char* taskfull = hr;
          strcat(taskfull, ":");
          strcat(taskfull, mn);
          strcat(taskfull, " ");
          strcat(taskfull, tsk);
         gslc_ElemXListboxAddItem(pGui, m_pElemListbox1, taskfull);

All the "gslc" stuff is from the library, so I'm not too worried about that. I initially had struggle adding these 3 snippets together, since all of them are from different textboxes. hr and min went together fine, but tsk didn't seem like it wanted to go with them, so after some searching I found that strcat was a way to get it all together.

And it did, so I can go to the second page, add in the info, and see it on the main page. But trying this a second time has one of the pages' elements glitch, the button to send me back to the main screen stops working, the screen goes white, and it resets. Am I right that this segment is causing trouble? If so, I'd like to know what I can do to get it done, and if not, I wonder what else could be causing the situation.

Well, that's your guess, but since only you know the remainder of the code, no-one else can even remotely possibly advise. :grimacing:

Note the instructions.

Thanks for telling me that! The code I have isn't that short, so sorry in advance..

//<App !Start!>
// FILE: [helperbox.ino]
// Created by GUIslice Builder version: [0.17.0]
//
// GUIslice Builder Generated File
//
// For the latest guides, updates and support view:
// https://github.com/ImpulseAdventure/GUIslice
//
//<App !End!>

// ------------------------------------------------
// Headers to include
// ------------------------------------------------
#include "helperbox_GSLC.h"



// ------------------------------------------------
// Program Globals
// ------------------------------------------------

// Save some element references for direct access
//<Save_References !Start!>
gslc_tsElemRef* m_pElemInTxt2     = NULL;
gslc_tsElemRef* m_pElemListbox1   = NULL;
gslc_tsElemRef* m_pElemVal3       = NULL;
gslc_tsElemRef* m_pElemVal4       = NULL;
gslc_tsElemRef* m_pListSlider1    = NULL;
gslc_tsElemRef* m_pElemKeyPadNum  = NULL;
gslc_tsElemRef* m_pElemKeyPadAlpha= NULL;
//<Save_References !End!>

// 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) {
//<Button Enums !Start!>
      case E_ELEM_EDITBTN:
         gslc_SetPageCur(pGui, E_PG2);
        break;
      case E_ELEM_TASKINPUT:
        // Clicked on edit field, so show popup box and associate with this text field
        gslc_ElemXKeyPadInputAsk(&m_gui, m_pElemKeyPadAlpha, E_POP_KEYPAD_ALPHA, m_pElemInTxt2);
        break;
      case E_ELEM_BTN2:
          char* hr = gslc_ElemGetTxtStr(pGui, m_pElemVal4);
          char* mn = gslc_ElemGetTxtStr(pGui, m_pElemVal3);
          char* tsk = gslc_ElemGetTxtStr(pGui, m_pElemInTxt2);
          char* taskfull = hr;
          strcat(taskfull, ":");
          strcat(taskfull, mn);
          strcat(taskfull, " ");
          strcat(taskfull, tsk);
         gslc_ElemXListboxAddItem(pGui, m_pElemListbox1, taskfull);
        
        gslc_SetPageCur(pGui, E_PG_MAIN);
        break;
      case E_ELEM_MIN:
        // Clicked on edit field, so show popup box and associate with this text field
        gslc_ElemXKeyPadInputAsk(&m_gui, m_pElemKeyPadNum, E_POP_KEYPAD_NUM, m_pElemVal3);
        break;
      case E_ELEM_HR:
        // Clicked on edit field, so show popup box and associate with this text field
        gslc_ElemXKeyPadInputAsk(&m_gui, m_pElemKeyPadNum, E_POP_KEYPAD_NUM, m_pElemVal4);
        break;
//<Button Enums !End!>
      default:
        break;
    }
  }
  return true;
}
//<Checkbox Callback !Start!>
//<Checkbox Callback !End!>
// KeyPad Input Ready callback
bool CbKeypad(void* pvGui, void *pvElemRef, int16_t nState, void* pvData)
{
  gslc_tsGui*     pGui     = (gslc_tsGui*)pvGui;
  gslc_tsElemRef* pElemRef = (gslc_tsElemRef*)(pvElemRef);
  gslc_tsElem*    pElem    = gslc_GetElemFromRef(pGui,pElemRef);

  // From the pvData we can get the ID element that is ready.
  int16_t nTargetElemId = gslc_ElemXKeyPadDataTargetIdGet(pGui, pvData);
  if (nState == XKEYPAD_CB_STATE_DONE) {
    // User clicked on Enter to leave popup
    // - If we have a popup active, pass the return value directly to
    //   the corresponding value field
    switch (nTargetElemId) {
//<Keypad Enums !Start!>
      case E_ELEM_TASKINPUT:
        gslc_ElemXKeyPadInputGet(pGui, m_pElemInTxt2, pvData);
	    gslc_PopupHide(&m_gui);
        break;

      case E_ELEM_MIN:
        gslc_ElemXKeyPadInputGet(pGui, m_pElemVal3, pvData);
	    gslc_PopupHide(&m_gui);
        break;
      case E_ELEM_HR:
        gslc_ElemXKeyPadInputGet(pGui, m_pElemVal4, pvData);
	    gslc_PopupHide(&m_gui);
        break;
//<Keypad Enums !End!>
      default:
        break;
    }
  } else if (nState == XKEYPAD_CB_STATE_CANCEL) {
    // User escaped from popup, so don't update values
    gslc_PopupHide(&m_gui);
  }
  return true;
}
//<Spinner Callback !Start!>
//<Spinner 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_LIST:
      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!>

// Callback function for when a slider's position has been updated
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;
  gslc_tsElemRef* pElemRefTmp = NULL;

  // From the element's ID we can determine which slider was updated.
  switch (pElem->nId) {
//<Slider Enums !Start!>
    case E_LISTSCROLL1:
      // Fetch the slider position
      nVal = gslc_ElemXSliderGetPos(pGui,m_pListSlider1);
      pElemRefTmp = gslc_PageFindElemById(pGui, E_PG_MAIN, E_LIST);
      gslc_ElemXListboxSetScrollPos(pGui, pElemRefTmp, nVal); 
      break;

      break;
//<Slider Enums !End!>
    default:
      break;
  }

  return true;
}
//<Tick Callback !Start!>
//<Tick Callback !End!>

void setup()
{
  // ------------------------------------------------
  // Initialize
  // ------------------------------------------------
  Serial.begin(9600);
  // Wait for USB Serial 
  delay(1000);  // NOTE: Some devices require a delay after Serial.begin() before serial port can be used

  gslc_InitDebug(&DebugOut);

  // ------------------------------------------------
  // Create graphic elements
  // ------------------------------------------------
  InitGUIslice_gen();

}

// -----------------------------------
// Main event loop
// -----------------------------------
void loop()
{

  // ------------------------------------------------
  // Update GUI Elements
  // ------------------------------------------------
  
  // ------------------------------------------------
  // Periodically call GUIslice update function
  // ------------------------------------------------
  gslc_Update(&m_gui);
    
}

The actual GUI's code is in a seperate file attached to this code. If the main code here isn't enough, I can give that too.

You're kidding! We've seen much worse here.

Sorry, but I can't help you - those display combinations are not my field. Just helping you provide sufficient information for someone who can help. :grin: