cancel
Showing results for 
Search instead for 
Did you mean: 

DebugPrinter Feature available in TouchGFX 4.12.3?

Marco.R
Senior

Hi

Does anyone know if the DebugPrinter is still available in current version (see Link)?​. I tried to implement it but it looks like LCD16DebugPrinter isn't available anymore.

If it is still available, how can I use it?

Thanks

Marco

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

I think that in 4.12.3 the DebugPrinter was renamed to LCD24DebugPrinter. It probably was 24bit to begin with (related to the hand-written glyphs being used).

In 4.13.0 we have DebugPrinter support for all LCD drivers. Should be out this december.

/d/TouchGFX/4.12.3/touchgfx/lib/core/cortex_m7/gcc
$ nm libtouchgfx.a | grep DebugPrinter
00000001 W _ZN8touchgfx17LCD24DebugPrinterD0Ev
00000001 W _ZN8touchgfx17LCD24DebugPrinterD1Ev
00000001 W _ZN8touchgfx17LCD24DebugPrinterD2Ev
00000000 n _ZN8touchgfx17LCD24DebugPrinterD5Ev
00000001 T _ZNK8touchgfx17LCD24DebugPrinter4drawERKNS_3LCDE
00000000 R _ZTVN8touchgfx17LCD24DebugPrinterE

/Martin

View solution in original post

8 REPLIES 8
Martin KJELDSEN
Chief III

I think that in 4.12.3 the DebugPrinter was renamed to LCD24DebugPrinter. It probably was 24bit to begin with (related to the hand-written glyphs being used).

In 4.13.0 we have DebugPrinter support for all LCD drivers. Should be out this december.

/d/TouchGFX/4.12.3/touchgfx/lib/core/cortex_m7/gcc
$ nm libtouchgfx.a | grep DebugPrinter
00000001 W _ZN8touchgfx17LCD24DebugPrinterD0Ev
00000001 W _ZN8touchgfx17LCD24DebugPrinterD1Ev
00000001 W _ZN8touchgfx17LCD24DebugPrinterD2Ev
00000000 n _ZN8touchgfx17LCD24DebugPrinterD5Ev
00000001 T _ZNK8touchgfx17LCD24DebugPrinter4drawERKNS_3LCDE
00000000 R _ZTVN8touchgfx17LCD24DebugPrinterE

/Martin

Marco.R
Senior

Hi @Martin KJELDSEN​

Thank you for the information. In that case I'll wait for the next release.

Marco

I ran across DebugPrinter yesterday and was wondering about how to implement it as well.

Thanks for providing the link you did.

Martin, are are there an example that utilizes it?

I did get something to compile and work (somewhat). Things have changed since the TouchGFX Tips and Tricks in the link you provided.

FrontendApplication.cpp:

#include <gui/common/FrontendApplication.hpp>
#include <platform/driver/lcd/LCD24bpp.hpp>
LCD24DebugPrinter lcd24bppDebugPrinter;
 
FrontendApplication::FrontendApplication(Model& m, FrontendHeap& heap)
    : FrontendApplicationBase(m, heap)
{
	lcd24bppDebugPrinter.setDebugPosition(0, 0, 240, 40);
	lcd24bppDebugPrinter.setDebugScale(2);
	lcd24bppDebugPrinter.setDebugColor(0x00); //black
	Application::setDebugPrinter(&lcd24bppDebugPrinter);
}

Then when implementing it in a Screen1View.cpp, calling the following function works except not invalidated on the screen correctly.

Unicode::UnicodeChar debugStringBuffer[30];
 
void Screen1View::updateDebugString()
{
  static int count = 0;
  count++;
  Unicode::snprintf(debugStringBuffer, sizeof(debugStringBuffer), "%d", count);
  Application::getDebugPrinter()->setDebugString((const char*)debugStringBuffer);
  //  touchgfx::Application::invalidateDebugRegion();
}

I needed to comment out the call to invalidateDebugRegion() because it is no longer a valid function.

I tried to call invalidateArea(), but is a protected function.

In TouchGFX 4.12.3, they added setDebugString to the Application class (framework/include/touchgfx/Application.hpp):

/**
     * @fn static void setDebugString(const char* string);
     *
     * @brief Sets the debug string to be displayed onscreen.
     *
     *        Sets the debug string to be displayed onscreen on top of the framebuffer.
     *
     * @param [in] string The debug string to display onscreen.
     */
    static void setDebugString(const char* string)
    {
        if (debugPrinter)
        {
            debugPrinter->setDebugString(string);
            getInstance()->invalidateArea(debugPrinter->region());
        }
    }

And it appears that it should do the invalidating so there is no need to call invalidateDebugRegion().

As stated, it is not invalidating correctly on my display, however.

Here's an example:

0690X00000AtQjRQAV.png

Here's the important code. This is just using a simulator.

int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    ...
    LCD24DebugPrinter lcd24bppDebugPrinter;
 
    char allchars[256];
    int ix = 0;
    for (int i = 32; i < 128; i++)
    {
        allchars[ix++] = i;
        if (i % 32 == 31)
        {
            allchars[ix++] = '\n';
        }
    }
    allchars[ix] = 0;
 
    char buf[300];
    snprintf(buf, sizeof(buf), "Hello World!\nMulti - line debug message!\nWindow size: %d*%d\n\n%s", SIM_WIDTH, SIM_HEIGHT, allchars);
 
    // Create hardware layer. Display size is defined in SimConstants.hpp
    // Martin: Important to init HAL before using Color class
    HAL& hal = touchgfx_generic_init<HALSDL2>(dma, lcd, tc, SIM_WIDTH, SIM_HEIGHT, 0, 0);
 
    // Simulate hardware running at 60Hz generating a vsync every 16.6667 ms
    static_cast<HALSDL2&>(hal).setVsyncInterval(16.6667f);
    static_cast<HALSDL2&>(hal).setWindowTitle(SIM_TITLE);
 
    //Configure debug printer
    lcd24bppDebugPrinter.setPosition(50, 10, SIM_WIDTH - 60, SIM_HEIGHT - 30);
    lcd24bppDebugPrinter.setColor(Color::getColorFrom24BitRGB(255, 0, 0));
    lcd24bppDebugPrinter.setScale(2);
 
    //Set printer object and debug string
    Application::setDebugPrinter(&lcd24bppDebugPrinter);
    Application::setDebugString(buf);
    ....
}

Martin,

Thanks for your reply.

I was getting errors when implementing on the STM32F746G-Discovery kit as it didn't know what setPosition(), setColor(), and setScale() were (TouchGFX 4.12.3).

I used setDebugPosition(), setDebugColor(), and setDebugScale() (which the TouchGFX console suggested)..

It complied when I call those functions instead. And for anyone else looking at doing this, I needed include the following at the top of simulator/main.cpp:

#include <platform/driver/lcd/LCD24bpp.hpp>
#include <touchgfx/Color.hpp>

I plan on trying this on the target next as this feature is actually more applicable to a target since the Simulator already has a console for logging debug messages.

When I attempted placing Martin's code inside the BoardConfiguration.cpp file, it compiled but I got a Hard Fault.

When I placed it in Screen1View.cpp (Screen1View::setupScreen), I get the first character ("H") to display, but nothing else is displayed. I checked with the debugger and the values of the buf variable are correct prior to calling setDebugString().

Can this be implemented in Screen1View.cpp?