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(); } }