Jump to content

ginput doesn't work with GINPUT_MOUSE_NEED_CALIBRATION FALSE


trunet

Recommended Posts

I'll have a look at this tonight. Can you please leave some more information about your hardware setup, which driver you are using and why you want to skip the calibration?

There's a small hack: You can use 9999 as the instance parameter that you pass to gwinAttachMouse() to skip the calibration for now. However, this is not the desired way as it is a workaround.

~ Tectu

Link to comment
Share on other sites

I'm using that HY-MiniSTM32V with 3.2 TFT display. Driver is that one that I sent on my other thread.

But which touch driver are you using? I don't see which driver from /drivers/ginput/touch you're using.

Try the trick with the 9999 instance first. I'm currently not at home either so I cannot investigate.

~ Tectu

Link to comment
Share on other sites

It runs fine.

gwinAttachMouse(9999) doesn't work, it skips calibration. gwinAttachMouse(0), asks for calibration and works fine after that.

If this touch_test works, it's because it's not using widgets. I tested gwin/widgets demo and it doesn't work without calibration, as my custom software.

I think the problem is a bug on GWIN.

Link to comment
Share on other sites

There is definitely a problem as I can confirm it myself now.

We will look into this as fast as possible.

In the meantime you can probably try to add a custom calibration load function (using ginputSetMouseCalibrationRoutines()) and returning an empty struct. "Empty struct" means that the parameters are set in a way that they don't change anything. Probably "neutral calibration data" would be the more appropriate term. The neutral struct looks like this:


ax = 1;
bx = 0;
cx = 0;
ay = 0;
by = 1;
cy = 0;

The struct itself is defined in mouse.c:


typedef struct Calibration_t {
float ax;
float bx;
float cx;
float ay;
float by;
float cy;
} Calibration;

~ Tectu

Link to comment
Share on other sites

I think you are both missing the point. The driver is either calibrated and clipped or non - calibrated with raw readings. The touch driver test code uses this to enable testing of the touch parameters.

If however you disable all calibration code this is NOT the same as running in the special raw mode used by the touch driver test tool. In this situation you will be getting raw readings but they will be clipped to the screen dimensions. As the touch scale is not likely to match one to one with pixel display scale this means the readings will not scale over the display and of course widgets will not work.

In other words this touch controller cannot operate without calibration or atleast scaling of its readings. One that does is the Win32 touch driver as windows performs the scaling and clipping for you before passing them to the ugfx driver. Effectively mouse/touch scaling as seen at the driver level corresponds one to one with the display scaling.

If you want to manually control the calibration and scaling then you need to use Tectu's method with calibration turned on but replace the 1's with the hardwired scaling factor. This will prevent the user being prompted for the calibration.

Note also many touch panels are oriented transverse the the display orientation. If your panel is one of these calibration is the only reliable way to get a working translation and scaling matrix. The maths involved in doing it by hand are nasty.

Link to comment
Share on other sites

I understood inmarket point.

I got my calibration routine save string and statically set on myload function. Worked for me...


static const char *myload(uint16_t instance)
{
char *buf;
uint8_t bsize = 24;

(void)instance;

buf = gfxAlloc(bsize);
strcpy(buf, "\x75\xD4\x84\xBD\x94\xE3\x72\xBA\x73\x76\x7E\x43\x2D\x67\x28\xBA\x17\x3A\xBB\x3D\x41\x05\xFA\xC1");

return buf;
}

ginputSetMouseCalibrationRoutines(0, NULL, myload, FALSE);

Link to comment
Share on other sites

  • 2 weeks later...
how can I convert the calibration values into this format? :(

What format do you mean? You can just assign them as any normal struct member:


cal->ax = 32;
cal->bx = 37;
...

If you refer to the strcpy() command of trunets code sample; it looks like he used some debugging tool to retrieve those values and simply copy pasted them.

~ Tectu

Link to comment
Share on other sites

If I call

mouse = ginputGetMouse(0);
ginputSetMouseCalibrationRoutines(0, mysave, myload, FALSE);

I can save the string like this: "Z,\202=\\\221b¹\037FaÁÅdI:䨹½´>³Cè\017" within the mysave function:

static void mysave(uint16_t instance, const uint8_t *calbuf, size_t sz)
{
(void)instance;
(void)calbuf;
(void)sz;
memcpy(&t_calibration, calbuf, (uint8_t) sz);
}

and than I got that string. But when I change the order of the two functions and the myload returns that string the touchscreen isn't working.

Edited by Guest
Link to comment
Share on other sites

I can save the string like this: "Z,\202=\\\221b¹\037FaÁÅdI:䨹½´>³Cè\017" within the mysave function:

Can you please elaborate how exactly you get this string? Some GDB examination?

The normal process:

  • Make 100% sure that your ginputSetMouseCalibrationRoutines() routine gets called before the ginputGetMouse() routine.
  • At the first execution, make sure that the third parameter of the ginputSetMouseCalibrationRoutines() routine is NULL.
  • Execute the program
  • Either extract the calibration data using a debugger / serial console or any other kind of output or store it on non-volatile memory
  • Set the third parameter of the ginputSetMouseCalibrationRoutines() routine to point to your actual loading routine which provides the data that you just exctracted/saved.
  • Done. Your touchscreen should now automatically load with the correct calibration data.

The wiki does also have this information.

~ Tectu

Link to comment
Share on other sites

First I called the ginoutGetMouse() and within the debugger I copied the string from MouseCondig.caldata after the mysave has been called.

This way when the mysave gets called I have the calbuf type const uint8_t* filled with this kind of string:

0x20001c94 "½3\205=÷&\2348KÓcÁu-6:Í\220»½\n\207°Cð\017"

I guess this is the calibration data. But when I load it back it does not work.

I've tried what you have mentioned, but that way my mysave function never get called:

  ginputSetMouseCalibrationRoutines(0, mysave, NULL, FALSE);
mouse = ginputGetMouse(0);

Edited by Guest
Link to comment
Share on other sites

Saddly I'm not that kind of programmer. :( I can't do that. I can chprintf to serial console but that's not enough.

But I have hard coded them in this form:

return ("=\136\004k:-\158c\193\145#\245\186E\158b\189\185\252\238C\178IH");

This is the return of myload, but it still does not work. I guess I will have to do the calibration thing until I don't have the SD card. :(

Edited by Guest
Link to comment
Share on other sites

You cannot simply return that string. You have to copy that string into a buffer and return the pointer to that buffer. Trunet showed how it's done in his code:

strcpy(buf, "\x75\xD4\x84\xBD\x94\xE3\x72\xBA\x73\x76\x7E\x43\x2D\x67\x28\xBA\x17\x3A\xBB\x3D\x41\x05\xFA\xC1");

return buf;

P.S. Can you please stop quoting the previous post all the time? Quotes are used to answer specific text parts, not the whole post. It's getting very messy otherwise ;-)

~ Tectu

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