Kb1gtt Posted July 24, 2016 Report Share Posted July 24, 2016 I'm trying to get the touch screen to only calibrate when it's required. Is there an example that shows how to do the screen calibration? I'm sure I'm not the first one to do this, however I have not been able to find an existing reference example yet. Here is where I'm at and what I've attempted so far. I found this wiki page http://wiki.ugfx.org/index.php/Touchscreen_Calibration however I'm still lost. When I try to enable load and save like this in gfxconf.h #define GINPUT_TOUCH_USER_CALIBRATION_SAVE TRUE #define GINPUT_TOUCH_USER_CALIBRATION_LOAD TRUE I get this error which are sourced from ginput_mouse.c undefined reference to `LoadMouseCalibration' undefined reference to `SaveMouseCalibration' Also I have an LCD button that will call ginputCalibrateMouse(0); When I press this button, the screen goes blank blue, my heartbeat LED stops blinking, and when I use the debugger pause I see dbg_panic_msg is a stack overflow. I'm not sure how to fix these issues. they are a bit beyond my programming abilities. One person suggested the program might not have enough memory for the stack. I see my make file notes CHIBIOS_LDSCRIPT = STM32F429xI.ld which contains this. MEMORY { flash : org = 0x08000000, len = 2M ram0 : org = 0x20000000, len = 192k /* SRAM1 + SRAM2 + SRAM3 */ ram1 : org = 0x20000000, len = 112k /* SRAM1 */ ram2 : org = 0x2001C000, len = 16k /* SRAM2 */ ram3 : org = 0x20020000, len = 64k /* SRAM3 */ ram4 : org = 0x10000000, len = 64k /* CCM SRAM */ ram5 : org = 0x40024000, len = 4k /* BCKP SRAM */ ram6 : org = 0x00000000, len = 0 ram7 : org = 0x00000000, len = 0 } /* RAM region to be used for Main stack. This stack accommodates the processing of all exceptions and interrupts*/ REGION_ALIAS("MAIN_STACK_RAM", ram0); /* RAM region to be used for the process stack. This is the stack used by the main() function.*/ REGION_ALIAS("PROCESS_STACK_RAM", ram0); /* RAM region to be used for data segment.*/ REGION_ALIAS("DATA_RAM", ram0); Perhaps I should change those ram#'s to something more, but I don't know what they should be changed too. Here's some back ground information about my setup. I'm using an STM32F429 discovery, and I started with this demo I have made reasonably small changes. I added some buttons on the LCD which when pressed will increase and decrease the rate of blinking of the green LED. I also added some debug stuff like setting up the terminal1, and chibios debug options. I have put a copy of my project posted here https://sourceforge.net/p/daecu/code/HEAD/tree/Hardware/trunk/rusefi.com/Digital_Dash_STM32F429/A_stm32f429_discovery_chibios_3/ I'm using chibistudio for the IDE on a win64 platform. Are there any suggestions in what I could look at to help get this screen to only calibrate when needed instead of on every boot? Link to comment Share on other sites More sharing options...
inmarket Posted July 25, 2016 Report Share Posted July 25, 2016 Those references that are undefined are routines you need to create to save and reload your touchscreen calibration data. Saving calibration data obviously requires some form of persistant storage. As ugfx knows nothing about any persistant storage on your board you need to provide the routines to do that. As you are using chibios, the main stack size is defined in one of the chibios config files in your project. I can't remember which file or what the setting is called (I think it might also change between chibios versions). You will need around 2K ram on your main stack for any reasonable sized ugfx application. Link to comment Share on other sites More sharing options...
Kb1gtt Posted July 26, 2016 Author Report Share Posted July 26, 2016 With some help from a friend, I got it working at least from a hard coded standpoint. Using the example on the wiki we got it to display the existing calibrated values, which I then used to replace the numbers noted in the example on the wiki. This has also caused the stack overflow to go away. Next thing to learn is how to make this persistant, such that I can remove the hard coding. I understand there is a lib or similar that I'll need to add to make this easier to do. Also to get the values to hard code, I used the below snippet, then I added to the variables in the Expressions in chibistudio, and copied and pasted the values to the section of the example code. So far so good. bool_t SaveMouseCalibration(unsigned instance, const void *data, size_t sz) { (void)instance; if (sz != sizeof(calibrationData) || instance != 0) { return FALSE; } memcpy((void*)&calibrationData, data, sz); return TRUE; } Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted July 26, 2016 Report Share Posted July 26, 2016 You can use the GFILE module which provides high-level API to access and manage files. It comes with a backend for FatFS which would easily allow you to store your calibration data on an SD-Card. The diskio.[ch] interface implementation required by FatFS are already implemented for ChibiOS. Unless the newer versions changed something, you should be able to just use the existing code. Corresponding documentation: http://wiki.ugfx.org/index.php/GFILE http://wiki.ugfx.org/index.php/FATFS You can of course store your data however and where ever you want. The only thing that matters to uGFX is that the data you provide through LoadMouseCalibration() is exactly the same as the one you get from SaveMouseCalibration. In between those two calls you can do whatever you like: Store them in a file on an SD-Card (most common), store them in an EEprom, FLASH, ... Heck, you could even give your device internet access and store them on a remote web server Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now