I made a quick implementation which allows to store the touchpad calibration data when calling tpCalibrate(). This way, you don't need to do tpCalibrate() after each reset.
The interface is similar to the GPIO abstraction for the LCD module itself. The user can decide where and how he wants to store the data. Someone may want to use an external I²C EEprom, another wants to use the SD card, maybe another uses the MCU's internal storage.
When you want to store the calibration data, you have to add #define TOUCHPAD_STORE_CALIBRATION TRUE in your halconf.h and then provide these two functions somewhere in your project (for example in main.c):
Code: Select all
void lld_tpWriteCalibration(struct cal cal) {
}
struct cal lld_tpReadCalibration(void) {
}
What you do in these two functions is up to you. You just have to make sure that you return the same struct which you receive. If you like, you can store two values on your EEprom and two on your SD card, just reassemble it the right way
This is the calibration struct:
Code: Select all
struct cal {
float xm;
float ym;
float xn;
float yn;
};
I couldn't test it yet. I would be thankful if someone could try this out and write a small review.
I am open for any critism or improvements.
~ Tectu