cancel
Showing results for 
Search instead for 
Did you mean: 

Using a PainterRGB888 in custom container causes TouchGFX thread to halt

JHarding
Senior

Hello,

TouchGFX version: 4.15.0

STMCubeIDE: 1.4.2

I need some help, I am seeing some strange behavior from a custom module I am creating. Basically, when I am forced to use a PainterRGB888 to color a circle, TouchGFX will halt when calling showBaseModal()

Here is my class:

#include <gui/containers/modal/modalBase.hpp>
#include <touchgfx/Color.hpp>
 
modalBase* modalBase::getInstance()
{
    static modalBase gModalBase;
    return &gModalBase;
}
 
modalBase::modalBase()
{
    mInternalWidth  = 212;
    mInternalHeight = 159;
    mCornerRadius   = 10;
    mEdgeBuffer     = 30;
 
    mMainContainer.setX(0);
    mMainContainer.setY(0);
    mMainContainer.setWidth(272);
    mMainContainer.setHeight(480);
 
    circleTopLeft.setPosition(mEdgeBuffer, 161, mCornerRadius*2, mCornerRadius*2);
    circleTopLeft.setCenter(mCornerRadius, mCornerRadius);
    circleTopLeft.setRadius(mCornerRadius);
    circleTopLeft.setLineWidth(0);
    circleTopLeft.setArc(0, 360);
    circleTopLeftPainter.setColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
    circleTopLeft.setPainter(circleTopLeftPainter);
 
    mMainContainer.add(circleTopLeft);
}
 
void modalBase::initialize()
{
 
}
 
void modalBase::showBaseModal()
{
    if(!application().getCurrentScreen()->getRootContainer().contains(mMainContainer))
        application().getCurrentScreen()->getRootContainer().add(mMainContainer);
 
    mMainContainer.invalidate();
}
 
#ifndef GUI_INCLUDE_GUI_CONTAINERS_MODALBASE_HPP_
#define GUI_INCLUDE_GUI_CONTAINERS_MODALBASE_HPP_
 
#include <gui/common/FrontendApplication.hpp>
#include <touchgfx/containers/Container.hpp>
#include <touchgfx/widgets/Box.hpp>
#include <touchgfx/widgets/canvas/Circle.hpp>
#include <touchgfx/widgets/canvas/PainterRGB888.hpp>
#include <touchgfx/widgets/canvas/Line.hpp>
#include <gui/containers/HomeBar.hpp>
#include <touchgfx/mixins/MoveAnimator.hpp>
 
class modalBase
{
public:
    static modalBase* getInstance();
 
    virtual void initialize();
 
    void showBaseModal();
 
protected:
    FrontendApplication& application()
    {
        return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
    }
 
    touchgfx::Circle circleTopLeft;
    touchgfx::PainterRGB888 circleTopLeftPainter;
 
    MoveAnimator< touchgfx::Container > mMainContainer;
private:
    modalBase();//Private so no one else can make one of me.
 
    int mInternalWidth;
    int mInternalHeight;
    int mCornerRadius;
    int mEdgeBuffer;
};
 
#endif /* GUI_INCLUDE_GUI_CONTAINERS_MODALBASE_HPP_ */

If I change the circle to something like a Box that doesn't require a painter, then the code works just fine. If I change it to a line (which requires a painter) then TouchGFX halts when calling showBaseModal();

If I use a circle from within TouchGFX generator, that circle will be drawn on the screen without issue.

Any idea what I am doing wrong here?

11 REPLIES 11

I believe so.

This is why I said this might be something we can optimize ^^

/Alexandre

​The Designer will set up the canvas buffer for each view that requires it, but you can also do what you're doing to set a global buffer.