cancel
Showing results for 
Search instead for 
Did you mean: 

Touchgfx change complete screen during run time and customized widget creation

Hello, I and using Touchgfx in my project. I want to implement below.

1) During run time , I want to to turn off complete screen.

2) During run time , I want to change complete screen.

3) I want to generate QR code dynamically and also want to clear it sometimes during run time. I got github link and added those files in my project. Still I am not sure how to call it. You have mentioned to call qrCode.setXY(0,0) , qrCode.setQRCode(&code), qrCode.setScale(4) , add(qrCode) methods but I am unable to find it.

Can any one please help ?

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

1) Seems like a hardware thing.

2) Change screens at run-time with interactions in the designer.

3) QRCodeWidget inherits from Widget which has setXY() and your view has add(). setQRCode() and setScale() are declared in QRCodeWidget.hpp. It's all there on github.

class QRCodeWidget : public touchgfx::Widget
{
...
    /**
     * @fn void QRCodeWidget::setQRCode(QRCode *code);
     *
     * @brief Set the qr code to display
     */
    void setQRCode(QRCode *code);
 
    /**
     * @fn void QRCodeWidget::setScale(uint8_t s);
     *
     * @brief Set the scaling factor of the widget
     */
    void setScale(uint8_t s);
...
}

 To summarize. If you're looking at the README.md for QR code, then:

qrCode.setXY(0,0);                   //From widget
qrCode.setQRCode(&code);  //From QRCodeWidget
qrCode.setScale(4);                 //From QRCodeWidget
add(qrCode);                            //Add to root container of your screen (view)

View solution in original post

48 REPLIES 48
Martin KJELDSEN
Chief III

1) Seems like a hardware thing.

2) Change screens at run-time with interactions in the designer.

3) QRCodeWidget inherits from Widget which has setXY() and your view has add(). setQRCode() and setScale() are declared in QRCodeWidget.hpp. It's all there on github.

class QRCodeWidget : public touchgfx::Widget
{
...
    /**
     * @fn void QRCodeWidget::setQRCode(QRCode *code);
     *
     * @brief Set the qr code to display
     */
    void setQRCode(QRCode *code);
 
    /**
     * @fn void QRCodeWidget::setScale(uint8_t s);
     *
     * @brief Set the scaling factor of the widget
     */
    void setScale(uint8_t s);
...
}

 To summarize. If you're looking at the README.md for QR code, then:

qrCode.setXY(0,0);                   //From widget
qrCode.setQRCode(&code);  //From QRCodeWidget
qrCode.setScale(4);                 //From QRCodeWidget
add(qrCode);                            //Add to root container of your screen (view)

Thanks for reply. I am looking to know where should i put below? In main ?

qrCode.setXY(0,0);                   //From widget
qrCode.setQRCode(&code);  //From QRCodeWidget
qrCode.setScale(4);                 //From QRCodeWidget
add(qrCode);                            //Add to root container of your screen (view)

Also Regarding turn off complete screen during run time, will be able to suggest which hardware changes I need to do ?

This code goes into setupScreen() of your view. Remember to declare qrCode in the view headerfile .

/Martin

I added code inside my main screen view. I just want to put some dummy QR code for quick test so commented out setQRcode part but post below code, program is going to hard fault.

Should we generate QR code with some open library and pass those pixel in qrCode.setQRCode ?

Please suggest.

0693W000000WbcGQAS.jpg

PS - I updated code as below, but still it didn't help. code is going to hardfault.

0693W000000WbfAQAS.jpg

code.at(x,y); will just return the value of the QR code at that spot so you won't gain anything by calling it, If you look at draw() for QRCodeWidget, you'll see it loops over the qr-code width/height and asks for the value at each index of the code to draw it into the framebuffer.

Does the app run fine if not adding a QR code?

And yes you need to supply a QR code somehow. If you check the QRCode class it just randomizes the data for each "pixel".

/Martin

Yes, my code is working fine without adding QR code. How should I make it work ? Please suggest ?

Also code is not going to QRCodeWidget::draw, Before this code is getting stuck at hard fault. I added code at void MainScreenViewBase::setupScreen() .

Using an RTOS? Try increasing stack of the task and the general heap.

Yes I m using RTOS. i tried increasing it but no luck.

0693W000000WcjDQAS.jpg

Also I am not able to track where exactly its going for hard fault. Stack callback is like below.

0693W000000WcjIQAS.jpg

My added QR code is as below.

void MainScreenViewBase::setupScreen()
{
	QRCodeWidget qrCode;
	QRCode code;
	qrCode.setXY(30,50);                   //From widget
	qrCode.setQRCode(&code);    //From QRCodeWidget
	qrCode.setScale(4);                 //From QRCodeWidget
	add(qrCode);                            //Add to root container of your screen (view)
 
}

That's just the heap. Did you increase the stack size for your task?