2020-04-07 04:18 AM
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!
2020-04-07 04:49 AM
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
2020-04-07 05:05 AM
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.
2020-04-07 05:10 AM
But can you hit a breakpoint where x and y are assigned? When returning true, the touchgfx engine will distribute the coords. Thanks
2020-04-07 05:14 AM
The breakpoint in this function always triggers
2020-04-07 05:20 AM
2020-04-07 05:47 AM
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
2020-04-07 06:02 AM
2020-04-07 06:26 AM
#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.
2020-04-07 06:34 AM
#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.