implemented touchpad calibration storage interface

ugfx_release_2.6
Joel Bodenmann 2012-09-26 00:05:24 +02:00
parent 0ba16c35af
commit 5de2e9ac86
2 changed files with 17 additions and 0 deletions

View File

@ -52,6 +52,10 @@
/* Type definitions */ /* Type definitions */
/*===========================================================================*/ /*===========================================================================*/
#ifndef TOUCHPAD_STORE_CALIBRATION
#define TOUCHPAD_STORE_CALIBRATION FALSE
#endif
/** /**
* @brief Struct used for calibration * @brief Struct used for calibration
*/ */
@ -83,6 +87,11 @@ void tpCalibrate(void);
uint16_t tpReadZ(void); uint16_t tpReadZ(void);
#endif #endif
#if TOUCHPAD_STORE_CALIBRATION
extern void lld_tpWriteCalibration(struct cal cal);
extern struct cal lld_tpReadCalibration(void);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -143,6 +143,10 @@ void tpInit(const TOUCHPADDriver *tp) {
//MUTEX_ENTER //MUTEX_ENTER
tp_lld_init(tp); tp_lld_init(tp);
//MUTEX_EXIT //MUTEX_EXIT
#if TOUCHPAD_STORE_CALIBRATION
cal = lld_tpReadCalibration();
#endif
} }
/** /**
@ -222,6 +226,10 @@ void tpCalibrate(void) {
cal.xn = (float)cross[0][0] - cal.xm * (float)points[0][0]; cal.xn = (float)cross[0][0] - cal.xm * (float)points[0][0];
cal.yn = (float)cross[0][1] - cal.ym * (float)points[0][1]; cal.yn = (float)cross[0][1] - cal.ym * (float)points[0][1];
#if TOUCHPAD_STORE_CALIBRATION
lld_tpWriteCalibration(cal);
#endif
} }
#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) #if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__)