cancel
Showing results for 
Search instead for 
Did you mean: 

the button be pressed, not release, keep pressed state!

redstone8415
Associate III

one box in the screen, then create a button on box, meant to change the color of box, when button pressed; simulator -> OK; but download to board, running denormal , when button pressed, finger off, button not release, still pressed state, why? (use STM32F429I_DISCO BOARD CUBEIDE)

1 ACCEPTED SOLUTION

Accepted Solutions

just make a test! 

View solution in original post

4 REPLIES 4
JohanAstrup
ST Employee

Hello @redstone8415.

Can you share your project? I just did a quick test, and I do not see any issues.

Best regards,
Johan

the problem is solved, 

box1.setColor(touchgfx::Color::getColorFromRGB(rand()&0xff, rand()&0xff, rand()&0xff));  here to blocking!

to comment out, button is normal!

correction method:

void Screen1View::buttonClicked()
{
    static uint32_t counter = 0;
    counter++;
    
    // Direct color composition (avoids function call)
    uint32_t r = (counter * 13) & 0xFF;
    uint32_t g = (counter * 37) & 0xFF;
    uint32_t b = (counter * 71) & 0xFF;
    
    touchgfx::colortype newColor = (r << 16) | (g << 8) | b;
    box1.setColor(newColor);
    box1.invalidate();
}

 

JohanAstrup
ST Employee

Okay, great to hear!

Is there a reason why you do not use a flex button? Using a flex button allows embedding the box and click functionality within a single widget.

Best regards,
Johan

just make a test!