cancel
Showing results for 
Search instead for 
Did you mean: 

My touchscreen is not working properly

ANapa
Associate III

Hi All.

I have my own development board on STM32.

TouchGfx 4.13.0 is ported to it.

Displays box, button, scrollbox and text.

The coordinates of the touchscreen I pass to

bool STM32TouchController::sampleTouch(int32_t& x, int32_t& y)
{
 
        if(touchDataReady == true)
        {
            x = tscX; // tscX is correct and given from I2C4 STM32H7BIT6
            y = tscY; // tscY is correct and given from I2C4 STM32H7BIT6
			
			touchDataReady = false;
 
            return true;
			
        }
 
        return false;
		
}

This function is permanently called from the TouchGfx kernel.

On "View", the overrided "handleTickEvent()" works well, but my overrided

"handleClickEvent()" not called.

The screen does not respond to clicks.

This is my third development with the TouchGfx.

Used version 4.13.0 and STM32H746BIT6

Two previous boards were built on controllers STM32F746 with TouchGfx 4.10.0

and work fine.

Help me, please!

0693W000000VSTcQAO.jpg

17 REPLIES 17
Martin KJELDSEN
Chief III

Hi,

I'm assuming you're not posting all your code from the sampleTouch() function.

Are you able to break inside the sampleTouch() function following the condition if(touchDataReady == true) ? (this code will only execute once since touchDataReady is set to "false" immediately after.

/Martin

ANapa
Associate III

Thanks for the answer Martin!

Variable touchDataReady sets true in I2C Interrupt, 

when touch-panel data occured from I2C bus and translate to display-coords 1280x800 

X=568

Y=145

is the real coords of my finger.

This coords Im passed via handleTickEvent.

They smoothly changed follows up my finger.

TouchGfx not take this coords from internal mechanics.

This is bool STM32TouchController::sampleTouch(int32_t& x, int32_t& y) function, 

as i was always sure.

Martin KJELDSEN
Chief III

But can you hit a breakpoint where x and y are assigned? When returning true, the touchgfx engine will distribute the coords. Thanks

ANapa
Associate III

The breakpoint in this function always triggers

ANapa
Associate III

0693W000000VSmPQAW.png

Martin KJELDSEN
Chief III

Something is wrong with the code, in some way. It's by nature the behavior of the engine to report a set of touch coordiantes IF sampleTouch() returns true. You could assign random values to x and y and your handleClickEvent should still be called.

Show me your view code that you expect to be executed?

/Martin

ANapa
Associate III

0693W000000VT2IQAW.png

ANapa
Associate III
#include <gui/screen1_screen/Screen1View.hpp>
#include <touchgfx/Color.hpp>
#include <stdio.h>
 
extern uint16_t tscX;
extern uint16_t tscY;
 
Screen1View::Screen1View()
{
	tickCount = 0;
 
    testBox.setPosition(200, 200, 100, 100);
    text.area().setTypedText(touchgfx::TypedText(T_COMMON_TEXT_SMALL_CENTER));
    text.area().setPosition(200, 250, 100, 100);
    text.area().setColor(touchgfx::Color::getColorFrom24BitRGB(0xFF, 0xFF, 0xFF));
 
    textX.area().setTypedText(touchgfx::TypedText(T_COMMON_TEXT_SMALL_CENTER));
    textX.area().setPosition(200, 300, 100, 100);
    textX.area().setColor(touchgfx::Color::getColorFrom24BitRGB(0x0, 0x0, 0x0));
 
    textY.area().setTypedText(touchgfx::TypedText(T_COMMON_TEXT_SMALL_CENTER));
    textY.area().setPosition(200, 350, 100, 100);
    textY.area().setColor(touchgfx::Color::getColorFrom24BitRGB(0x0, 0x0, 0x0));
 
 
    add(testBox);
    add(text.area());
    add(textX.area());
    add(textY.area());
    text.setText("Text Area");
 
 
}
 
void Screen1View::touchEvent(ClickEvent evt)
{
    int c = 0;
 
    if(evt.getEventType() == ClickEvent::PRESSED)
    {
        c++;
    }
    else
    if(evt.getEventType() == ClickEvent::RELEASED)
    {
        c--;
    }
}
 
void Screen1View::setupScreen()
{
    Screen1ViewBase::setupScreen();
}
 
void Screen1View::tearDownScreen()
{
    Screen1ViewBase::tearDownScreen();
}
 
void Screen1View::handleTickEvent()
{
 
    char bufx[7];
    char bufy[6];
 
    static int c = 0;
 
    if(tickCount < 2000)
    {
        sprintf(bufx, "X=%d", tscX);
        sprintf(bufy, "Y=%d", tscY);
        bufx[6] = 0;
        bufy[5] = 0;
        textX.setText(bufx);
        textY.setText(bufy);
        textX.area().invalidate();
        textY.area().invalidate();
 
        tickCount++;
    }
    else
    {
        tickCount = 0;
    }
 
	
}
 
I can transfer all coordinates to handleTickEvent manually.
They change smoothly across the screen.

0693W000000VT9xQAG.gif

ANapa
Associate III
#include <gui/screen1_screen/Screen1View.hpp>
#include <touchgfx/Color.hpp>
#include <stdio.h>
 
extern uint16_t tscX;
extern uint16_t tscY;
 
Screen1View::Screen1View()
{
	tickCount = 0;
 
    testBox.setPosition(200, 200, 100, 100);
    text.area().setTypedText(touchgfx::TypedText(T_COMMON_TEXT_SMALL_CENTER));
    text.area().setPosition(200, 250, 100, 100);
    text.area().setColor(touchgfx::Color::getColorFrom24BitRGB(0xFF, 0xFF, 0xFF));
 
    textX.area().setTypedText(touchgfx::TypedText(T_COMMON_TEXT_SMALL_CENTER));
    textX.area().setPosition(200, 300, 100, 100);
    textX.area().setColor(touchgfx::Color::getColorFrom24BitRGB(0x0, 0x0, 0x0));
 
    textY.area().setTypedText(touchgfx::TypedText(T_COMMON_TEXT_SMALL_CENTER));
    textY.area().setPosition(200, 350, 100, 100);
    textY.area().setColor(touchgfx::Color::getColorFrom24BitRGB(0x0, 0x0, 0x0));
 
 
    add(testBox);
    add(text.area());
    add(textX.area());
    add(textY.area());
    text.setText("Text Area");
 
 
}
 
void Screen1View::touchEvent(ClickEvent evt)
{
    int c = 0;
 
    if(evt.getEventType() == ClickEvent::PRESSED)
    {
        c++;
    }
    else
    if(evt.getEventType() == ClickEvent::RELEASED)
    {
        c--;
    }
}
 
void Screen1View::setupScreen()
{
    Screen1ViewBase::setupScreen();
}
 
void Screen1View::tearDownScreen()
{
    Screen1ViewBase::tearDownScreen();
}
 
void Screen1View::handleTickEvent()
{
 
    char bufx[7];
    char bufy[6];
 
    static int c = 0;
 
    if(tickCount < 2000)
    {
        sprintf(bufx, "X=%d", tscX);
        sprintf(bufy, "Y=%d", tscY);
        bufx[6] = 0;
        bufy[5] = 0;
        textX.setText(bufx);
        textY.setText(bufy);
        textX.area().invalidate();
        textY.area().invalidate();
 
        tickCount++;
    }
    else
    {
        tickCount = 0;
    }
 
	
}
 
I can transfer all coordinates to handleTickEvent manually.
They change smoothly across the screen.

0693W000000VT9xQAG.gif