This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

EK-TM4C1294XL: Isuue in Implementing keyboard widget of graphics library

Part Number: EK-TM4C1294XL
Other Parts Discussed in Thread: TM4C129XNCZAD

Hello All,

I'am using EK-TM4C1294XL launchpad and I'am trying to implement the keyboard widget of the graphics library.

I'am able to get the keyboard on the display but when I press any key on the keyboard, the code hangs and goes into Fault ISR.

Kindly help in resolving the issue. I've attached my code.

//
// Keyboard cursor blink rate.
//
#define KEYBOARD_BLINK_RATE     100

//
// The current string pointer for the keyboard.
//
static char *g_pcKeyStr;

//
// The current string index for the keyboard.
//
static uint32_t g_ui32StringIdx;

//
// A place holder string used when nothing is being displayed on the keyboard.
//
static const char g_cTempStr = 0;

//
// The current string width for the keyboard in pixels.
//
static int32_t g_i32StringWidth;

//
// The cursor blink counter.
//
static volatile uint32_t g_ui32CursorDelay;

/******************keyboard***************/

 	 		Keyboard(Keyboard, &KeyboardBackground, 0, 0,
 	 		         &g_sGrRaster16BppDriver, 8, 190, 792, 300,
 	 		         KEYBOARD_STYLE_FILL | KEYBOARD_STYLE_AUTO_REPEAT |
 	 		         KEYBOARD_STYLE_PRESS_NOTIFY | KEYBOARD_STYLE_RELEASE_NOTIFY |
 	 		         KEYBOARD_STYLE_BG,
 	 		         ClrBlack, ClrGray, ClrDarkGray, ClrGray, ClrBlack, g_psFontCmss20b,
 	 		         100, 100, NUM_KEYBOARD_US_ENGLISH, g_psKeyboardUSEnglish, KeyEvent);

 	 		Canvas(KeyboardText, &KeyboardBackground, &Keyboard, 0,
 	 		       &g_sGrRaster16BppDriver, X_OFFSET, Y_OFFSET,
 	 		       800, 180,
				   CANVAS_STYLE_APP_DRAWN|CANVAS_STYLE_FILL | CANVAS_STYLE_TEXT | CANVAS_STYLE_TEXT_LEFT,
				          ClrBlack, ClrWhite, ClrWhite, g_psFontCmss24, &g_cTempStr, 0 ,textarea);

 	 		Canvas(KeyboardBackground, WIDGET_ROOT, 0, &KeyboardText,
 	 		       &g_sGrRaster16BppDriver, X_OFFSET, Y_OFFSET,
 	 		       800, 480,
				   CANVAS_STYLE_FILL, ClrBlack, ClrWhite, ClrWhite, 0, 0, 0 ,0 );

/********************************/

void textarea(tWidget *psWidget, tContext *psContext)
 	 		{

 	 			HandleKeyboard();
 	 			GrContextFontSet(psContext, g_psFontCmss28b);
 	 			 	 				GrContextForegroundSet(psContext, ClrRed);
 	 			 	 				GrStringDraw(psContext, "Patient ID: ", -1,
 	 			 	 				                 5, 5, 0);

 	 			 	 				GrStringDraw(psContext, "Patient Name:", -1,
 	 			 	 				                 5,40, 0);

 	 			 	 						GrStringDraw(psContext, "Gender:", -1,
 	 			 	 						                 5,75, 0);
 	 			 	 					GrStringDraw(psContext, "Age:", -1,
 	 			 	 					 	 			 	 5,110, 0);

 	 			 	 				GrStringDraw(psContext, "Height:", -1,
 	 			 	 				 	 			 	 		 555,5, 0);
 	 			 	 			GrStringDraw(psContext, "Weight:", -1,
 	 			 	 			 	 			 	 			555,40, 0);
 	 			 	 		GrStringDraw(psContext, "Date:", -1,
 	 			 	 		 	 			 	 				555,75, 0);

 	 		}


void
 	 		HandleKeyboard(void)
 	 		{

 	 		    //
 	 		    // If the mid value is hit then clear the cursor.
 	 		    //
 	 		    if(g_ui32CursorDelay == KEYBOARD_BLINK_RATE / 2)
 	 		    {
 	 		        GrContextForegroundSet(&guiMainContext, ClrBlack);

 	 		        //
 	 		        // Keep the counter moving now that the clearing has been handled.
 	 		        //
 	 		        g_ui32CursorDelay--;
 	 		    }
 	 		    else if(g_ui32CursorDelay == 0)
 	 		    {
 	 		        GrContextForegroundSet(&guiMainContext, ClrWhite);

 	 		        //
 	 		        // Reset the blink delay now that the drawing of the cursor has been
 	 		        // handled.
 	 		        //
 	 		        g_ui32CursorDelay = KEYBOARD_BLINK_RATE;
 	 		    }
 	 		    else
 	 		    {
 	 		        return;
 	 		    }

 	 		    //
 	 		    // Draw the cursor only if it is time.
 	 		    //
 	 		    GrLineDrawV(&guiMainContext, 200 + g_i32StringWidth ,  20,
 	 		                 40);
 	 		
 	 		}

void
 	 		KeyEvent(tWidget *psWidget, uint32_t ui32Key, uint32_t ui32Event)
 	 		{
 	 		    switch(ui32Key)
 	 		    {
 	 		        //
 	 		        // Look for a backspace key press.
 	 		        //
 	 		        case UNICODE_BACKSPACE:
 	 		        {
 	 		            if(ui32Event == KEYBOARD_EVENT_PRESS)
 	 		            {
 	 		                if(g_ui32StringIdx != 0)
 	 		                {
 	 		                    g_ui32StringIdx--;
 	 		                    g_pcKeyStr[g_ui32StringIdx] = 0;
 	 		                }

 	 		                WidgetPaint((tWidget *)&KeyboardText);

 	 		                //
 	 		                // Save the pixel width of the current string.
 	 		                //
 	 		                g_i32StringWidth = GrStringWidthGet(&guiMainContext, g_pcKeyStr,
 	 		                                                    100);
 	 		            }
 	 		            break;
 	 		        }
 	 		        //
 	 		        // Look for an enter/return key press.  This will exit the keyboard and
 	 		        // return to the current active screen.
 	 		        //
 	 		       /* case UNICODE_RETURN:
 	 		        {
 	 		            if(ui32Event == KEYBOARD_EVENT_RELEASE)
 	 		          {
// // If the key is not special then update the text string. // default: { if(ui32Event == KEYBOARD_EVENT_PRESS) { // // Set the string to the current string to be updated. // if(g_ui32StringIdx == 0) { CanvasTextSet(&KeyboardText, &g_pcKeyStr); } g_pcKeyStr[g_ui32StringIdx] = (char)ui32Key; g_ui32StringIdx++; g_pcKeyStr[g_ui32StringIdx] = 0; WidgetPaint((tWidget *)&KeyboardText); // // Save the pixel width of the current string. // g_i32StringWidth = GrStringWidthGet(&guiMainContext, g_pcKeyStr, 100); } break; } WidgetMessageQueueProcess(); } }

  • Hello Sumit

    Can you please describe which TivaWare version and which panel are you using?
  • Hello Amit,

    I'am using SW-TM4C-RLN-2.1.3.156 & Iam using a panel controlled by TM4C129XNCZAD MCU similar to kentec display , only difference is it is 7inch with 800x480 resolution
  • Hello Sumit

    OK, since the display is not the same, did you make any change for Stack Size?

    Also please use a breakpoint to check how the program execution happens during the callback function that you have initialized in the Structure.
  • Hello Amit,

    I've kept the stack size as 65536.

    where exactly should I put the breakpoint?
  • Hello Sumit

    The breakpoint should be in the callback function to see if it is being called on the touch press.

  • Hello Amit,

    So, you mean I should keep the breakpoint in the keyevent function OR inside the main function where WidgetMessageQueueProcess() is called in while(1) loop .

    void

               KeyEvent(tWidget *psWidget, uint32_t ui32Key, uint32_t ui32Event)

               {

                   switch(ui32Key)

                   {

                       //

                       // Look for a backspace key press.

                       //

                       case UNICODE_BACKSPACE: 

                       {

                           if(ui32Event == KEYBOARD_EVENT_PRESS)

                           {

                               if(g_ui32StringIdx != 0)

                               {

                                   g_ui32StringIdx--;

                                   g_pcKeyStr[g_ui32StringIdx] = 0;

                               }

                               WidgetPaint((tWidget *)&KeyboardText);

                               //

                               // Save the pixel width of the current string.

                               //

                               g_i32StringWidth = GrStringWidthGet(&guiMainContext, g_pcKeyStr,

                                                                   100);

                           }

                           break;

                       }

                       //

                       // Look for an enter/return key press.  This will exit the keyboard and

                       // return to the current active screen.

                       //

                      /* case UNICODE_RETURN:

                       {

                           if(ui32Event == KEYBOARD_EVENT_RELEASE)

                         {

                       //

                       // If the key is not special then update the text string.

                       //

                       default:

                       {

                           if(ui32Event == KEYBOARD_EVENT_PRESS)

                           {

                               //

                               // Set the string to the current string to be updated.

                               //

                               if(g_ui32StringIdx == 0)

                               {

                                   CanvasTextSet(&KeyboardText, &g_pcKeyStr);

                               }

                               g_pcKeyStr[g_ui32StringIdx] = (char)ui32Key;

                               g_ui32StringIdx++;

                               g_pcKeyStr[g_ui32StringIdx] = 0;

                               WidgetPaint((tWidget *)&KeyboardText);

                               //

                               // Save the pixel width of the current string.

                               //

                               g_i32StringWidth = GrStringWidthGet(&guiMainContext, g_pcKeyStr,

                                                                   100);

                           }

                           break;

                       }

                     WidgetMessageQueueProcess();---------------------> breakpoint

                   }

               }

    OR inside int main while(1) loop

    {

     WidgetMessageQueueProcess();---------------------> breakpoint

    }

  • Hello Sumit

    If Keyevent function is the callback function on the key press, then breakpoint is on KeyEvent function.
  • Hello Amit,

    Thx for the support, I was able to resolve the issue.

    There were many errors in my programming which I cannot describe here, but I followed the qs weather application in which they have used keyboard and I was finally able to use the keyboard widget!!! :)

    Note:- For anyone else who faces a problem in implementing keyboard widget, just go through the code for qs weather application . It is available in boards examples in Tivaware_C_Series - 2.1.0.12573 version
  • Hello Sumit

    TivaWare 2.1.3.156 as well (and the newer releases coming soon)