NXWidgets  1.19
Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
NxWM::CCalibration Class Reference

#include <ccalibration.hxx>

Inheritance diagram for NxWM::CCalibration:
Inheritance graph

Classes

struct  SCalibScreenInfo
 

Public Member Functions

 CCalibration (CTaskbar *taskbar, CFullScreenWindow *window, CTouchscreen *touchscreen)
 
 ~CCalibration (void)
 
IApplicationWindowgetWindow (void) const
 
NXWidgets::IBitmapgetIcon (void)
 
NXWidgets::CNxString getName (void)
 
bool run (void)
 
void stop (void)
 
void destroy (void)
 
void hide (void)
 
void redraw (void)
 
bool isFullScreen (void) const
 
- Public Member Functions inherited from NxWM::IApplication
virtual ~IApplication (void)
 
void setMinimized (bool minimized)
 
void setTopApplication (bool topapp)
 
bool isMinimized (void) const
 
bool isTopApplication (void) const
 

Private Types

enum  ECalThreadState {
  CALTHREAD_NOTRUNNING = 0, CALTHREAD_STARTED, CALTHREAD_RUNNING, CALTHREAD_STOPREQUESTED,
  CALTHREAD_HIDE, CALTHREAD_SHOW, CALTHREAD_TERMINATED
}
 
enum  ECalibrationPhase {
  CALPHASE_NOT_STARTED = 0, CALPHASE_UPPER_LEFT, CALPHASE_UPPER_RIGHT, CALPHASE_LOWER_RIGHT,
  CALPHASE_LOWER_LEFT, CALPHASE_COMPLETE
}
 

Private Member Functions

void touchscreenInput (struct touch_sample_s &sample)
 
bool createWidgets (void)
 
void destroyWidgets (void)
 
bool startCalibration (enum ECalThreadState initialState)
 
bool isRunning (void) const
 
bool isStarted (void) const
 
bool averageSamples (struct nxgl_point_s &average)
 
void stateMachine (void)
 
void showCalibration (void)
 
void finishCalibration (void)
 
bool createCalibrationData (struct SCalibrationData &data)
 

Static Private Member Functions

static FAR void * calibration (FAR void *arg)
 

Private Attributes

CTaskbarm_taskbar
 
CFullScreenWindowm_window
 
CTouchscreenm_touchscreen
 
NXWidgets::CLabelm_text
 
NXWidgets::CNxFontm_font
 
pthread_t m_thread
 
struct SCalibScreenInfo m_screenInfo
 
struct nxgl_point_s m_touchPos
 
volatile uint8_t m_calthread
 
uint8_t m_calphase
 
bool m_stop
 
bool m_touched
 
uint8_t m_touchId
 
uint8_t m_nsamples
 
struct nxgl_point_s m_sampleData [CONFIG_NXWM_CALIBRATION_NSAMPLES]
 
struct nxgl_point_s m_calibData [CALIB_DATA_POINTS]
 

Additional Inherited Members

- Protected Attributes inherited from NxWM::IApplication
bool m_minimized
 
bool m_topapp
 

Detailed Description

The CCalibration class provides the the calibration window and obtains callibration data.

Definition at line 123 of file ccalibration.hxx.

Member Enumeration Documentation

◆ ECalibrationPhase

enum NxWM::CCalibration::ECalibrationPhase
private

Identifies the current display state

Enumerator
CALPHASE_NOT_STARTED 

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

Definition at line 145 of file ccalibration.hxx.

◆ ECalThreadState

enum NxWM::CCalibration::ECalThreadState
private

The state of the calibration thread.

Enumerator
CALTHREAD_NOTRUNNING 

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

Definition at line 130 of file ccalibration.hxx.

Constructor & Destructor Documentation

◆ CCalibration()

CCalibration::CCalibration ( CTaskbar taskbar,
CFullScreenWindow window,
CTouchscreen touchscreen 
)

CCalibration Constructor

Parameters
taskbar.The taskbar instance used to terminate calibration
window.The window to use for the calibration display
touchscreen.An instance of the class that wraps the touchscreen device.

Definition at line 116 of file ccalibration.cxx.

◆ ~CCalibration()

CCalibration::~CCalibration ( void  )

CCalibration Destructor

Definition at line 142 of file ccalibration.cxx.

Member Function Documentation

◆ averageSamples()

bool CCalibration::averageSamples ( struct nxgl_point_s &  average)
private

Accumulate and average touch sample data

Parameters
average.When the averaged data is available, return it here
Returns
True: Average data is available; False: Need to collect more samples

Definition at line 694 of file ccalibration.cxx.

◆ calibration()

FAR void * CCalibration::calibration ( FAR void *  arg)
staticprivate

The calibration thread. This is the entry point of a thread that provides the calibration displays, waits for input, and collects calibration data.

Parameters
arg.The CCalibration 'this' pointer cast to a void*.
Returns
This function always returns NULL when the thread exits

Definition at line 582 of file ccalibration.cxx.

◆ createCalibrationData()

bool CCalibration::createCalibrationData ( struct SCalibrationData data)
private

Given the raw touch data collected by the calibration thread, create the massaged calibration data needed by CTouchscreen.

Parameters
data.A reference to the location to save the calibration data
Returns
True if the calibration data was successfully created.

Definition at line 1144 of file ccalibration.cxx.

◆ createWidgets()

bool CCalibration::createWidgets ( void  )
private

Create widgets need by the calibration thread.

Returns
True if the widgets were successfully created.

Definition at line 428 of file ccalibration.cxx.

◆ destroy()

void CCalibration::destroy ( void  )
virtual

Destroy the application and free all of its resources. This method will initiate blocking of messages from the NX server. The server will flush the window message queue and reply with the blocked message. When the block message is received by CWindowMessenger, it will send the destroy message to the start window task which will, finally, safely delete the application.

Implements NxWM::IApplication.

Definition at line 250 of file ccalibration.cxx.

◆ destroyWidgets()

void CCalibration::destroyWidgets ( void  )
private

Destroy widgets created for the calibration thread.

Definition at line 518 of file ccalibration.cxx.

◆ finishCalibration()

void CCalibration::finishCalibration ( void  )
private

Finish calibration steps and provide the calibration data to the touchscreen driver.

Definition at line 1095 of file ccalibration.cxx.

◆ getIcon()

NXWidgets::IBitmap * CCalibration::getIcon ( void  )
virtual

Get the icon associated with the application

Returns
An instance if IBitmap that may be used to rend the application's icon. This is an new IBitmap instance that must be deleted by the caller when it is no long needed.

Implements NxWM::IApplication.

Definition at line 173 of file ccalibration.cxx.

◆ getName()

NXWidgets::CNxString CCalibration::getName ( void  )
virtual

Get the name string associated with the application

Returns
A copy if CNxString that contains the name of the application.

Implements NxWM::IApplication.

Definition at line 187 of file ccalibration.cxx.

◆ getWindow()

IApplicationWindow * CCalibration::getWindow ( void  ) const
virtual

Each implementation of IApplication must provide a method to recover the contained IApplicationWindow instance.

Implements NxWM::IApplication.

Definition at line 160 of file ccalibration.cxx.

◆ hide()

void CCalibration::hide ( void  )
virtual

The application window is hidden (either it is minimized or it is maximized, but not at the top of the hierarchy

The application window is hidden (either it is minimized or it is maximized, but it is not at the top of the hierarchy)

Implements NxWM::IApplication.

Definition at line 266 of file ccalibration.cxx.

◆ isFullScreen()

bool CCalibration::isFullScreen ( void  ) const
virtual

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.

Returns
True if this is a full screen window.

Implements NxWM::IApplication.

Definition at line 331 of file ccalibration.cxx.

◆ isRunning()

bool NxWM::CCalibration::isRunning ( void  ) const
inlineprivate

Return true if the calibration thread is running normally. There are lots of potential race conditions. There are also two ambiguous states:

1) The thread may have been started but not yet running (CALTHREAD_STARTED), or the 2) The thread may been requested to terminate, but has not yet terminated (CALTHREAD_STOPREQUESTED)

Both of those states will cause isRunning() to return false.

Returns
True if the calibration thread is runnning normally.

Definition at line 239 of file ccalibration.hxx.

◆ isStarted()

bool NxWM::CCalibration::isStarted ( void  ) const
inlineprivate

Return true if the calibration thread is has been started and has not yet terminated. There is a potential race condition here when the thread has been requested to terminate, but has not yet terminated (CALTHREAD_STOPREQUESTED). isStarted() will return false in that case.

Returns
True if the calibration thread has been started and/or is running normally.

Definition at line 256 of file ccalibration.hxx.

◆ redraw()

void CCalibration::redraw ( void  )
virtual

Redraw the entire window. The application has been maximized or otherwise moved to the top of the hierarchy. This method is called from CTaskbar when the application window must be displayed

Implements NxWM::IApplication.

Definition at line 287 of file ccalibration.cxx.

◆ run()

bool CCalibration::run ( void  )
virtual

Start the application (perhaps in the minimized state).

Returns
True if the application was successfully started.

Implements NxWM::IApplication.

Definition at line 198 of file ccalibration.cxx.

◆ showCalibration()

void CCalibration::showCalibration ( void  )
private

Presents the next calibration screen

Presents the next calibration screen

Parameters
screenInfoDescribes the next calibration screen

Definition at line 1044 of file ccalibration.cxx.

◆ startCalibration()

bool CCalibration::startCalibration ( enum ECalThreadState  initialState)
private

Start the calibration thread.

Parameters
initialState.The initial state of the calibration thread
Returns
True if the thread was successfully started.

Definition at line 535 of file ccalibration.cxx.

◆ stateMachine()

void CCalibration::stateMachine ( void  )
private

This is the calibration state machine. It is called initially and then as new touchscreen data is received.

Definition at line 800 of file ccalibration.cxx.

◆ stop()

void CCalibration::stop ( void  )
virtual

Stop the application.

Implements NxWM::IApplication.

Definition at line 209 of file ccalibration.cxx.

◆ touchscreenInput()

void CCalibration::touchscreenInput ( struct touch_sample_s &  sample)
private

Accept raw touchscreen input.

Parameters
sampleTouchscreen input sample

Definition at line 342 of file ccalibration.cxx.

Member Data Documentation

◆ m_calibData

struct nxgl_point_s NxWM::CCalibration::m_calibData[CALIB_DATA_POINTS]
private

Definition at line 189 of file ccalibration.hxx.

◆ m_calphase

uint8_t NxWM::CCalibration::m_calphase
private

Current calibration display state (See ECalibrationPhase)

Definition at line 181 of file ccalibration.hxx.

◆ m_calthread

volatile uint8_t NxWM::CCalibration::m_calthread
private

Current calibration display state (See ECalibThreadState)

Definition at line 180 of file ccalibration.hxx.

◆ m_font

NXWidgets::CNxFont* NxWM::CCalibration::m_font
private

The font used in the message

Definition at line 175 of file ccalibration.hxx.

◆ m_nsamples

uint8_t NxWM::CCalibration::m_nsamples
private

Number of samples collected so far at this position

Definition at line 186 of file ccalibration.hxx.

◆ m_sampleData

struct nxgl_point_s NxWM::CCalibration::m_sampleData[CONFIG_NXWM_CALIBRATION_NSAMPLES]
private

Definition at line 187 of file ccalibration.hxx.

◆ m_screenInfo

struct SCalibScreenInfo NxWM::CCalibration::m_screenInfo
private

Describes the current calibration display

Definition at line 178 of file ccalibration.hxx.

◆ m_stop

bool NxWM::CCalibration::m_stop
private

True: We have been asked to stop the calibration

Definition at line 182 of file ccalibration.hxx.

◆ m_taskbar

CTaskbar* NxWM::CCalibration::m_taskbar
private

CCalibration state dataThe taskbar (used to terminate calibration)

Definition at line 170 of file ccalibration.hxx.

◆ m_text

NXWidgets::CLabel* NxWM::CCalibration::m_text
private

Calibration message

Definition at line 174 of file ccalibration.hxx.

◆ m_thread

pthread_t NxWM::CCalibration::m_thread
private

The calibration thread ID

Definition at line 177 of file ccalibration.hxx.

◆ m_touched

bool NxWM::CCalibration::m_touched
private

True: The screen is touched

Definition at line 183 of file ccalibration.hxx.

◆ m_touchId

uint8_t NxWM::CCalibration::m_touchId
private

The ID of the touch

Definition at line 184 of file ccalibration.hxx.

◆ m_touchPos

struct nxgl_point_s NxWM::CCalibration::m_touchPos
private

This is the last touch position

Definition at line 179 of file ccalibration.hxx.

◆ m_touchscreen

CTouchscreen* NxWM::CCalibration::m_touchscreen
private

The touchscreen device

Definition at line 172 of file ccalibration.hxx.

◆ m_window

CFullScreenWindow* NxWM::CCalibration::m_window
private

The window for the calibration display

Definition at line 171 of file ccalibration.hxx.


The documentation for this class was generated from the following files: