Jump to content

Calibration and shared pins


Waylander

Recommended Posts

Hello all!

I'm having hard time with ugfx, because i'm newbie in C world, but i've already managed to create a driver for my lcd (because it is unsupported) and even run ugfx under freertos!

But i have an issue with touch support. My lcd board has no touch controller, it is raw 4 wire resistive touch panel. And what is important (i believe) that those 4 wires are shared with lcd controller (2 data lines and 2 control pins, controller is in parallel mode).

And without calibration everything works (except that i can't click anything), but when calibration starts, display fills for about 30 lines with blue and a top of 'C' letter is visible too in the drawn area. I believe that calibration starts before screen is redrawn. But i don't know how to resolve this.

Does ugfx support such cases when touch panel wires are shared with lcd controller?

Edited by Waylander
Link to comment
Share on other sites

Yes it does. If you look at the existing gdisp drivers you will see that they make a bus_aquire call and a bus_release call which are normally implemented in the board file. These calls are there so that they can be used to get exclusive access to the bus. Where the bus is not being shared with another device these calls can be simply ignored.

So from the gdisp side that is what you need to use.

From the touch side there is typically only the one call made. This call must also obtain exclusive access to the bus. If the bus is busy (due to a gdisp call) then gfxYield() can be called in a loop until the bus becomes available.

Well done on getting what you have working!

Link to comment
Share on other sites

Hi and thanks for the tip, seems like i misunderstood bus_aquire and bus_release, i just switch lcdcontroller's CS pin here. But what should i do more?

I failed to find board examples, so i made it from scratch just using the template file. May be you can point me to the example of MCU touch driver (would be cool if it uses stm32 SPL)? Because i'm also not very confident if the values that i return from driver are correct for ugfx input subsystem.

You mean that ginput driver (that MCU driver) should also have bus_aquire and bus_release functions? But what should they contain? This topic is unknown for me.

UPD: may i use freertos's mutex in both lcd's bus_aquire and touch bus_aquire? I mean will it work? Because i don't know whether drivers are separate tasks or not. Will calibration routine be suspended if touch driver fails to get mutex? Will normal touch polling routine be suspended too, if it fails to get mutex? Won't this suspension break the functionality of ugfx?

Edited by Waylander
Link to comment
Share on other sites

I've looked into implementing aquire_bus and release_bus in the gmouse_lld_MCU_board.h file, but they aren't appear to be called and there is no setting i see that can enable them and it seems to me even in ginput_driver_mouse.h there is nothing about them. What is the right way to do it? Should i just call them manually from read_xyz() ? Actually may be i need to take and give  mutex in the beginning and end of read_xyz() function? Or there is already implemented way, but i don't see it?

Edited by Waylander
Link to comment
Share on other sites

Me again, lol. Mutex did the job (partially), now calibration screen is entirely drawn (all filled blue), but there is no text present. The function that should draw that text is called actually, but displays nothing. That is strange. But if i disable the calibration screen, add a lable that is updated by separate task every tick, so i see that label is updated and touchscreen is polled as expected (every 25 ms), so i assume that there is no deadlock. But why calibration screen fails? What could be the reason? Color is filled, but no text drawn, while the function, that draws "Calibration" string is called.

Link to comment
Share on other sites

I've tried setting caption background to green and i saw it, but text is not there. Font seems to be loading fine, the font variable is filled with some data. And i don't know how this calibration should function, but when i press screen few times, nothing happens, but i think it should proceed, after some inputs? And crosses aren't visible too. So the only thing that is drawn is caption background. I'm still not sure whether my touch driver code works properly for ugfx to understand input data, but i believe that it should at least return proper z value, so touches should be recognizable.

Edited by Waylander
Link to comment
Share on other sites

The fact that draw routines are being called but nothing is displaying, especially the crosses, indicates that perhaps only certain drawing operations are working.

Please start with some of the gdisp module demos just to make sure all drawing operations including text are working properly.

If they are working properly my guess is that sometimes the bus is not being released thus stopping the drawing from continuing.

Link to comment
Share on other sites

Yeah, something seems very wrong with using this mutex. Can you confirm that i'm using it right with ufgx? My drivers have such aquire_bus code:

while (xSemaphoreTake(lcdBusMutex, MUTEX_DELAY) != pdTRUE) { //MUTEX_DELAY = portTICK_PERIOD_MS = 1ms
   gfxYield();
}

So i'm using here freertos's xSemaphoreTake which has maximum wait parameter, after which (i think) it suspends the process. And it returns pdTRUE is mutex was taken. But if it was not, i call gfxYield() as you suggested.

Today i saw another 'cool' stuff on calibration screen, it was outputing garbage of pixels instead of solid color, so i believe there is some fight between disp and input drivers.

Btw if i disable calibration screen, my test screen with button (which is unfunctional at the moment, because of unfunctional input driver) and label, that is updated continuously by task, runs flawlessly. Input driver is still active tho, not calibrated.

Edited by Waylander
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...