6
votes

I have a simple Qt5.2 application it's built for the TI AM335x EVM (ARM based processor). It just has 1 button on it which enables some LEDs on the board.

The problem I'm having is that the touch event is not calibrated to the screen. Example:

*************
*           *
*  []       *
*       X   *
*           *
*************

So if the [] is where the button is, the X is where you have to touch to activate it. It's like it's upside down and backwards. I've tried with larger applications (more buttons) and the trend follows.

Now when I use the Qt4.8 GUI user interface provided by TI, the touch works as expected, so for some reason when I compile by 5.2 code it seems like it needs to be recalibrated, but I'm not sure how to do that.

My questions:

  1. Has anyone working with Qt run into anything like this in the past?
  2. Anyone who knows Qt know if there is an ability to recalibrate programmatically? (I can't seem to find anything about this on the Qt site)

Additional information that may or may not be helpful:

My Qt environment was configured with this command:

./configure -prefix /usr/Qt5.2 -xplatform linux-am335x-g++ -no-sse -no-sse2 -no-glib -no-cups -no-largefile -no-accessibility -no-openssl -no-gtkstyle -opensource

Followed by a make and make install. My path is updated to include the correct version of the TI toolchain and the home configured/built version of qmake:

mike@mike-VirtualBox:/usr/Qt5.2/test_button$ echo $PATH
/usr/Qt5.2/bin: /home/mike/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin:/usr/local/Trolltech/Qt-4.8.5/bin:/home/mike/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/mike/bin

Flags used in the actual compile command:

arm-linux-gnueabihf-g++ -c -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../mkspecs/linux-am335x-g++ -I. -I. -I../include -I../include/QtWidgets -I../include/QtGui -I../include/QtCore -I. -o main.o main.cpp

The application is launched with:

./touch_keys -platform eglfs

The application:

main.cpp:

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    MainWindow mainWindow;
    mainWindow.showMaximized();
    return app.exec();
}

mainwindow.cpp

#include "mainwindow.h"
#include <QtCore/QCoreApplication>
#include <QDebug>
#include <QFile>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    // Create the button, make "this" the parent
    m_button = new QPushButton("Light LEDs", this);

    // set size and location of the button
    m_button->setGeometry(QRect(QPoint(100, 100),
                                 QSize(200, 50)));

    // Connect button signal to appropriate slot
    connect(m_button, SIGNAL(released()), this, SLOT(handleButton()));
}

void MainWindow::handleButton()
{
    char buf[10];
    // change the text
    m_button->setText("Boom");

    // resize button
    m_button->resize(100,100);
}

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPushButton>

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    explicit MainWindow(QWidget *parent = 0);
private slots:
    void handleButton();
private:
    QPushButton *m_button;
};

#endif // MAINWINDOW_H
1
@artlessnoise - It's a resistive touch display that comes with the AM335x EVM. The display itself does have a calibration mechanism and on first boot it's run automatically and the results are saved on the uSD card. After a successful calibration the TI "app launcher" GUI (called matrix) works and responds correctly, but then I launch my home made Qt 5.2 applications the touches are registered backwards and upside down from where they should be. So it has to be something wrong with how I’m configuring or launching the applications…Mike
@artlessnoise - In Qt4.8 there was a -qt-mouse-tslib configuration command, but when I switched to Qt5.2 that came up as an invalid configuration flag... so I'm not sure how "touch" is known to be used now. I'm launching the application as a -platform eglfs. It’s likely that my problem and the fact that I don’t know what touch screen lib is being used are one and the same, but I’m not sure.Mike
I think you use QMAKE_LIBS += -lts in the qmake.conf and configure checks and finds it? I think you need -device and -device-option to configure and support files (qmake.conf) to set this up. It seems this is not really well documented anywhere. I had to looks at examples and do lots of googling before I got it to work. You need libts to do the transform from touch co-ord to screen for your resistive touch; this is the calibration data.artless noise
@artlessnoise - Doing a lot of google work I found notes about how tslib support is not present by default, but there are patches (starting Qt5.0.2) to pull this in. I would have thought it present by 5.2. I can easily add the -lts option you mention to the qmake.conf, but could you elaborate on this -device and -device-option, as far as I can tell that's a way to pass custom flags to the Qt build. Is that correct? How would that help if the touch support is not present? (if you do have this working feel free to make an answer and I'll test it out from there)Mike
I think that -device is a way to configure Qt5.0 for a particular type of hardware. It says, framebuffer, mouse, touch screen, etc. This is sort of like the older 'qws/platform' information. I understood -device allowed libts, but I don't know this as a fact. Again, I couldn't find a lot of information and I feel your pain. I have the Qt5.0 compiling and I tested some things; however, due to the API changes (QtQuick, etc), our app people don't want it right now. I am not sure if I tested touch or not. Sorry.artless noise

1 Answers

10
votes

So I found out that the touch support via tslib should not be required when using the eglfs platform plugin. eglfs has the evdev input handlers built-in so mouse/keyboard/touch support come without needing anything else to connect to the correct device.

This means that evdevtouch is failing to recognize the touch screen on am335x, this was supposed to be corrected in 5.2, but clearly still isn't. The "fix" (workaround) is to flip the screen manually by exporting an QPA environment variable:

export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS="rotate=180" 

This properly transforms the coordinates.