2012-04-30 22:38:44 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2012-09-14 17:23:54 +02:00
|
|
|
// NxWidgets/UnitTests/nxwm/nxwm_main.cxx
|
2012-04-30 22:38:44 +02:00
|
|
|
//
|
|
|
|
// Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
|
|
|
// Author: Gregory Nutt <gnutt@nuttx.org>
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions
|
|
|
|
// are met:
|
|
|
|
//
|
|
|
|
// 1. Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer in
|
|
|
|
// the documentation and/or other materials provided with the
|
|
|
|
// distribution.
|
|
|
|
// 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
|
|
|
|
// me be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Included Files
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2012-05-01 16:52:54 +02:00
|
|
|
#include <nuttx/arch.h>
|
2012-04-30 22:38:44 +02:00
|
|
|
|
2012-05-01 22:36:19 +02:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
2012-05-03 00:03:05 +02:00
|
|
|
#include <cunistd>
|
2012-05-01 22:36:19 +02:00
|
|
|
|
2013-10-31 00:16:58 +01:00
|
|
|
#ifdef CONFIG_NXWM_TOUCHSCREEN_CONFIGDATA
|
|
|
|
# include <apps/platform/configdata.h>
|
2013-10-30 17:11:43 +01:00
|
|
|
#endif
|
|
|
|
|
2012-04-30 22:38:44 +02:00
|
|
|
#include "ctaskbar.hxx"
|
|
|
|
#include "cstartwindow.hxx"
|
2013-12-30 17:04:34 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_NXWM_NXCONSOLE
|
|
|
|
# include "cnxconsole.hxx"
|
|
|
|
#endif
|
|
|
|
|
2012-05-22 21:29:22 +02:00
|
|
|
#include "chexcalculator.hxx"
|
2012-04-30 22:38:44 +02:00
|
|
|
|
2013-05-12 00:15:51 +02:00
|
|
|
#ifdef CONFIG_NXWM_MEDIAPLAYER
|
2013-10-30 17:11:43 +01:00
|
|
|
# include "cmediaplayer.hxx"
|
2013-05-12 00:15:51 +02:00
|
|
|
#endif
|
|
|
|
|
2012-05-19 01:08:34 +02:00
|
|
|
#ifdef CONFIG_NXWM_TOUCHSCREEN
|
|
|
|
# include "ctouchscreen.hxx"
|
|
|
|
# include "ccalibration.hxx"
|
|
|
|
#endif
|
|
|
|
|
2012-05-21 00:10:34 +02:00
|
|
|
#ifdef CONFIG_NXWM_KEYBOARD
|
|
|
|
# include "ckeyboard.hxx"
|
|
|
|
#endif
|
|
|
|
|
2012-04-30 22:38:44 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Pre-processor Definitions
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-03 21:46:37 +02:00
|
|
|
#ifdef CONFIG_HAVE_FILENAME
|
|
|
|
# define showTestStepMemory(msg) \
|
|
|
|
_showTestStepMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
|
2012-05-19 01:08:34 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_NXWIDGET_MEMMONITOR
|
|
|
|
# ifdef CONFIG_HAVE_FILENAME
|
|
|
|
# define showTestCaseMemory(msg) \
|
|
|
|
_showTestCaseMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
|
|
|
|
# define showTestMemory(msg) \
|
|
|
|
_showTestMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# define initMemoryUsage()
|
|
|
|
# define showTestCaseMemory(msg)
|
|
|
|
# define showTestMemory(msg)
|
2012-05-03 21:46:37 +02:00
|
|
|
#endif
|
|
|
|
|
2012-04-30 22:38:44 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Private Types
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-01 22:36:19 +02:00
|
|
|
struct SNxWmTest
|
2012-04-30 22:38:44 +02:00
|
|
|
{
|
2012-05-12 00:07:06 +02:00
|
|
|
NxWM::CTaskbar *taskbar; // The task bar
|
|
|
|
NxWM::CStartWindow *startwindow; // The start window
|
2012-05-10 00:30:19 +02:00
|
|
|
#ifdef CONFIG_NXWM_TOUCHSCREEN
|
2012-05-12 00:07:06 +02:00
|
|
|
NxWM::CTouchscreen *touchscreen; // The touchscreen
|
|
|
|
struct NxWM::SCalibrationData calibData; // Calibration data
|
2013-10-30 17:11:43 +01:00
|
|
|
bool calibrated; // True: Touchscreen has been calibrated
|
2012-05-10 00:30:19 +02:00
|
|
|
#endif
|
2012-05-19 01:08:34 +02:00
|
|
|
#ifdef CONFIG_NXWIDGET_MEMMONITOR
|
2012-05-12 00:07:06 +02:00
|
|
|
unsigned int mmInitial; // Initial memory usage
|
|
|
|
unsigned int mmStep; // Memory Usage at beginning of test step
|
|
|
|
unsigned int mmSubStep; // Memory Usage at beginning of test sub-step
|
2012-05-19 01:08:34 +02:00
|
|
|
#endif
|
2012-04-30 22:38:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Private Data
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-01 22:36:19 +02:00
|
|
|
static struct SNxWmTest g_nxwmtest;
|
2012-04-30 22:38:44 +02:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Public Function Prototypes
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Suppress name-mangling
|
|
|
|
|
2012-09-14 17:23:54 +02:00
|
|
|
extern "C" int nxwm_main(int argc, char *argv[]);
|
2012-04-30 22:38:44 +02:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Public Functions
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-03 21:46:37 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: updateMemoryUsage
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-19 01:08:34 +02:00
|
|
|
#ifdef CONFIG_NXWIDGET_MEMMONITOR
|
2012-05-03 21:46:37 +02:00
|
|
|
#ifdef CONFIG_HAVE_FILENAME
|
|
|
|
static void updateMemoryUsage(unsigned int *previous,
|
|
|
|
FAR const char *file, int line,
|
|
|
|
FAR const char *msg)
|
|
|
|
#else
|
|
|
|
static void updateMemoryUsage(unsigned int *previous,
|
|
|
|
FAR const char *msg)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
struct mallinfo mmcurrent;
|
|
|
|
|
|
|
|
/* Get the current memory usage */
|
|
|
|
|
|
|
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
|
|
|
mmcurrent = mallinfo();
|
|
|
|
#else
|
|
|
|
(void)mallinfo(&mmcurrent);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Show the change from the previous time */
|
|
|
|
|
|
|
|
#ifdef CONFIG_HAVE_FILENAME
|
|
|
|
printf("File: %s Line: %d : %s\n", file, line, msg);
|
|
|
|
#else
|
|
|
|
printf("\n%s:\n", msg);
|
|
|
|
#endif
|
|
|
|
printf(" Before: %8u After: %8u Change: %8d\n",
|
|
|
|
*previous, mmcurrent.uordblks, (int)mmcurrent.uordblks - (int)*previous);
|
|
|
|
|
|
|
|
/* Set up for the next test */
|
|
|
|
|
|
|
|
*previous = mmcurrent.uordblks;
|
|
|
|
}
|
2012-05-19 01:08:34 +02:00
|
|
|
#endif
|
2012-05-03 21:46:37 +02:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: showTestCaseMemory
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-19 01:08:34 +02:00
|
|
|
#ifdef CONFIG_NXWIDGET_MEMMONITOR
|
2012-05-03 21:46:37 +02:00
|
|
|
#ifdef CONFIG_HAVE_FILENAME
|
|
|
|
static void _showTestCaseMemory(FAR const char *file, int line, FAR const char *msg)
|
|
|
|
{
|
|
|
|
updateMemoryUsage(&g_nxwmtest.mmStep, file, line, msg);
|
|
|
|
g_nxwmtest.mmSubStep = g_nxwmtest.mmInitial;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static void showTestCaseMemory(FAR const char *msg)
|
|
|
|
{
|
|
|
|
updateMemoryUsage(&g_nxwmtest.mmStep, msg);
|
|
|
|
g_nxwmtest.mmSubStep = g_nxwmtest.mmInitial;
|
|
|
|
}
|
|
|
|
#endif
|
2012-05-19 01:08:34 +02:00
|
|
|
#endif
|
2012-05-03 21:46:37 +02:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: showTestMemory
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-19 01:08:34 +02:00
|
|
|
#ifdef CONFIG_NXWIDGET_MEMMONITOR
|
2012-05-03 21:46:37 +02:00
|
|
|
#ifdef CONFIG_HAVE_FILENAME
|
|
|
|
static void _showTestMemory(FAR const char *file, int line, FAR const char *msg)
|
|
|
|
{
|
|
|
|
updateMemoryUsage(&g_nxwmtest.mmInitial, file, line, msg);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static void showTestMemory(FAR const char *msg)
|
|
|
|
{
|
|
|
|
updateMemoryUsage(&g_nxwmtest.mmInitial, msg);
|
|
|
|
}
|
|
|
|
#endif
|
2012-05-19 01:08:34 +02:00
|
|
|
#endif
|
2012-05-03 21:46:37 +02:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: initMemoryUsage
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-19 01:08:34 +02:00
|
|
|
#ifdef CONFIG_NXWIDGET_MEMMONITOR
|
2012-05-03 21:46:37 +02:00
|
|
|
static void initMemoryUsage(void)
|
|
|
|
{
|
|
|
|
struct mallinfo mmcurrent;
|
|
|
|
|
|
|
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
|
|
|
mmcurrent = mallinfo();
|
|
|
|
#else
|
|
|
|
(void)mallinfo(&mmcurrent);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
g_nxwmtest.mmInitial = mmcurrent.uordblks;
|
|
|
|
g_nxwmtest.mmStep = mmcurrent.uordblks;
|
|
|
|
g_nxwmtest.mmSubStep = mmcurrent.uordblks;
|
|
|
|
}
|
2012-05-19 01:08:34 +02:00
|
|
|
#endif
|
2012-05-03 21:46:37 +02:00
|
|
|
|
2012-05-10 03:35:23 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: cleanup
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
static void testCleanUpAndExit(int exitCode)
|
2012-05-10 03:35:23 +02:00
|
|
|
{
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
// And exit
|
2012-05-03 21:46:37 +02:00
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
exit(exitCode);
|
2012-05-03 21:46:37 +02:00
|
|
|
}
|
|
|
|
|
2012-04-30 22:38:44 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2012-05-10 18:25:56 +02:00
|
|
|
// Name: createTaskbar
|
2012-04-30 22:38:44 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
static bool createTaskbar(void)
|
2012-04-30 22:38:44 +02:00
|
|
|
{
|
|
|
|
// Create an instance of the Task Bar.
|
|
|
|
//
|
|
|
|
// The general sequence for initializing the task bar is:
|
|
|
|
//
|
|
|
|
// 1. Create the CTaskbar instance,
|
|
|
|
// 2. Call the CTaskbar::connect() method to connect to the NX server (CTaskbar
|
|
|
|
// inherits the connect method from CNxServer),
|
|
|
|
// 3. Call the CTaskbar::initWindowManager() method to initialize the task bar.
|
|
|
|
// 3. Call CTaskBar::startApplication repeatedly to add applications to the task bar
|
|
|
|
// 4. Call CTaskBar::startWindowManager to start the display with applications in place
|
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createTaskbar: Create CTaskbar instance\n");
|
2012-05-01 22:36:19 +02:00
|
|
|
g_nxwmtest.taskbar = new NxWM::CTaskbar();
|
2012-04-30 22:38:44 +02:00
|
|
|
if (!g_nxwmtest.taskbar)
|
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createTaskbar: ERROR: Failed to instantiate CTaskbar\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
return false;
|
2012-04-30 22:38:44 +02:00
|
|
|
}
|
2012-05-17 00:43:40 +02:00
|
|
|
showTestCaseMemory("createTaskbar: After create taskbar");
|
2012-04-30 22:38:44 +02:00
|
|
|
|
|
|
|
// Connect to the NX server
|
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createTaskbar: Connect CTaskbar instance to the NX server\n");
|
2012-04-30 22:38:44 +02:00
|
|
|
if (!g_nxwmtest.taskbar->connect())
|
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createTaskbar: ERROR: Failed to connect CTaskbar instance to the NX server\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
return false;
|
2012-04-30 22:38:44 +02:00
|
|
|
}
|
2012-05-17 00:43:40 +02:00
|
|
|
showTestCaseMemory("createTaskbar: After connecting to the server");
|
2012-04-30 22:38:44 +02:00
|
|
|
|
|
|
|
// Initialize the task bar
|
|
|
|
//
|
|
|
|
// Taskbar::initWindowManager() prepares the task bar to receive applications.
|
|
|
|
// CTaskBar::startWindowManager() brings the window manager up with those applications
|
|
|
|
// in place.
|
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createTaskbar: Initialize CTaskbar instance\n");
|
2012-04-30 22:38:44 +02:00
|
|
|
if (!g_nxwmtest.taskbar->initWindowManager())
|
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createTaskbar: ERROR: Failed to intialize CTaskbar instance\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
return false;
|
2012-04-30 22:38:44 +02:00
|
|
|
}
|
2012-05-03 21:46:37 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
showTestCaseMemory("createTaskbar: After initializing window manager");
|
2012-05-10 18:25:56 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: createStartWindow
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static bool createStartWindow(void)
|
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
// Create the start window. The start window is unique among applications
|
|
|
|
// because it has no factory. The general sequence for setting up the
|
|
|
|
// start window is:
|
2012-04-30 22:38:44 +02:00
|
|
|
//
|
2012-05-17 00:43:40 +02:00
|
|
|
// 1. Create and open a CApplicationWindow
|
|
|
|
// 2. Use the window to create the CStartWindow the start window application
|
|
|
|
// 2. Call Cstartwindow::addApplication numerous times to install applications
|
2012-04-30 22:38:44 +02:00
|
|
|
// in the start window.
|
2012-05-17 00:43:40 +02:00
|
|
|
// 3. Call CTaskBar::startApplication (initially minimized) to start the start
|
2012-04-30 22:38:44 +02:00
|
|
|
// window application.
|
2012-05-13 16:36:59 +02:00
|
|
|
//
|
|
|
|
// NOTE: that the start window should not have a stop button.
|
2012-04-30 22:38:44 +02:00
|
|
|
|
2012-05-13 16:36:59 +02:00
|
|
|
NxWM::CApplicationWindow *window = g_nxwmtest.taskbar->openApplicationWindow(NxWM::CApplicationWindow::WINDOW_PERSISTENT);
|
2012-04-30 22:38:44 +02:00
|
|
|
if (!window)
|
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createStartWindow: ERROR: Failed to create CApplicationWindow\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
return false;
|
2012-04-30 22:38:44 +02:00
|
|
|
}
|
2012-05-17 00:43:40 +02:00
|
|
|
showTestCaseMemory("createStartWindow: After creating CApplicationWindow");
|
|
|
|
|
|
|
|
// Open the window (it is hot in here)
|
2012-04-30 22:38:44 +02:00
|
|
|
|
2012-05-02 16:38:54 +02:00
|
|
|
if (!window->open())
|
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createStartWindow: ERROR: Failed to open CApplicationWindow \n");
|
2012-05-02 16:38:54 +02:00
|
|
|
delete window;
|
2012-05-10 18:25:56 +02:00
|
|
|
return false;
|
2012-05-02 16:38:54 +02:00
|
|
|
}
|
2012-05-17 00:43:40 +02:00
|
|
|
showTestCaseMemory("createStartWindow: After opening CApplicationWindow");
|
|
|
|
|
|
|
|
// Instantiate the application, providing the window to the application's
|
|
|
|
// constructor
|
2012-05-02 16:38:54 +02:00
|
|
|
|
2012-04-30 22:38:44 +02:00
|
|
|
g_nxwmtest.startwindow = new NxWM::CStartWindow(g_nxwmtest.taskbar, window);
|
2012-05-02 16:38:54 +02:00
|
|
|
if (!g_nxwmtest.startwindow)
|
2012-04-30 22:38:44 +02:00
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
gdbg("ERROR: Failed to instantiate CStartWindow\n");
|
2012-04-30 22:38:44 +02:00
|
|
|
delete window;
|
2012-05-10 18:25:56 +02:00
|
|
|
return false;
|
|
|
|
}
|
2012-05-17 00:43:40 +02:00
|
|
|
showTestCaseMemory("createStartWindow: After creating CStartWindow");
|
2012-05-10 18:25:56 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
// Add the CStartWindow application to the task bar (minimized)
|
2012-05-10 18:25:56 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createStartWindow: Start the start window application\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
if (!g_nxwmtest.taskbar->startApplication(g_nxwmtest.startwindow, true))
|
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createStartWindow: ERROR: Failed to start the start window application\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
return false;
|
2012-04-30 22:38:44 +02:00
|
|
|
}
|
2012-05-17 00:43:40 +02:00
|
|
|
showTestCaseMemory("createStartWindow: After starting the start window application");
|
2012-05-10 18:25:56 +02:00
|
|
|
return true;
|
|
|
|
}
|
2012-04-30 22:38:44 +02:00
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: startWindowManager
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2012-05-10 03:35:23 +02:00
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
static bool startWindowManager(void)
|
|
|
|
{
|
|
|
|
// Start the window manager
|
2012-05-10 03:35:23 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("startWindowManager: Start the window manager\n");
|
2012-05-10 03:35:23 +02:00
|
|
|
if (!g_nxwmtest.taskbar->startWindowManager())
|
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("startWindowManager: ERROR: Failed to start the window manager\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
return false;
|
2012-05-10 03:35:23 +02:00
|
|
|
}
|
|
|
|
|
2012-05-19 01:08:34 +02:00
|
|
|
showTestCaseMemory("startWindowManager: After starting the window manager");
|
2012-05-10 18:25:56 +02:00
|
|
|
return true;
|
|
|
|
}
|
2012-05-10 00:30:19 +02:00
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: createTouchScreen
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2012-05-10 00:30:19 +02:00
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
#ifdef CONFIG_NXWM_TOUCHSCREEN
|
|
|
|
static bool createTouchScreen(void)
|
|
|
|
{
|
2012-05-12 18:59:57 +02:00
|
|
|
// Get the physical size of the display in pixels
|
2012-05-11 02:05:25 +02:00
|
|
|
|
2012-05-12 18:59:57 +02:00
|
|
|
struct nxgl_size_s displaySize;
|
|
|
|
(void)g_nxwmtest.taskbar->getDisplaySize(displaySize);
|
2012-05-11 02:05:25 +02:00
|
|
|
|
|
|
|
// Create the touchscreen device
|
2012-05-10 00:30:19 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createTouchScreen: Creating CTouchscreen\n");
|
2012-05-12 18:59:57 +02:00
|
|
|
g_nxwmtest.touchscreen = new NxWM::CTouchscreen(g_nxwmtest.taskbar, &displaySize);
|
2012-05-10 03:35:23 +02:00
|
|
|
if (!g_nxwmtest.touchscreen)
|
2012-05-10 00:30:19 +02:00
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createTouchScreen: ERROR: Failed to create CTouchscreen\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
return false;
|
2012-05-10 00:30:19 +02:00
|
|
|
}
|
2012-05-21 00:10:34 +02:00
|
|
|
showTestCaseMemory("createTouchScreen: After creating CTouchscreen");
|
2012-05-10 00:30:19 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createTouchScreen: Start touchscreen listener\n");
|
2012-05-11 02:05:25 +02:00
|
|
|
if (!g_nxwmtest.touchscreen->start())
|
2012-05-10 00:30:19 +02:00
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createTouchScreen: ERROR: Failed start the touchscreen listener\n");
|
2012-05-10 00:30:19 +02:00
|
|
|
delete g_nxwmtest.touchscreen;
|
2012-05-10 18:25:56 +02:00
|
|
|
return false;
|
2012-05-10 00:30:19 +02:00
|
|
|
}
|
2012-05-10 18:25:56 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
showTestCaseMemory("createTouchScreen: After starting the touchscreen listener");
|
2012-05-10 18:25:56 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-21 00:10:34 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: createKeyboard
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifdef CONFIG_NXWM_KEYBOARD
|
|
|
|
static bool createKeyboard(void)
|
|
|
|
{
|
|
|
|
printf("createKeyboard: Creating CKeyboard\n");
|
|
|
|
NxWM::CKeyboard *keyboard = new NxWM::CKeyboard(g_nxwmtest.taskbar);
|
|
|
|
if (!keyboard)
|
|
|
|
{
|
|
|
|
printf("createKeyboard: ERROR: Failed to create CKeyboard\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
showTestCaseMemory("createKeyboard After creating CKeyboard");
|
|
|
|
|
|
|
|
printf("createKeyboard: Start keyboard listener\n");
|
|
|
|
if (!keyboard->start())
|
|
|
|
{
|
|
|
|
printf("createKeyboard: ERROR: Failed start the keyboard listener\n");
|
|
|
|
delete keyboard;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
showTestCaseMemory("createKeyboard: After starting the keyboard listener");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: createCalibration
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2012-05-10 00:30:19 +02:00
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
#ifdef CONFIG_NXWM_TOUCHSCREEN
|
|
|
|
static bool createCalibration(void)
|
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
// 1Create the CCalibrationFactory application factory
|
2012-05-10 00:30:19 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createCalibration: Creating CCalibrationFactory\n");
|
|
|
|
NxWM::CCalibrationFactory *factory = new NxWM::CCalibrationFactory(g_nxwmtest.taskbar, g_nxwmtest.touchscreen);
|
|
|
|
if (!factory)
|
2012-05-10 00:30:19 +02:00
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createCalibration: ERROR: Failed to create CCalibrationFactory\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
return false;
|
2012-05-10 00:30:19 +02:00
|
|
|
}
|
2012-05-17 00:43:40 +02:00
|
|
|
showTestCaseMemory("createCalibration: After creating CCalibrationFactory");
|
2012-05-10 00:30:19 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
// Add the calibration application to the start window.
|
2012-05-10 00:30:19 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createCalibration: Adding CCalibration to the start window\n");
|
|
|
|
if (!g_nxwmtest.startwindow->addApplication(factory))
|
2012-05-10 00:30:19 +02:00
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createCalibration: ERROR: Failed to add CCalibrationto the start window\n");
|
|
|
|
delete factory;
|
2012-05-10 18:25:56 +02:00
|
|
|
return false;
|
2012-05-10 00:30:19 +02:00
|
|
|
}
|
2012-05-17 00:43:40 +02:00
|
|
|
showTestCaseMemory("createCalibration: After adding CCalibration");
|
2012-05-10 18:25:56 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
// Call StartWindowFactory::create to to create the start window application
|
2012-05-10 00:30:19 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createCalibration: Creating CCalibration\n");
|
|
|
|
NxWM::IApplication *calibration = factory->create();
|
|
|
|
if (!calibration)
|
2012-05-14 22:46:47 +02:00
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createCalibration: ERROR: Failed to create CCalibration\n");
|
2012-05-14 22:46:47 +02:00
|
|
|
return false;
|
|
|
|
}
|
2012-05-17 00:43:40 +02:00
|
|
|
showTestCaseMemory("createCalibration: After creating CCalibration");
|
2012-05-12 00:07:06 +02:00
|
|
|
|
2013-10-31 00:16:58 +01:00
|
|
|
#ifdef CONFIG_NXWM_TOUCHSCREEN_CONFIGDATA
|
2013-10-30 17:11:43 +01:00
|
|
|
// Check if we have previously stored calibration data
|
2012-05-10 00:30:19 +02:00
|
|
|
|
2013-10-30 17:11:43 +01:00
|
|
|
int ret = platform_getconfig(CONFIGDATA_TSCALIBRATION, 0,
|
|
|
|
(FAR uint8_t *)&g_nxwmtest.calibData,
|
|
|
|
sizeof(struct NxWM::SCalibrationData));
|
|
|
|
if (ret == OK)
|
2012-05-10 00:30:19 +02:00
|
|
|
{
|
2013-10-30 17:11:43 +01:00
|
|
|
// We successfully got the calibration data from the platform-specific
|
|
|
|
// logic. This might fail if (1) calibration data was never saved, or
|
|
|
|
// (2) if some failure occurred while trying to obtain the configuration
|
|
|
|
// data. In either event, the appropriate thing to do is to perform
|
|
|
|
// the calibration.
|
|
|
|
|
|
|
|
// Provide the calibration data to the touchscreen thread
|
|
|
|
|
|
|
|
g_nxwmtest.touchscreen->setCalibrationData(g_nxwmtest.calibData);
|
|
|
|
g_nxwmtest.touchscreen->setEnabled(true);
|
|
|
|
g_nxwmtest.calibrated = true;
|
2012-05-10 00:30:19 +02:00
|
|
|
}
|
2013-10-30 17:11:43 +01:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
// Call CTaskBar::startApplication to start the Calibration application.
|
|
|
|
// Nothing will be displayed because the window manager has not yet been
|
|
|
|
// started.
|
|
|
|
|
|
|
|
printf("createCalibration: Start the calibration application\n");
|
|
|
|
g_nxwmtest.calibrated = false;
|
|
|
|
|
|
|
|
if (!g_nxwmtest.taskbar->startApplication(calibration, false))
|
|
|
|
{
|
|
|
|
printf("createCalibration ERROR: Failed to start the calibration application\n");
|
|
|
|
delete calibration;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
showTestCaseMemory("createCalibration: After starting the start window application");
|
|
|
|
}
|
|
|
|
|
2012-05-12 15:50:21 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: createNxConsole
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2012-04-30 22:38:44 +02:00
|
|
|
|
2013-12-30 17:04:34 +01:00
|
|
|
#ifdef CONFIG_NXWM_NXCONSOLE
|
2012-05-10 18:25:56 +02:00
|
|
|
static bool createNxConsole(void)
|
|
|
|
{
|
|
|
|
// Add the NxConsole application to the start window
|
2012-05-01 22:36:19 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createNxConsole: Creating the NxConsole application\n");
|
|
|
|
NxWM::CNxConsoleFactory *console = new NxWM::CNxConsoleFactory(g_nxwmtest.taskbar);
|
2012-04-30 22:38:44 +02:00
|
|
|
if (!console)
|
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createNxConsole: ERROR: Failed to instantiate CNxConsoleFactory\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
return false;
|
2012-04-30 22:38:44 +02:00
|
|
|
}
|
2012-05-17 00:43:40 +02:00
|
|
|
showTestCaseMemory("createNxConsole: After creating the NxConsole application");
|
2012-04-30 22:38:44 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createNxConsole: Adding the NxConsole application to the start window\n");
|
2012-04-30 22:38:44 +02:00
|
|
|
if (!g_nxwmtest.startwindow->addApplication(console))
|
|
|
|
{
|
2012-05-17 00:43:40 +02:00
|
|
|
printf("createNxConsole: ERROR: Failed to add CNxConsoleFactory to the start window\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
delete console;
|
|
|
|
return false;
|
2012-04-30 22:38:44 +02:00
|
|
|
}
|
2012-05-10 18:25:56 +02:00
|
|
|
|
2012-05-17 00:43:40 +02:00
|
|
|
showTestCaseMemory("createNxConsole: After adding the NxConsole application");
|
2012-05-10 18:25:56 +02:00
|
|
|
return true;
|
|
|
|
}
|
2013-12-30 17:04:34 +01:00
|
|
|
#endif
|
2012-05-10 18:25:56 +02:00
|
|
|
|
2012-05-22 21:29:22 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: createHexCalculator
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static bool createHexCalculator(void)
|
|
|
|
{
|
|
|
|
// Add the hex calculator application to the start window
|
|
|
|
|
|
|
|
printf("createHexCalculator: Creating the hex calculator application\n");
|
|
|
|
NxWM::CHexCalculatorFactory *calculator = new NxWM::CHexCalculatorFactory(g_nxwmtest.taskbar);
|
|
|
|
if (!calculator)
|
|
|
|
{
|
|
|
|
printf("createHexCalculator: ERROR: Failed to instantiate CHexCalculatorFactory\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
showTestCaseMemory("createHexCalculator: After creating the hex calculator application");
|
|
|
|
|
|
|
|
printf("createHexCalculator: Adding the hex calculator application to the start window\n");
|
|
|
|
if (!g_nxwmtest.startwindow->addApplication(calculator))
|
|
|
|
{
|
2013-12-30 17:04:34 +01:00
|
|
|
printf("createHexCalculator: ERROR: Failed to add CHexCalculatorFactory to the start window\n");
|
2012-05-22 21:29:22 +02:00
|
|
|
delete calculator;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
showTestCaseMemory("createHexCalculator: After adding the hex calculator application");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-05-12 00:15:51 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: createMediaPlayer
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifdef CONFIG_NXWM_MEDIAPLAYER
|
|
|
|
static bool createMediaPlayer(void)
|
|
|
|
{
|
|
|
|
// Add the hex calculator application to the start window
|
|
|
|
|
|
|
|
printf("createHexCalculator: Creating the hex calculator application\n");
|
2013-05-16 00:45:57 +02:00
|
|
|
NxWM::CMediaPlayerFactory *mediaplayer = new NxWM::CMediaPlayerFactory(g_nxwmtest.taskbar);
|
|
|
|
if (!mediaplayer)
|
2013-05-12 00:15:51 +02:00
|
|
|
{
|
|
|
|
printf("createMediaPlayer: ERROR: Failed to instantiate CMediaPlayerFactory\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
showTestCaseMemory("createMediaPlayer: After creating the media player application");
|
|
|
|
|
|
|
|
printf("createMediaPlayer: Adding the hex calculator application to the start window\n");
|
2013-05-16 00:45:57 +02:00
|
|
|
if (!g_nxwmtest.startwindow->addApplication(mediaplayer))
|
2013-05-12 00:15:51 +02:00
|
|
|
{
|
2013-12-30 17:04:34 +01:00
|
|
|
printf("createMediaPlayer: ERROR: Failed to add CMediaPlayerFactory to the start window\n");
|
2013-05-16 00:45:57 +02:00
|
|
|
delete mediaplayer;
|
2013-05-12 00:15:51 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
showTestCaseMemory("createMediaPlayer: After adding the media player application");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Public Functions
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: showTestStepMemory
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Called by ad hoc instrumentation in the NxWM/NxWidgets code
|
|
|
|
|
|
|
|
#ifdef CONFIG_HAVE_FILENAME
|
|
|
|
void _showTestStepMemory(FAR const char *file, int line, FAR const char *msg)
|
|
|
|
{
|
2012-05-19 01:08:34 +02:00
|
|
|
#ifdef CONFIG_NXWIDGET_MEMMONITOR
|
2012-05-10 18:25:56 +02:00
|
|
|
updateMemoryUsage(&g_nxwmtest.mmSubStep, file, line, msg);
|
2012-05-19 01:08:34 +02:00
|
|
|
#endif
|
2012-05-10 18:25:56 +02:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
void showTestStepMemory(FAR const char *msg)
|
|
|
|
{
|
2012-05-19 01:08:34 +02:00
|
|
|
#ifdef CONFIG_NXWIDGET_MEMMONITOR
|
2012-05-10 18:25:56 +02:00
|
|
|
updateMemoryUsage(&g_nxwmtest.mmSubStep, msg);
|
2012-05-19 01:08:34 +02:00
|
|
|
#endif
|
2012-05-10 18:25:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2012-09-17 20:43:00 +02:00
|
|
|
// nxwm_main
|
2012-05-10 18:25:56 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2012-04-30 22:38:44 +02:00
|
|
|
|
2012-09-14 17:23:54 +02:00
|
|
|
int nxwm_main(int argc, char *argv[])
|
2012-05-10 18:25:56 +02:00
|
|
|
{
|
|
|
|
// Call all C++ static constructors
|
2012-04-30 22:38:44 +02:00
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
|
|
|
|
up_cxxinitialize();
|
|
|
|
#endif
|
2012-04-30 22:38:44 +02:00
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
// Initialize memory monitor logic
|
2012-05-01 22:36:19 +02:00
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
initMemoryUsage();
|
|
|
|
|
|
|
|
// Initialize the NSH library
|
|
|
|
|
2013-12-30 17:04:34 +01:00
|
|
|
#ifdef CONFIG_NXWM_NXCONSOLE
|
2012-09-14 17:23:54 +02:00
|
|
|
printf("nxwm_main: Initialize the NSH library\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
if (!NxWM::nshlibInitialize())
|
2012-04-30 22:38:44 +02:00
|
|
|
{
|
2012-09-14 17:23:54 +02:00
|
|
|
printf("nxwm_main: ERROR: Failed to initialize the NSH library\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
return EXIT_FAILURE;
|
2012-04-30 22:38:44 +02:00
|
|
|
}
|
2012-09-14 17:23:54 +02:00
|
|
|
showTestCaseMemory("nxwm_main: After initializing the NSH library");
|
2013-12-30 17:04:34 +01:00
|
|
|
#endif
|
2012-04-30 22:38:44 +02:00
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
// Create the task bar.
|
|
|
|
|
|
|
|
if (!createTaskbar())
|
2012-05-02 16:38:54 +02:00
|
|
|
{
|
2012-09-14 17:23:54 +02:00
|
|
|
printf("nxwm_main: ERROR: Failed to create the task bar\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
testCleanUpAndExit(EXIT_FAILURE);
|
2012-05-02 16:38:54 +02:00
|
|
|
}
|
|
|
|
|
2012-05-14 22:46:47 +02:00
|
|
|
// Create the start window.
|
|
|
|
|
|
|
|
if (!createStartWindow())
|
|
|
|
{
|
2012-09-14 17:23:54 +02:00
|
|
|
printf("nxwm_main: ERROR: Failed to create the start window\n");
|
2012-05-14 22:46:47 +02:00
|
|
|
testCleanUpAndExit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2012-05-21 00:10:34 +02:00
|
|
|
// Create the keyboard device
|
|
|
|
|
|
|
|
#ifdef CONFIG_NXWM_KEYBOARD
|
|
|
|
if (!createKeyboard())
|
|
|
|
{
|
2012-09-14 17:23:54 +02:00
|
|
|
printf("nxwm_main: ERROR: Failed to create the keyboard\n");
|
2012-05-21 00:10:34 +02:00
|
|
|
testCleanUpAndExit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-10 18:25:56 +02:00
|
|
|
// Create the touchscreen device
|
|
|
|
|
|
|
|
#ifdef CONFIG_NXWM_TOUCHSCREEN
|
|
|
|
if (!createTouchScreen())
|
2012-04-30 22:38:44 +02:00
|
|
|
{
|
2012-09-14 17:23:54 +02:00
|
|
|
printf("nxwm_main ERROR: Failed to create the touchscreen\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
testCleanUpAndExit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-14 22:46:47 +02:00
|
|
|
// Create the calibration application and add it to the start window
|
2012-05-10 18:25:56 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_NXWM_TOUCHSCREEN
|
|
|
|
if (!createCalibration())
|
|
|
|
{
|
2012-09-14 17:23:54 +02:00
|
|
|
printf("nxwm_main ERROR: Failed to create the calibration application\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
testCleanUpAndExit(EXIT_FAILURE);
|
2012-04-30 22:38:44 +02:00
|
|
|
}
|
2012-05-14 22:46:47 +02:00
|
|
|
#endif
|
2012-04-30 22:38:44 +02:00
|
|
|
|
2012-05-14 22:46:47 +02:00
|
|
|
// Create the NxConsole application and add it to the start window
|
2012-05-10 18:25:56 +02:00
|
|
|
|
2013-12-30 17:04:34 +01:00
|
|
|
#ifdef CONFIG_NXWM_NXCONSOLE
|
2012-05-14 22:46:47 +02:00
|
|
|
if (!createNxConsole())
|
2012-05-10 18:25:56 +02:00
|
|
|
{
|
2012-09-14 17:23:54 +02:00
|
|
|
printf("nxwm_main: ERROR: Failed to create the NxConsole application\n");
|
2012-05-10 18:25:56 +02:00
|
|
|
testCleanUpAndExit(EXIT_FAILURE);
|
|
|
|
}
|
2013-12-30 17:04:34 +01:00
|
|
|
#endif
|
2012-05-12 15:50:21 +02:00
|
|
|
|
2012-05-22 21:29:22 +02:00
|
|
|
// Create the hex calculator application and add it to the start window
|
|
|
|
|
|
|
|
if (!createHexCalculator())
|
|
|
|
{
|
2012-09-14 17:23:54 +02:00
|
|
|
printf("nxwm_main: ERROR: Failed to create the hex calculator application\n");
|
2012-05-22 21:29:22 +02:00
|
|
|
testCleanUpAndExit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2013-05-12 00:15:51 +02:00
|
|
|
// Create the media player application and add it to the start window
|
|
|
|
|
|
|
|
#ifdef CONFIG_NXWM_MEDIAPLAYER
|
|
|
|
if (!createMediaPlayer())
|
|
|
|
{
|
|
|
|
printf("nxwm_main: ERROR: Failed to create the media player application\n");
|
|
|
|
testCleanUpAndExit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-14 22:46:47 +02:00
|
|
|
// Call CTaskBar::startWindowManager to start the display with applications in place.
|
2012-05-12 15:50:21 +02:00
|
|
|
|
2012-05-14 22:46:47 +02:00
|
|
|
if (!startWindowManager())
|
2012-05-12 15:50:21 +02:00
|
|
|
{
|
2012-09-14 17:23:54 +02:00
|
|
|
printf("nxwm_main: ERROR: Failed to start the window manager\n");
|
2012-05-12 15:50:21 +02:00
|
|
|
testCleanUpAndExit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_NXWM_TOUCHSCREEN
|
2013-10-31 00:16:58 +01:00
|
|
|
#ifdef CONFIG_NXWM_TOUCHSCREEN_CONFIGDATA
|
2014-07-18 01:58:24 +02:00
|
|
|
// There are two possibilities: (1) We started the calibration earlier and now
|
2013-10-30 17:11:43 +01:00
|
|
|
// need to obtain the calibration data from the calibration process, or (2)
|
|
|
|
// We have already obtained stored calibration data in which case, the calibration
|
|
|
|
// process never ran.
|
|
|
|
|
|
|
|
if (!g_nxwmtest.calibrated)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
// Since we started the touchscreen calibration program maximized, it will
|
|
|
|
// run immediately when we start the window manager. There is no positive
|
2014-07-18 01:58:24 +02:00
|
|
|
// handshake to know when the touchscreen has been calibrated. If we really
|
2013-10-30 17:11:43 +01:00
|
|
|
// want to know, we have to poll
|
|
|
|
|
|
|
|
printf("nxwm_main: Waiting for touchscreen calibration\n");
|
|
|
|
while (!g_nxwmtest.touchscreen->isCalibrated())
|
|
|
|
{
|
|
|
|
std::sleep(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is how we would then recover the calibration data. After the
|
|
|
|
// calibration application creates the calibration data, it hands it to
|
|
|
|
// the touchscreen driver. After the touchscreen driver gets it, it will
|
|
|
|
// report isCalibrated() == true and then we can read the calibration data
|
|
|
|
// from the touchscreen driver.
|
|
|
|
|
|
|
|
printf("nxwm_main: Getting calibration data from the touchscreen\n");
|
|
|
|
if (!g_nxwmtest.touchscreen->getCalibrationData(g_nxwmtest.calibData))
|
|
|
|
{
|
|
|
|
printf("nxwm_main: ERROR: Failed to get calibration data from the touchscreen\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-31 00:16:58 +01:00
|
|
|
#if 0 // ifdef CONFIG_NXWM_TOUCHSCREEN_CONFIGDATA. Done in CCalibration
|
2013-10-30 17:11:43 +01:00
|
|
|
// Save the new calibration data so that we do not have to do this
|
|
|
|
// again the next time we start up.
|
|
|
|
|
|
|
|
int ret = platform_setconfig(CONFIGDATA_TSCALIBRATION, 0,
|
|
|
|
(FAR const uint8_t *)&g_nxwmtest.calibData,
|
|
|
|
sizeof(struct NxWM::SCalibrationData));
|
|
|
|
if (ret != 0)
|
|
|
|
{
|
|
|
|
printf("nxwm_main: ERROR: Failed to save calibration data\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
g_nxwmtest.calibrated = true;
|
|
|
|
}
|
2012-04-30 22:38:44 +02:00
|
|
|
}
|
2012-05-14 22:46:47 +02:00
|
|
|
#endif
|
2012-04-30 22:38:44 +02:00
|
|
|
|
2012-05-19 01:08:34 +02:00
|
|
|
// Wait a little bit for the display to stabilize. Then simulate pressing of
|
2012-05-03 00:03:05 +02:00
|
|
|
// the 'start window' icon in the task bar
|
|
|
|
|
2012-05-10 00:30:19 +02:00
|
|
|
#ifndef CONFIG_NXWM_TOUCHSCREEN
|
2012-05-03 00:03:05 +02:00
|
|
|
sleep(2);
|
2012-05-19 01:08:34 +02:00
|
|
|
g_nxwmtest.taskbar->clickIcon(0, true);
|
|
|
|
usleep(500*1000);
|
|
|
|
g_nxwmtest.taskbar->clickIcon(0, false);
|
2012-09-14 17:23:54 +02:00
|
|
|
showTestCaseMemory("nxwm_main: After clicking the start window icon");
|
2012-05-03 00:03:05 +02:00
|
|
|
|
2012-05-19 01:08:34 +02:00
|
|
|
// Wait bit to see the result of the button press. Then press the first icon
|
2013-12-30 17:04:34 +01:00
|
|
|
// in the start menu. That should be the NxConsole icon (if the NXCONSOLE
|
|
|
|
// is not disabled).
|
2012-05-03 00:03:05 +02:00
|
|
|
|
|
|
|
sleep(2);
|
2012-05-19 01:08:34 +02:00
|
|
|
g_nxwmtest.startwindow->clickIcon(0, true);
|
|
|
|
usleep(500*1000);
|
|
|
|
g_nxwmtest.startwindow->clickIcon(0, false);
|
2012-09-14 17:23:54 +02:00
|
|
|
showTestCaseMemory("nxwm_main: After clicking the NxConsole icon");
|
2012-05-10 00:30:19 +02:00
|
|
|
#endif
|
|
|
|
|
2012-05-03 00:03:05 +02:00
|
|
|
// Wait bit to see the result of the button press.
|
|
|
|
|
|
|
|
sleep(2);
|
2012-09-14 17:23:54 +02:00
|
|
|
showTestMemory("nxwm_main: Final memory usage");
|
2012-05-10 03:35:23 +02:00
|
|
|
return EXIT_SUCCESS;
|
2012-04-30 22:38:44 +02:00
|
|
|
}
|
|
|
|
|