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.

Clearing the display for dk-tm4c123g

I write a string out the display using GrStringDrawCenter and display is not cleared before the new string is written so

you still see part of the old string that was being displayed. i have tried calling GrFlush and then GrStringDrawCenter but that does not clear it either. What is the command to clear the display before you write a new string?

  Void UpdateMyDisplay(

char * newMessage)

   {

   GrFlush(&sContext);

      GrStringDrawCentered(&sContext,newMessage , -1,

                             GrContextDpyWidthGet(&sContext) / 2,

                             ((GrContextDpyHeightGet(&sContext) - 24) / 2) + 24,

                             0);

   }

 

  • You can write a function like this to clear the whole screen or any part of screen.

    void ClearScreen(void)
    {
        tRectangle sRect;

        //
        // Clear the display.
        //
        sRect.i16XMin = 0;
        sRect.i16YMin = 0;
        sRect.i16XMax = Width of screen- 1;
        sRect.i16YMax = Height of screen- 1;
        GrContextForegroundSet(&g_sContext, ClrBlack);
        GrRectFill(&g_sContext, &sRect);
        GrContextForegroundSet(&g_sContext, ClrWhite);
    }

    Angela

  • There's another explanation for your problem. You are setting the last, bOpaque, parameter of GrStringDrawCentered to "false" which tells the graphics library that you want the new text to be transparent and for whatever is beneath it to shine through the newly-drawn text. This is intended to allow you to draw text over some other graphic without having a rectangular, background-color box behind the text. If you want to clear the area under the text, set this parameter to "true" and the library will draw both foreground and background pixels when it writes the text, erasing whatever was there as it writes each character.