diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-10 01:35:23 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-10 01:35:23 +0000 |
commit | 2bfda8161a877d7e618a37353f806981c0ab4a4b (patch) | |
tree | ed24ca0b53d7c523a4d09b961329fd081234457e | |
parent | 6b32872462ba7e069df10760d89806a9ae895006 (diff) | |
download | px4-nuttx-2bfda8161a877d7e618a37353f806981c0ab4a4b.tar.gz px4-nuttx-2bfda8161a877d7e618a37353f806981c0ab4a4b.tar.bz2 px4-nuttx-2bfda8161a877d7e618a37353f806981c0ab4a4b.zip |
More NxWM touchscreen fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4719 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r-- | NxWidgets/UnitTests/nxwm/main.cxx | 95 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/ccalibration.hxx | 10 | ||||
-rw-r--r-- | NxWidgets/nxwm/include/ctouchscreen.hxx | 5 | ||||
-rw-r--r-- | NxWidgets/nxwm/src/ccalibration.cxx | 2 | ||||
-rw-r--r-- | nuttx/arch/sim/src/up_touchscreen.c | 1 |
5 files changed, 70 insertions, 43 deletions
diff --git a/NxWidgets/UnitTests/nxwm/main.cxx b/NxWidgets/UnitTests/nxwm/main.cxx index 09744c8a6..e7a16727d 100644 --- a/NxWidgets/UnitTests/nxwm/main.cxx +++ b/NxWidgets/UnitTests/nxwm/main.cxx @@ -198,6 +198,35 @@ static void initMemoryUsage(void) } ///////////////////////////////////////////////////////////////////////////// +// Name: cleanup +///////////////////////////////////////////////////////////////////////////// + +static void test_cleanup(void) +{ +#ifdef CONFIG_NXWM_TOUCHSCREEN + if (g_nxwmtest.touchscreen) + { + delete g_nxwmtest.touchscreen; + } +#endif + + // Delete the task bar then the start window. the order is important because + // we must bet all of the application references out of the task bar before + // deleting the start window. When the start window is deleted, it will + // also delete of of the resouces contained within the start window. + + if (g_nxwmtest.taskbar) + { + delete g_nxwmtest.taskbar; + } + + if (g_nxwmtest.startwindow) + { + delete g_nxwmtest.startwindow; + } +} + +///////////////////////////////////////////////////////////////////////////// // Public Functions ///////////////////////////////////////////////////////////////////////////// @@ -270,7 +299,7 @@ int MAIN_NAME(int argc, char *argv[]) if (!g_nxwmtest.taskbar->connect()) { printf(MAIN_STRING "ERROR: Failed to connect the CTaskbar instance to the NX server\n"); - delete g_nxwmtest.taskbar; + test_cleanup(); return EXIT_FAILURE; } showTestCaseMemory("After connecting to the server"); @@ -285,7 +314,7 @@ int MAIN_NAME(int argc, char *argv[]) if (!g_nxwmtest.taskbar->initWindowManager()) { printf(MAIN_STRING "ERROR: Failed to intialize the CTaskbar instance\n"); - delete g_nxwmtest.taskbar; + test_cleanup(); return EXIT_FAILURE; } showTestCaseMemory("After initializing window manager"); @@ -304,7 +333,7 @@ int MAIN_NAME(int argc, char *argv[]) if (!window) { printf(MAIN_STRING "ERROR: Failed to create CApplicationWindow for the start window\n"); - delete g_nxwmtest.taskbar; + test_cleanup(); return EXIT_FAILURE; } showTestCaseMemory("After creating start window application window"); @@ -314,7 +343,7 @@ int MAIN_NAME(int argc, char *argv[]) { printf(MAIN_STRING "ERROR: Failed to open the CApplicationWindow \n"); delete window; - delete g_nxwmtest.taskbar; + test_cleanup(); return EXIT_FAILURE; } showTestCaseMemory("After initializing the start window application window"); @@ -325,13 +354,26 @@ int MAIN_NAME(int argc, char *argv[]) { printf(MAIN_STRING "ERROR: Failed to instantiate CStartWindow\n"); delete window; - delete g_nxwmtest.taskbar; + test_cleanup(); return EXIT_FAILURE; } showTestCaseMemory("After create the start window application"); // Perform touchscreen calibration -#if 0 // defined(CONFIG_NXWM_TOUCHSCREEN) -- Not ready for prime time + +#ifdef CONFIG_NXWM_TOUCHSCREEN + // Start the window manager before adding applications + + printf(MAIN_STRING "Start the window manager\n"); + if (!g_nxwmtest.taskbar->startWindowManager()) + { + printf(MAIN_STRING "ERROR: Failed to start the window manager\n"); + test_cleanup(); + return EXIT_FAILURE; + } + showTestCaseMemory("After starting the window manager"); + + // Perform touchscreen calibration NxWM::CCalibration *calibration = (NxWM::CCalibration *)0; // Avoid compiler complaint NxWM::CFullScreenWindow *fullscreen = (NxWM::CFullScreenWindow *)0; // Avoid compiler complaint @@ -340,7 +382,7 @@ int MAIN_NAME(int argc, char *argv[]) printf(MAIN_STRING "Creating CTouchscreen\n"); g_nxwmtest.touchscreen = new NxWM::CTouchscreen; - if (!touchscreen) + if (!g_nxwmtest.touchscreen) { printf(MAIN_STRING "ERROR: Failed to create CTouchscreen\n"); goto nocalibration; @@ -395,7 +437,7 @@ int MAIN_NAME(int argc, char *argv[]) if (!g_nxwmtest.startwindow->addApplication(calibration)) { printf(MAIN_STRING "ERROR: Failed to add CCalibration to the start window\n"); - delete fullscreen; + delete calibration; goto nocalibration; } showTestCaseMemory("After adding the CCalibration application"); @@ -406,11 +448,19 @@ int MAIN_NAME(int argc, char *argv[]) if (!g_nxwmtest.taskbar->startApplication(calibration, false)) { printf(MAIN_STRING "ERROR: Failed to start the calibration application\n"); - delete fullscreen; goto nocalibration; } showTestCaseMemory("After starting the start window application"); + // Wait for calibration data + + printf(MAIN_STRING "Get calibration data\n"); + struct NxWM::SCalibrationData data; + if (!calibration->waitCalibrationData(data)) + { + printf(MAIN_STRING "ERROR: Failed to get calibration data\n"); + } + nocalibration: #endif @@ -432,8 +482,7 @@ nocalibration: { printf(MAIN_STRING "ERROR: Failed to open the CApplicationWindow \n"); delete window; - delete g_nxwmtest.taskbar; - return EXIT_FAILURE; + goto noconsole; } showTestCaseMemory("After initializing the NxConsole application window"); @@ -476,7 +525,7 @@ noconsole: { printf(MAIN_STRING "ERROR: Failed to open the CApplicationWindow \n"); delete window; - delete g_nxwmtest.taskbar; + test_cleanup(); return EXIT_FAILURE; } showTestCaseMemory("After creating the initializing application window"); @@ -509,35 +558,23 @@ nocalculator: if (!g_nxwmtest.taskbar->startApplication(g_nxwmtest.startwindow, true)) { printf(MAIN_STRING "ERROR: Failed to start the start window application\n"); - - // Delete the task bar then the start window. the order is important because - // we must bet all of the application references out of the task bar before - // deleting the start window. When the start window is deleted, it will - // also delete of of the resouces contained within the start window. - - delete g_nxwmtest.taskbar; - delete g_nxwmtest.startwindow; + test_cleanup(); return EXIT_FAILURE; } showTestCaseMemory("After starting the start window application"); // Call CTaskBar::startWindowManager to start the display with applications in place. +#ifndef CONFIG_NXWM_TOUCHSCREEN printf(MAIN_STRING "Start the window manager\n"); if (!g_nxwmtest.taskbar->startWindowManager()) { printf(MAIN_STRING "ERROR: Failed to start the window manager\n"); - - // Delete the task bar then the start window. the order is important because - // we must bet all of the application references out of the task bar before - // deleting the start window. When the start window is deleted, it will - // also delete of of the resouces contained within the start window. - - delete g_nxwmtest.taskbar; - delete g_nxwmtest.startwindow; + test_cleanup(); return EXIT_FAILURE; } showTestCaseMemory("After starting the window manager"); +#endif // Wait a little bit for the display to stabilize. The simulation pressing of // the 'start window' icon in the task bar @@ -559,6 +596,6 @@ nocalculator: sleep(2); showTestMemory("Final memory usage"); - return EXIT_SUCCESS; + return EXIT_SUCCESS; } diff --git a/NxWidgets/nxwm/include/ccalibration.hxx b/NxWidgets/nxwm/include/ccalibration.hxx index 9ca5b7589..0adcd894f 100644 --- a/NxWidgets/nxwm/include/ccalibration.hxx +++ b/NxWidgets/nxwm/include/ccalibration.hxx @@ -89,7 +89,7 @@ namespace NxWM * callibration data. */ - class CCalibration : public IApplication, private NXWidgets::CWidgetEventHandler + class CCalibration : public IApplication { private: /** @@ -147,14 +147,6 @@ namespace NxWM void stateMachine(void); /** - * Handle a mouse button click event. - * - * @param e The event data. - */ - - void handleClickEvent(const NXWidgets::CWidgetEventArgs &e); - - /** * Presents the next calibration screen */ diff --git a/NxWidgets/nxwm/include/ctouchscreen.hxx b/NxWidgets/nxwm/include/ctouchscreen.hxx index 31c61623b..f8eaeaee8 100644 --- a/NxWidgets/nxwm/include/ctouchscreen.hxx +++ b/NxWidgets/nxwm/include/ctouchscreen.hxx @@ -45,9 +45,6 @@ #include <semaphore.h> #include <nuttx/input/touchscreen.h> -#include "cwidgeteventhandler.hxx" -#include "iapplication.hxx" - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -63,7 +60,7 @@ namespace NxWM * callibration data. */ - class CTouchscreen : public IApplication, private NXWidgets::CWidgetEventHandler + class CTouchscreen { private: int m_touchFd; /**< File descriptor of the opened touchscreen device */ diff --git a/NxWidgets/nxwm/src/ccalibration.cxx b/NxWidgets/nxwm/src/ccalibration.cxx index 2ca132dac..e218b5f1e 100644 --- a/NxWidgets/nxwm/src/ccalibration.cxx +++ b/NxWidgets/nxwm/src/ccalibration.cxx @@ -156,7 +156,7 @@ bool CCalibration::run(void) // Loop until calibration completes - while (!m_stop) + while (!m_stop && m_state != CALIB_COMPLETE) { // Wait for the next raw touchscreen input diff --git a/nuttx/arch/sim/src/up_touchscreen.c b/nuttx/arch/sim/src/up_touchscreen.c index f89371cbf..53e8e0d0d 100644 --- a/nuttx/arch/sim/src/up_touchscreen.c +++ b/nuttx/arch/sim/src/up_touchscreen.c @@ -55,6 +55,7 @@ #include <nuttx/kmalloc.h> #include <nuttx/arch.h> #include <nuttx/fs/fs.h> +#include <nuttx/nx/nx.h> #include <nuttx/input/touchscreen.h> |