Jump to content

Touchscreen Calibration At Start-Up


aymen

Recommended Posts

Hi all!

I was doing some tests with the widgets demo but none of the them(push-buttons, tab sets etc...) were working. I found out that i need to do  some calibration before using the touchscreen (by setting "GINPUT_TOUCH_STARTRAW" to "GFXOFF") after the calibration, the widgets works fine.

In fact my problem is that i have to perform this calibration every time. Is there a way to do this once and save/load the results?

I saw that there are two macros : "GINPUT_TOUCH_USER_CALIBRATION_SAVE" and "GINPUT_TOUCH_USER_CALIBRATION_LOAD " but i am not sure to have understood how to use these. I think that i have to implement the associated fonctions ("SaveMouseCalibration" and "LoadMouseCalibration" in "ginput_mouse.c" file) myself. Am i right?

I am using an STM32F407 with a custom board, an 7'' 800x480 LCD display with SSD1963 display controller and an STMPE811 touchsreen controller.

Thank you!

Edited by aymen
Link to comment
Share on other sites

I have managed to implement the two functions (" SaveMouseCalibration " and " LoadMouseCalibration"). In fact i am using the µController (STM32F407) Flash to store the values of the calibration. It works well, i can write and read the stored value.

However, i have a problem : i get a hard-fault error (branch to an address where no code is located ) when i come to this test in the code (in ginput_mouse.c) :

if (gmvmt(m)->calsave)
	gmvmt(m)->calsave(m, &m->caldata, sizeof(GMouseCalibration));

My question is : what are these lines doing exactly?

Thank you

Link to comment
Share on other sites

gmvmt is a VMT (virtual method table). calsave is a function pointer in that table. Your custom saving routine is registered there. Therefore, gmvmt(m)->calsave() will call your custom saving function.

If you get a hard-fault at that point your function is either not properly registered (wrong address?) or the implementation of your own function is causing the hardfault. Step into that function to check which one is the case.

Link to comment
Share on other sites

Thank you Joel!

You were right! The problem come from my own function. I was using eeprom emulation  : it allows the user to store some datas directly on the mcu flash at runtime. The problem is that it overlaps the user code location (at least in my case) so when i had to write the calibration data i was erasing others existing datas and the program could not work properly...

Anyway, i think that i will hardcode the calibration values, it will be easier.

But i still have a question : is it possible to launch the calibration process manually? For example only if i push a button at start up or if i have a jumper in a given position...

Thank you!

Link to comment
Share on other sites

Glad to hear that you managed to get it working.

 

33 minutes ago, aymen said:

But i still have a question : is it possible to launch the calibration process manually? For example only if i push a button at start up or if i have a jumper in a given position...

I can't check right now but as far as I know there's no high-level API call for that at the moment.

Link to comment
Share on other sites

Hardcoding the values is a great option for a one-off device.

For a production run that is obviously too unweildy as each device will require different calibration values. In that situation a load/save is best as it can be calibrated once during manufacture or on first startup and it will be correct thereafter.

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...