mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 02:23:34 +08:00
NxWM: Calibration is now done on a separate thread; Change mechanism for reporting calibration data; add method to determine if the application is full-screen
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4736 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -158,6 +158,16 @@ namespace NxWM
|
||||
|
||||
void setWindowLabel(NXWidgets::CNxString &appname);
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
bool isFullScreen(void) const;
|
||||
|
||||
/**
|
||||
* Register to receive callbacks when toolbar icons are selected
|
||||
*/
|
||||
|
||||
@@ -42,12 +42,14 @@
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <fixedmath.h>
|
||||
|
||||
#include "cnxstring.hxx"
|
||||
#include "cwidgeteventhandler.hxx"
|
||||
#include "cwidgetcontrol.hxx"
|
||||
|
||||
#include "ctaskbar.hxx"
|
||||
#include "iapplication.hxx"
|
||||
#include "cfullscreenwindow.hxx"
|
||||
|
||||
@@ -97,18 +99,33 @@ namespace NxWM
|
||||
class CCalibration : public IApplication
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The state of the calibration thread.
|
||||
*/
|
||||
|
||||
enum ECalThreadState
|
||||
{
|
||||
CALTHREAD_NOTRUNNING = 0, /**< The calibration thread has not yet been started */
|
||||
CALTHREAD_STARTED, /**< The calibration thread has been started, but is not yet running */
|
||||
CALTHREAD_RUNNING, /**< The calibration thread is running normally */
|
||||
CALTHREAD_STOPREQUESTED, /**< The calibration thread has been requested to stop */
|
||||
CALTHREAD_HIDE, /**< The hide() called by calibration thread running */
|
||||
CALTHREAD_SHOW, /**< The redraw() called by calibration thread running */
|
||||
CALTHREAD_TERMINATED /**< The calibration thread terminated normally */
|
||||
};
|
||||
|
||||
/**
|
||||
* Identifies the current display state
|
||||
*/
|
||||
|
||||
enum ECalibState
|
||||
enum ECalibrationPhase
|
||||
{
|
||||
CALIB_NOT_STARTED = 0, /**< Constructed, but not yet started */
|
||||
CALIB_UPPER_LEFT, /**< Touch point is in the upper left corner */
|
||||
CALIB_UPPER_RIGHT, /**< Touch point is in the upper right corner */
|
||||
CALIB_LOWER_RIGHT, /**< Touch point is in the lower left corner */
|
||||
CALIB_LOWER_LEFT, /**< Touch point is in the lower right corner */
|
||||
CALIB_COMPLETE /**< Calibration is complete */
|
||||
CALPHASE_NOT_STARTED = 0, /**< Constructed, but not yet started */
|
||||
CALPHASE_UPPER_LEFT, /**< Touch point is in the upper left corner */
|
||||
CALPHASE_UPPER_RIGHT, /**< Touch point is in the upper right corner */
|
||||
CALPHASE_LOWER_RIGHT, /**< Touch point is in the lower left corner */
|
||||
CALPHASE_LOWER_LEFT, /**< Touch point is in the lower right corner */
|
||||
CALPHASE_COMPLETE /**< Calibration is complete */
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -126,15 +143,17 @@ namespace NxWM
|
||||
* CCalibration state data
|
||||
*/
|
||||
|
||||
CTaskbar *m_taskbar; /**< The taskbar (used to terminate calibration) */
|
||||
CFullScreenWindow *m_window; /**< The window for the calibration display */
|
||||
CTouchscreen *m_touchscreen; /**< The touchscreen device */
|
||||
enum ECalibState m_state; /**< Current calibration display state */
|
||||
pthread_t m_thread; /**< The calibration thread ID */
|
||||
struct SCalibScreenInfo m_screenInfo; /**< Describes the current calibration display */
|
||||
struct nxgl_point_s m_touchPos; /**< This is the last touch position */
|
||||
volatile uint8_t m_calthread; /**< Current calibration display state (See ECalibThreadState)*/
|
||||
uint8_t m_calphase; /**< Current calibration display state (See ECalibrationPhase)*/
|
||||
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 */
|
||||
sem_t m_waitSem; /**< Supports wait for calibration data */
|
||||
struct nxgl_point_s m_calibData[CALIB_DATA_POINTS];
|
||||
|
||||
/**
|
||||
@@ -145,6 +164,42 @@ namespace NxWM
|
||||
|
||||
void touchscreenInput(struct touch_sample_s &sample);
|
||||
|
||||
/**
|
||||
* Start the calibration thread.
|
||||
*
|
||||
* @param initialState. The initial state of the calibration thread
|
||||
* @return True if the thread was successfully started.
|
||||
*/
|
||||
|
||||
bool startCalibration(enum ECalThreadState initialState);
|
||||
|
||||
/**
|
||||
* Return true if the calibration thread is running normally. There are
|
||||
* lots of potential race conditions. Let's hope that things are running
|
||||
* orderly and we that we do not have to concern ourself with them
|
||||
*
|
||||
* @return True if the calibration thread is runnning normally.
|
||||
*/
|
||||
|
||||
inline bool isRunning(void) const
|
||||
{
|
||||
// What if the boundary states CALTHREAD_STARTED and CALTHREAD_STOPREQUESTED?
|
||||
|
||||
return (m_calthread == CALTHREAD_RUNNING ||
|
||||
m_calthread == CALTHREAD_HIDE ||
|
||||
m_calthread == CALTHREAD_SHOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* The calibration thread. This is the entry point of a thread that provides the
|
||||
* calibration displays, waits for input, and collects calibration data.
|
||||
*
|
||||
* @param arg. The CCalibration 'this' pointer cast to a void*.
|
||||
* @return This function always returns NULL when the thread exits
|
||||
*/
|
||||
|
||||
static FAR void *calibration(FAR void *arg);
|
||||
|
||||
/**
|
||||
* This is the calibration state machine. It is called initially and then
|
||||
* as new touchscreen data is received.
|
||||
@@ -158,16 +213,36 @@ namespace NxWM
|
||||
|
||||
void showCalibration(void);
|
||||
|
||||
/**
|
||||
* Finish calibration steps and provide the calibration data to the
|
||||
* touchscreen driver.
|
||||
*/
|
||||
|
||||
void finishCalibration(void);
|
||||
|
||||
/**
|
||||
* Given the raw touch data collected by the calibration thread, create the
|
||||
* massaged calibration data needed by CTouchscreen.
|
||||
*
|
||||
* @param data. A reference to the location to save the calibration data
|
||||
* @return True if the calibration data was successfully created.
|
||||
*/
|
||||
|
||||
bool createCalibrationData(struct SCalibrationData &data);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* CCalibration Constructor
|
||||
*
|
||||
* @param taskbar. The taskbar instance used to terminate calibration
|
||||
* @param window. The window to use for the calibration display
|
||||
* @param touchscreen. An instance of the class that wraps the touchscreen device.
|
||||
* @param touchscreen. An instance of the class that wraps the
|
||||
* touchscreen device.
|
||||
*/
|
||||
|
||||
CCalibration(CFullScreenWindow *window, CTouchscreen *touchscreen);
|
||||
CCalibration(CTaskbar *taskbar, CFullScreenWindow *window,
|
||||
CTouchscreen *touchscreen);
|
||||
|
||||
/**
|
||||
* CCalibration Destructor
|
||||
@@ -230,12 +305,14 @@ namespace NxWM
|
||||
void redraw(void);
|
||||
|
||||
/**
|
||||
* Wait for calibration data to be received.
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if the calibration data was successfully obtained.
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
bool waitCalibrationData(struct SCalibrationData &data);
|
||||
bool isFullScreen(void) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,16 @@ namespace NxWM
|
||||
|
||||
void setWindowLabel(NXWidgets::CNxString &appname);
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
bool isFullScreen(void) const;
|
||||
|
||||
/**
|
||||
* Register to receive callbacks when toolbar icons are selected
|
||||
*/
|
||||
|
||||
@@ -173,6 +173,16 @@ namespace NxWM
|
||||
*/
|
||||
|
||||
void redraw(void);
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
bool isFullScreen(void) const;
|
||||
};
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
@@ -188,6 +188,16 @@ namespace NxWM
|
||||
|
||||
void redraw(void);
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
bool isFullScreen(void) const;
|
||||
|
||||
/**
|
||||
* Add the application to the start window. The general sequence for
|
||||
* setting up the start window is:
|
||||
|
||||
@@ -166,6 +166,17 @@ namespace NxWM
|
||||
m_enabled = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the touchscreen calibrated?
|
||||
*
|
||||
* @return True if the touchscreen has been calibrated.
|
||||
*/
|
||||
|
||||
inline bool isCalibrated(void) const
|
||||
{
|
||||
return m_calibrated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide touchscreen calibration data. If calibration data is received (and
|
||||
* the touchscreen is enabled), then received touchscreen data will be scaled
|
||||
@@ -175,7 +186,23 @@ namespace NxWM
|
||||
* @param data. A reference to the touchscreen data.
|
||||
*/
|
||||
|
||||
void setCalibrationData(struct SCalibrationData &caldata);
|
||||
void setCalibrationData(const struct SCalibrationData &caldata);
|
||||
|
||||
/**
|
||||
* Recover the calibration data so that it can be saved to non-volatile storage.
|
||||
*
|
||||
* @param data. A reference to the touchscreen data.
|
||||
* @return True if calibration data was successfully returned.
|
||||
*/
|
||||
|
||||
inline bool getCalibrationData(struct SCalibrationData &caldata) const
|
||||
{
|
||||
if (m_calibrated)
|
||||
{
|
||||
caldata = m_calibData;
|
||||
}
|
||||
return m_calibrated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture raw driver data. This method will capture mode one raw touchscreen
|
||||
|
||||
@@ -170,6 +170,16 @@ namespace NxWM
|
||||
{
|
||||
return m_topapp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
virtual bool isFullScreen(void) const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +129,16 @@ namespace NxWM
|
||||
|
||||
virtual void setWindowLabel(NXWidgets::CNxString &appname) = 0;
|
||||
|
||||
/**
|
||||
* Report of this is a "normal" window or a full screen window. The
|
||||
* primary purpose of this method is so that window manager will know
|
||||
* whether or not it show draw the task bar.
|
||||
*
|
||||
* @return True if this is a full screen window.
|
||||
*/
|
||||
|
||||
virtual bool isFullScreen(void) const = 0;
|
||||
|
||||
/**
|
||||
* Register to receive callbacks when toolbar icons are selected
|
||||
*/
|
||||
|
||||
@@ -333,6 +333,10 @@
|
||||
* Default: "/dev/input0"
|
||||
* CONFIG_NXWM_TOUCHSCREEN_SIGNO - The realtime signal used to wake up the
|
||||
* touchscreen listener thread. Default: 5
|
||||
* CONFIG_NXWM_TOUCHSCREEN_LISTENERPRIO - Priority of the touchscreen listener
|
||||
* thread. Default: SCHED_PRIORITY_DEFAULT
|
||||
* CONFIG_NXWM_TOUCHSCREEN_LISTENERSTACK - Touchscreen listener thread stack
|
||||
* size. Default 2048
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWM_TOUCHSCREEN_DEVNO
|
||||
@@ -347,6 +351,14 @@
|
||||
# define CONFIG_NXWM_TOUCHSCREEN_SIGNO 5
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWM_TOUCHSCREEN_LISTENERPRIO
|
||||
# define CONFIG_NXWM_TOUCHSCREEN_LISTENERPRIO SCHED_PRIORITY_DEFAULT
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWM_TOUCHSCREEN_LISTENERSTACK
|
||||
# define CONFIG_NXWM_TOUCHSCREEN_LISTENERSTACK 2048
|
||||
#endif
|
||||
|
||||
/* Calibration display ******************************************************/
|
||||
/**
|
||||
* Calibration display settings:
|
||||
@@ -363,6 +375,12 @@
|
||||
* MKRGB(255, 255, 96) (very light yellow)
|
||||
* CONFIG_NXWM_CALIBRATION_ICON - The ICON to use for the touchscreen
|
||||
* calibration application. Default: NxWM::g_calibrationBitmap
|
||||
* CONFIG_NXWM_CALIBRATION_SIGNO - The realtime signal used to wake up the
|
||||
* touchscreen calibration thread. Default: 5
|
||||
* CONFIG_NXWM_CALIBRATION_LISTENERPRIO - Priority of the touchscreen listener
|
||||
* thread. Default: SCHED_PRIORITY_DEFAULT
|
||||
* CONFIG_NXWM_CALIBRATION_LISTENERSTACK - Touchscreen listener thread stack
|
||||
* size. Default 2048
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR
|
||||
@@ -385,6 +403,18 @@
|
||||
# define CONFIG_NXWM_CALIBRATION_ICON NxWM::g_calibrationBitmap
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWM_CALIBRATION_SIGNO
|
||||
# define CONFIG_NXWM_CALIBRATION_SIGNO 5
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWM_CALIBRATION_LISTENERPRIO
|
||||
# define CONFIG_NXWM_CALIBRATION_LISTENERPRIO SCHED_PRIORITY_DEFAULT
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWM_CALIBRATION_LISTENERSTACK
|
||||
# define CONFIG_NXWM_CALIBRATION_LISTENERSTACK 2048
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Global Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user