diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-10-14 18:35:23 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-10-14 18:35:23 -0600 |
commit | b5a37a3e45ac9faea285cc252e742c1c7267a6d7 (patch) | |
tree | 678ad7a3d43ff4bdbc9a5ba2bc280ad9dcfea2b6 /NxWidgets/nxwm/include | |
parent | c4bd33095126562d1f54c63187288d98bf2c4eec (diff) | |
download | px4-nuttx-b5a37a3e45ac9faea285cc252e742c1c7267a6d7.tar.gz px4-nuttx-b5a37a3e45ac9faea285cc252e742c1c7267a6d7.tar.bz2 px4-nuttx-b5a37a3e45ac9faea285cc252e742c1c7267a6d7.zip |
NxWM::CCalibration: Add logic to collect and average samples, optionally discarding the most extreem values
Diffstat (limited to 'NxWidgets/nxwm/include')
-rw-r--r-- | NxWidgets/nxwm/include/ccalibration.hxx | 31 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/nxwmconfig.hxx | 30 |
2 files changed, 61 insertions, 0 deletions
diff --git a/NxWidgets/nxwm/include/ccalibration.hxx b/NxWidgets/nxwm/include/ccalibration.hxx index 376462ca8..30a48f7eb 100644 --- a/NxWidgets/nxwm/include/ccalibration.hxx +++ b/NxWidgets/nxwm/include/ccalibration.hxx @@ -160,6 +160,10 @@ namespace NxWM bool m_stop; /**< True: We have been asked to stop the calibration */ bool m_touched; /**< True: The screen is touched */ uint8_t m_touchId; /**< The ID of the touch */ +#if CONFIG_NXWM_CALIBRATION_AVERAGE + uint8_t m_nsamples; /**< Number of samples collected so far at this position */ + struct nxgl_point_s m_sampleData[CONFIG_NXWM_CALIBRATION_NSAMPLES]; +#endif struct nxgl_point_s m_calibData[CALIB_DATA_POINTS]; /** @@ -170,6 +174,22 @@ namespace NxWM void touchscreenInput(struct touch_sample_s &sample); +#ifdef CONFIG_NXWM_CALIBRATION_MESSAGES + /** + * Create widgets need by the calibration thread. + * + * @return True if the widgets were successfully created. + */ + + bool createWidgets(void); + + /** + * Destroy widgets created for the calibration thread. + */ + + void destroyWidgets(void); +#endif + /** * Start the calibration thread. * @@ -230,6 +250,17 @@ namespace NxWM static FAR void *calibration(FAR void *arg); /** + * Accumulate and average touch sample data + * + * @param average. When the averaged data is available, return it here + * @return True: Average data is available; False: Need to collect more samples + */ + +#if CONFIG_NXWM_CALIBRATION_AVERAGE + bool averageSamples(struct nxgl_point_s &average); +#endif + + /** * This is the calibration state machine. It is called initially and then * as new touchscreen data is received. */ diff --git a/NxWidgets/nxwm/include/nxwmconfig.hxx b/NxWidgets/nxwm/include/nxwmconfig.hxx index 65384341b..6e540fefc 100644 --- a/NxWidgets/nxwm/include/nxwmconfig.hxx +++ b/NxWidgets/nxwm/include/nxwmconfig.hxx @@ -526,6 +526,36 @@ # define CONFIG_NXWM_CALIBRATION_MARGIN 40 #endif +// Calibration sample averaging + +#ifndef CONFIG_NXWM_CALIBRATION_AVERAGE +# undef CONFIG_NXWM_CALIBRATION_AVERAGE +# undef CONFIG_NXWM_CALIBRATION_NSAMPLES +# define CONFIG_NXWM_CALIBRATION_NSAMPLES 1 +# undef CONFIG_NXWM_CALIBRATION_DISCARD_MINMAX +#endif + +#if !defined(CONFIG_NXWM_CALIBRATION_NSAMPLES) || CONFIG_NXWM_CALIBRATION_NSAMPLES < 2 +# undef CONFIG_NXWM_CALIBRATION_AVERAGE +# undef CONFIG_NXWM_CALIBRATION_NSAMPLES +# define CONFIG_NXWM_CALIBRATION_NSAMPLES 1 +# undef CONFIG_NXWM_CALIBRATION_DISCARD_MINMAX +#endif + +#if CONFIG_NXWM_CALIBRATION_NSAMPLES < 3 +# undef CONFIG_NXWM_CALIBRATION_DISCARD_MINMAX +#endif + +#if CONFIG_NXWM_CALIBRATION_NSAMPLES > 255 +# define CONFIG_NXWM_CALIBRATION_NSAMPLES 255 +#endif + +#ifdef CONFIG_NXWM_CALIBRATION_DISCARD_MINMAX +# define NXWM_CALIBRATION_NAVERAGE (CONFIG_NXWM_CALIBRATION_NSAMPLES - 2) +#else +# define NXWM_CALIBRATION_NAVERAGE CONFIG_NXWM_CALIBRATION_NSAMPLES +#endif + /* Hexcalculator applications ***********************************************/ /** * Calibration display settings: |