Jump to content

use custom stmpe811 driver


Nikolay

Recommended Posts

I have a driver for stmpe811. This is based on using i2c interrupts of stm32 (RXNE, ADDR, SB..). My function reading look as start exchange, wait and handled some interrupts. And at the end I get XY coordinates in interrupt's handler.
How can I put this value in gwin?

I see stmpe811 driver, but I don't understand how embed my read function, because uGWIN is a initiate gets of coordinates but i need backward.

Link to comment
Share on other sites

And I want don't use the timer in function _gmouseInitDriver. Is it possible?

Quote

// Ensure the Poll timer is started
    if (!gtimerIsActive(&MouseTimer))
        gtimerStart(&MouseTimer, MousePoll, 0, TRUE, GINPUT_MOUSE_POLL_PERIOD);

Maybe create function like "put_mouse_data_in_ginput"? Sometimes the timer is redundant and spends resources

Edited by Nikolay
Link to comment
Share on other sites

Set the mouse timer period to TIME_INFINITE. This is done in your gfxconf.h file.

In yiur driver interrupt save the x and y and then call MouseTimerJab (I think that is what it is called). Some time later the mouse code will call your driver read function and you can then return the values you saved in the interrupt handler.

The reason you do not want to turn off the mouse timer is that there are all sorts of other things that are also being handled by the mouse timer. Also using the timer jab allows all the heavy cpu processing and inter-thread communication to happen outside the interrupt handler.

Note that in our experience touch controller chips are very unreliable when run with interrupts. They tend to freeze up, give wrong values, sometimes just forget to interrupt at all or generate tonnes of spurious interrupts. For chips that supply a "touched" interrupt the point it generates the interrupt is invariably nowhere near as good or as reliable as we can determine for ourself. That is why for all existing mouse drivers except a couple of emulation touch drivers we have not used the interrupts - they are just too flaky.

Link to comment
Share on other sites

  • 2 weeks later...

That is not a function you should be calling. Whilst I may not have the Jab toutine name 100% correct (i am on my phone so can't look it up now) the method described above is the correct method. For example look at the Win32 mouse driver (part of the Win32 gdisp driver).

Link to comment
Share on other sites

ugfx_2.7\drivers\multiple\Win32\gdisp_lld_Win32.c

Only this file fits your description. In this there is function

void gfxEmulatorMouseInject(GDisplay *g, uint16_t buttons, coord_t x, coord_t y)

But don't  example how to use it. In particular how to get GDisplay*g in main. And there is no use of a timer.

For example in STEmWin there are function 

GUI_PID_STATE ts_state = {TSC_data.x, TSC_data.y, TSC_data.touchState, LAYER_0};
GUI_TOUCH_StoreStateEx(&ts_state);

simple and understandable

When this function is called, the GUI react

Link to comment
Share on other sites

Please listen. You are not looking for a function - you are looking for how the win32 code works.

1. When it gets a windows mouse message it just saves the values and then calls MouseTimerJab.

2. Sometime later the mouse code calls the mouse driver get routine which returns the values previously saved.

You will need to follow a similar process. The code is not identical but the way it needs to work is.

Please also take notice of the comments on interrupt driven touch devices. Generally they just do not work well.

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