Fix STM32 USART4/5 vs UART4/5 confusion

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4671 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-04-29 14:34:56 +00:00
parent 562e215f60
commit 080d38e168
18 changed files with 452 additions and 33 deletions

View File

@ -130,6 +130,15 @@ namespace NXWidgets
bool open(void);
/**
* Each implementation of INxWindow must provide a method to recover
* the contained CWidgetControl instance.
*
* @return The contained CWidgetControl instance
*/
CWidgetControl *getWidgetControl(void) const;
/**
* Request the position and size information of the window. The values
* will be returned asynchronously through the client callback method.

View File

@ -48,6 +48,7 @@
#include <nuttx/nx/nx.h>
#include "cnxwindow.hxx"
#include "cnxtkwindow.hxx"
#include "cbgwindow.hxx"
/****************************************************************************
@ -176,12 +177,10 @@ namespace NXWidgets
* Get an instance of the framed NX window.
*/
#if 0 // Not ready for prime time
inline CFramedWindow *createFramedWindow(CWidgetControl *widgetControl)
inline CNxTkWindow *createFramedWindow(CWidgetControl *widgetControl)
{
return new CFramedWindow(m_hNxServer, widgetControl);
return new CNxTkWindow(m_hNxServer, widgetControl);
}
#endif
/**
* Get an instance of the background window.

View File

@ -102,7 +102,7 @@ namespace NXWidgets
* 3) The window constructor call CWidgetControl methods to "smarten"
* the CWidgetControl instance with window-specific knowledge.
* 4) Call the open() method on the window to display the window.
* 5) After that, the fully smartend CWidgetControl instance can
* 5) After that, the fully smartened CWidgetControl instance can
* be used to generate additional widgets.
* 6) After that, the fully smartened CWidgetControl instance can
* be used to generate additional widgets by passing it to the
@ -129,6 +129,15 @@ namespace NXWidgets
bool open(void);
/**
* Each implementation of INxWindow must provide a method to recover
* the contained CWidgetControl instance.
*
* @return The contained CWidgetControl instance
*/
CWidgetControl *getWidgetControl(void) const;
/**
* Open a toolbar on the framed window. Toolbar creation is separate
* from object instantion so that errors can be reported

View File

@ -120,6 +120,15 @@ namespace NXWidgets
bool open(void);
/**
* Each implementation of INxWindow must provide a method to recover
* the contained CWidgetControl instance.
*
* @return The contained CWidgetControl instance
*/
CWidgetControl *getWidgetControl(void) const;
/**
* Request the position and size information of the toolbar. The values
* will be returned asynchronously through the client callback method.

View File

@ -130,6 +130,15 @@ namespace NXWidgets
bool open(void);
/**
* Each implementation of INxWindow must provide a method to recover
* the contained CWidgetControl instance.
*
* @return The contained CWidgetControl instance
*/
CWidgetControl *getWidgetControl(void) const;
/**
* Request the position and size information of the window. The values
* will be returned asynchronously through the client callback method.

View File

@ -60,6 +60,7 @@
namespace NXWidgets
{
struct SBitmap;
class CWidgetControl;
/**
* This class defines common operations on a any NX window.
@ -89,6 +90,15 @@ namespace NXWidgets
virtual bool open(void) = 0;
/**
* Each implementation of INxWindow must provide a method to recover
* the contained CWidgetControl instance.
*
* @return The contained CWidgetControl instance
*/
virtual CWidgetControl *getWidgetControl(void) const = 0;
/**
* Request the position and size information of the window. The values
* will be returned asynchronously through the client callback method.

View File

@ -113,6 +113,18 @@ bool CBgWindow::open(void)
return true;
}
/**
* Each implementation of INxWindow must provide a method to recover
* the contained CWidgetControl instance.
*
* @return The contained CWidgetControl instance
*/
CWidgetControl *CBgWindow::getWidgetControl(void) const
{
return m_widgetControl;
}
/**
* Request the position and size information of the window. The values
* will be returned asynchronously through the client callback method.

View File

@ -120,7 +120,7 @@ CNxServer::~CNxServer(void)
#ifndef CONFIG_NX_MULTIUSER
bool CNxServer::connect(void)
{
#if defined(SCREENS_EXTERNINIT)
#if defined(CONFIG_NXWIDGETS_EXTERNINIT)
// Use external graphics driver initialization
m_hDevice = up_nxdrvinit(CONFIG_NXWIDGETS_DEVNO);

View File

@ -111,6 +111,18 @@ bool CNxTkWindow::open(void)
return m_hNxTkWindow != NULL;
}
/**
* Each implementation of INxWindow must provide a method to recover
* the contained CWidgetControl instance.
*
* @return The contained CWidgetControl instance
*/
CWidgetControl *CNxTkWindow::getWidgetControl(void) const
{
return m_widgetControl;
}
/**
* Open a toolbar on the framed window
*

View File

@ -117,6 +117,18 @@ bool CNxToolbar::open(void)
return ret == OK;
}
/**
* Each implementation of INxWindow must provide a method to recover
* the contained CWidgetControl instance.
*
* @return The contained CWidgetControl instance
*/
CWidgetControl *CNxToolbar::getWidgetControl(void) const
{
return m_widgetControl;
}
/**
* Request the position and size information of the toolbar. The values
* will be returned asynchronously through the client callback method.

View File

@ -103,6 +103,18 @@ bool CNxWindow::open(void)
return m_hNxWindow != NULL;
}
/**
* Each implementation of INxWindow must provide a method to recover
* the contained CWidgetControl instance.
*
* @return The contained CWidgetControl instance
*/
CWidgetControl *CNxWindow::getWidgetControl(void) const
{
return m_widgetControl;
}
/**
* Request the position and size information of the window. The values
* will be returned asynchronously through the client callback method.

View File

@ -56,6 +56,9 @@
namespace NxWM
{
class CNxTaskbar;
class CApplicationWindow;
class CNxStart : public INxApplication
{
protected:
@ -71,9 +74,19 @@ namespace NxWM
/**
* CNxStart Constructor
*
* @param taskbar. A pointer to the parent task bar instance
* @param window. The window to be used by this application.
*/
CNxStart(CNxTaskbar *taskbar);
CNxStart(CNxTaskbar *taskbar, CApplicationWindow *window);
/**
* Each implementation of INxApplication must provide a method to recover
* the contained CApplicationWindow instance.
*/
CApplicationWindow *getWindow(void) const;
/**
* Get the icon associated with the application
@ -85,6 +98,26 @@ namespace NxWM
NXWidgets::INxBitmap *getIcon(void);
/**
* Get the name string associated with the application
*
* @return A copy if CNxString that contains the name of the application.
*/
NXWidgets::CNxString getName(void);
/**
* Start the application.
*/
run(void);
/**
* Stop the application.
*/
stop(void);
/**
* Add the application to the start window
*

View File

@ -92,7 +92,7 @@ namespace NxWM
* widget constructor
*/
NXWidgets::INxWindow *openRawWindow(void);
NXWidgets::CNxWindow *openRawWindow(void);
/**
* Create a framed application window
@ -102,7 +102,15 @@ namespace NxWM
* @return A partially initialized application window instance.
*/
NXWidgets::INxWindow *openFramedWindow(void);
NXWidgets::CNxTkWindow *openFramedWindow(void);
/**
* Set size and position of a window in the application area.
*
* @param window. The window to be resized and repositioned
*/
void setApplicationGeometry(NxWidgets::INxWindow *window);
/**
* Create the toolbar window.
@ -166,9 +174,37 @@ namespace NxWM
bool startWindowManager(start);
/**
* Create an application window. Creating a new applicatino in the start
* window requires three steps:
*
* 1. Call openApplicationWindow to create a window for the application,
* 2. Instantiate the application, providing the window to the application's
* constructor,
* 3. Then call addApplication to add the application to the start window.
*
* When the application is selected from the start window:
*
* 4. Call startApplication start the application and bring its window to
* the top.
*/
CApplicationWindow *openApplicationWindow(void);
/**
* Start an application and add its icon to the taskbar. The applications's
* window is brought to the top.
* window is brought to the top. Creating a new applicatino in the start
* window requires three steps:
*
* 1. Call openApplicationWindow to create a window for the application,
* 2. Instantiate the application, providing the window to the application's
* constructor,
* 3. Then call addApplication to add the application to the start window.
*
* When the application is selected from the start window:
*
* 4. Call startApplication start the application and bring its window to
* the top.
*
* @param application. The new application to add to the task bar
* @return true on success

View File

@ -54,9 +54,23 @@
namespace NxWM
{
class CApplicationWindow;
class NxWidget::CNxString;
/**
* INxApplication provides the abstract base class for each NxWM application.
*/
class INxApplication
{
public:
/**
* Each implementation of INxApplication must provide a method to recover
* the contained CApplicationWindow instance.
*/
virtual CApplicationWindow *getWindow(void) const = 0;
/**
* Get the icon associated with the application
*
@ -67,11 +81,25 @@ namespace NxWM
virtual NXWidgets::INxBitmap *getIcon(void) = 0;
/**
* Get the name string associated with the application
*
* @return A copy if CNxString that contains the name of the application.
*/
virtual NXWidgets::CNxString getName(void) = 0;
/**
* Start the application.
*/
virtual run(void) = 0;
/**
* Stop the application.
*/
virtual stop(void) = 0;
};
}

View File

@ -47,7 +47,16 @@
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* General Configuration ****************************************************/
/**
* NX Multi-user support is required
*/
#ifndef CONFIG_NX_MULTIUSER
# warning "NX multi-user support is required (CONFIG_NX_MULTIUSER)"
#endif
/* Colors *******************************************************************/
/**
* Normal background color
*/
@ -80,5 +89,34 @@
# define CONFIG_NXWM_DEFAULT_SELECTEDFOREGROUNDCOLOR MKRGB(248,248,248)
#endif
/* Task Bar Configuation ***************************************************/
/* At present, all icons are 25 pixels in "widgth" and, hence require a
* task bar of at least that size.
*/
#ifndef CONFIG_NXWM_TASKBAR_WIDTH
# define CONFIG_NXWM_TASKBAR_WIDTH (25+2*2)
#endif
/* Check task bar location */
#if defined(CONFIG_NXWM_TASKBAR_TOP)
# if defined(CONFIG_NXWM_TASKBAR_BOTTOM) || defined (CONFIG_NXWM_TASKBAR_LEFT) || defined (CONFIG_NXWM_TASKBAR_RIGHT)
# warning "Multiple task positions specified"
# endif
#elif defined(CONFIG_NXWM_TASKBAR_BOTTOM)
# if defined (CONFIG_NXWM_TASKBAR_LEFT) || defined (CONFIG_NXWM_TASKBAR_RIGHT)
# warning "Multiple task positions specified"
# endif
#elif defined(CONFIG_NXWM_TASKBAR_LEFT)
# if defined defined (CONFIG_NXWM_TASKBAR_RIGHT)
# warning "Multiple task positions specified"
# endif
#elif !defined(CONFIG_NXWM_TASKBAR_RIGHT)
# warning "No task positions specified"
# define CONFIG_NXWM_TASKBAR_TOP 1
#endif
/* Colors *******************************************************************/
#endif // __INCLUDE_NXWM_CONFIG_HXX

View File

@ -105,7 +105,36 @@ bool CNxTaskBar::addApplication(INxApplication *application)
bool CNxTaskBar::startWindowManager(start);
/**
* Start an application and add its icon to the taskbar
* Create an application window. Creating a new applicatino in the start
* window requires three steps:
*
* 1. Call openApplicationWindow to create a window for the application,
* 2. Instantiate the application, providing the window to the application's
* constructor,
* 3. Then call addApplication to add the application to the start window.
*
* When the application is selected from the start window:
*
* 4. Call startApplication start the application and bring its window to
* the top.
*/
CApplicationWindow *CNxTaskBar::openApplicationWindow(void);
/**
* Start an application and add its icon to the taskbar. The applications's
* window is brought to the top. Creating a new applicatino in the start
* window requires three steps:
*
* 1. Call openApplicationWindow to create a window for the application,
* 2. Instantiate the application, providing the window to the application's
* constructor,
* 3. Then call addApplication to add the application to the start window.
*
* When the application is selected from the start window:
*
* 4. Call startApplication start the application and bring its window to
* the top.
*
* @param application. The new application to add to the task bar
* @return true on success
@ -171,18 +200,52 @@ void CNxTaskBar::disconnect(void)
// Close the windows
NxWidgets::CWidgetControl *control;
if (m_toolbar)
{
// Delete the contained widget control. We are responsible for it
// because we created it
control = m_toolbar->getWidgetControl();
if (control)
{
delete control;
}
// Then delete the toolbar
delete m_toolbar;
}
if (m_background)
{
// Delete the contained widget control. We are responsible for it
// because we created it
control = m_background->getWidgetControl();
if (control)
{
delete control;
}
// Then delete the background
delete m_background;
}
if (m_start)
{
// Delete the contained widget control. We are responsible for it
// because we created it
control = m_start->getWidgetControl();
if (control)
{
delete control;
}
// Then delete the start window
delete m_start;
}
@ -204,7 +267,7 @@ void CNxTaskBar::disconnect(void)
* widget constructor
*/
NXWidgets::INxWindow *CNxTaskBar::openRawWindow(void)
NXWidgets::CNxWindow *CNxTaskBar::openRawWindow(void)
{
// Initialize the widget control using the default style
@ -232,7 +295,7 @@ NXWidgets::INxWindow *CNxTaskBar::openRawWindow(void)
return false;
}
return static_cast<INxWindow*>(window);
return window;
}
/**
@ -243,7 +306,7 @@ NXWidgets::INxWindow *CNxTaskBar::openRawWindow(void)
* @return A partially initialized application window instance.
*/
NXWidgets::INxWindow *CNxTaskBar::openFramedWindow(void)
NXWidgets::CNxTkWindow *CNxTaskBar::openFramedWindow(void)
{
// Initialize the widget control using the default style
@ -252,7 +315,7 @@ NXWidgets::INxWindow *CNxTaskBar::openFramedWindow(void)
// Get an (uninitialized) instance of the background window as a class
// that derives from INxWindow.
NxWidgets:CFramedWindow window = createRawWindow(widgetControl);
NxWidgets:CNxTkWindow window = createRawWindow(widgetControl);
if (!window)
{
message("CNxwm::createGraphics: Failed to create background window\n");
@ -271,7 +334,64 @@ NXWidgets::INxWindow *CNxTaskBar::openFramedWindow(void)
return false;
}
return static_cast<INxWindow*>(window);
return window;
}
/**
* Set size and position of a window in the application area.
*
* @param window. The window to be resized and repositioned
*
* @return true on success
*/
bool CNxTaskBar::setApplicationGeometry(NxWidgets::INxWindow *window)
{
// Get the widget control from the toolbar window. The physical window geometry
// should be the same for all windows.
NxWidgets::CWidgetControl *control = m_toolbar->getWidgetControl();
// Now position and size the application. This will depend on the position and
// orientation of the toolbar.
nxgl_point_t pos;
nxgl_size_t size;
#if defined(CONFIG_NXWM_TASKBAR_TOP)
pos.x = 0;
pos.y = CONFIG_NXWM_TASKBAR_WIDTH;
size.w = rect.getWidth();
size.h = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH;
#elif defined(CONFIG_NXWM_TASKBAR_BOTTOM)
pos.x = 0;
pos.y = 0;
size.w = rect.getWidth();
size.h = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH;
#elif defined(CONFIG_NXWM_TASKBAR_LEFT)
pos.x = CONFIG_NXWM_TASKBAR_WIDTH;
pos.y = 0;
size.w = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH;
size.h = rect.getHeight();
#else
pos.x = 0;
pos.y = 0;
size.w = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH;
size.h = rect.getHeight();
#endif
/* Set the size and position the window.
*
* @param pPos The new position of the window.
* @return True on success, false on failure.
*/
window->setPosition(&pos);
window->setSize(&size);
}
/**
@ -291,6 +411,61 @@ bool CNxTaskBar::createToolbarWindow(void)
return false;
}
// Get the contained widget control
NxWidgets::CWidgetControl *control = m_toolbar->getWidgetControl();
// Get the size of the window from the widget control
CRect rect = control->getWindowBoundingBox();
// Now position and size the toolbar. This will depend on the position and
// orientation of the toolbar.
nxgl_point_t pos;
nxgl_size_t size;
#if defined(CONFIG_NXWM_TASKBAR_TOP)
pos.x = 0;
pos.y = 0;
size.w = rect.getWidth();
size.h = CONFIG_NXWM_TASKBAR_WIDTH;
#elif defined(CONFIG_NXWM_TASKBAR_BOTTOM)
pos.x = 0;
pos.y = rect.getHeight() - CONFIG_NXWM_TASKBAR_WIDTH;
size.w = rect.getWidth();
size.h = CONFIG_NXWM_TASKBAR_WIDTH;
#elif defined(CONFIG_NXWM_TASKBAR_LEFT)
pos.x = 0;
pos.y = 0;
size.w = CONFIG_NXWM_TASKBAR_WIDTH;
size.h = rect.getHeight();
#else
pos.x = rect.getWidgth() - CONFIG_NXWM_TASKBAR_WIDTH;
pos.y = 0;
size.w = CONFIG_NXWM_TASKBAR_WIDTH;
size.h = rect.getHeight();
#endif
/* Set the size and position the window.
*
* @param pPos The new position of the window.
* @return True on success, false on failure.
*/
m_toolbar->setPosition(&pos);
m_toolbar->setSize(&size);
/* And raise the window to the top of the display */
m_toolbar->raise(void);
// Add the start menu's icon to the toolbar
#warning "Missing logic"
return true;
}
@ -311,11 +486,19 @@ bool CNxTaskBar::createBackgroundWindow(void)
return false;
}
// Set the geometry to fit in the application window space
setApplicationGeometry(static_cast<NxWidgets::INxWidget>(m_background));
/* And lower the background window to the bottom of the display */
m_background->lower(void);
return true;
}
/**
* Create the background window.
* Create the start window.
*
* @return true on success
*/
@ -324,13 +507,21 @@ bool CNxTaskBar::createStartWindow(void)
{
// Create a raw window to present the background image
INxWindow *window = openFramedWindow();
if (!window)
m_start = openFramedWindow();
if (!m_start)
{
message("CNxwm::createGraphics: Failed to create start window\n");
return false;
}
// Set the geometry to fit in the application window space
setApplicationGeometry(static_cast<NxWidgets::INxWidget>(m_start));
/* And lower the background window to the top of the display */
m_start->raise(void);
// Now create the start up application
#warning "Missing logic"

View File

@ -85,8 +85,8 @@
# define STM32_CONSOLE_2STOP CONFIG_USART3_2STOP
# define STM32_CONSOLE_TX GPIO_USART3_TX
# define STM32_CONSOLE_RX GPIO_USART3_RX
#elif defined(CONFIG_UART4_SERIAL_CONSOLE)
# define STM32_CONSOLE_BASE STM32_USART4_BASE
#elif defined(CONFIG_USART4_SERIAL_CONSOLE)
# define STM32_CONSOLE_BASE STM32_UART4_BASE
# define STM32_APBCLOCK STM32_PCLK1_FREQUENCY
# define STM32_CONSOLE_BAUD CONFIG_USART4_BAUD
# define STM32_CONSOLE_BITS CONFIG_USART4_BITS
@ -94,8 +94,8 @@
# define STM32_CONSOLE_2STOP CONFIG_USART4_2STOP
# define STM32_CONSOLE_TX GPIO_UART4_TX
# define STM32_CONSOLE_RX GPIO_UART4_RX
#elif defined(CONFIG_UART5_SERIAL_CONSOLE)
# define STM32_CONSOLE_BASE STM32_USART5_BASE
#elif defined(CONFIG_USART5_SERIAL_CONSOLE)
# define STM32_CONSOLE_BASE STM32_UART5_BASE
# define STM32_APBCLOCK STM32_PCLK1_FREQUENCY
# define STM32_CONSOLE_BAUD CONFIG_USART5_BAUD
# define STM32_CONSOLE_BITS CONFIG_USART5_BITS

View File

@ -84,8 +84,8 @@
#if defined(CONFIG_USART1_SERIAL_CONSOLE) && defined(CONFIG_STM32_USART1)
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_UART4_SERIAL_CONSOLE
# undef CONFIG_UART5_SERIAL_CONSOLE
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART5_SERIAL_CONSOLE
# undef CONFIG_USART6_SERIAL_CONSOLE
# define CONSOLE_UART 1
# define HAVE_CONSOLE 1
@ -100,8 +100,8 @@
#elif defined(CONFIG_USART3_SERIAL_CONSOLE) && defined(CONFIG_STM32_USART3)
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_UART4_SERIAL_CONSOLE
# undef CONFIG_UART5_SERIAL_CONSOLE
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART5_SERIAL_CONSOLE
# undef CONFIG_USART6_SERIAL_CONSOLE
# define CONSOLE_UART 3
# define HAVE_CONSOLE 1
@ -109,7 +109,7 @@
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_UART5_SERIAL_CONSOLE
# undef CONFIG_USART5_SERIAL_CONSOLE
# undef CONFIG_USART6_SERIAL_CONSOLE
# define CONSOLE_UART 4
# define HAVE_CONSOLE 1
@ -117,7 +117,7 @@
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_UART4_SERIAL_CONSOLE
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART6_SERIAL_CONSOLE
# define CONSOLE_UART 5
# define HAVE_CONSOLE 1
@ -125,16 +125,16 @@
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_UART4_SERIAL_CONSOLE
# undef CONFIG_UART5_SERIAL_CONSOLE
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART5_SERIAL_CONSOLE
# define CONSOLE_UART 6
# define HAVE_CONSOLE 1
#else
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_UART4_SERIAL_CONSOLE
# undef CONFIG_UART5_SERIAL_CONSOLE
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART5_SERIAL_CONSOLE
# undef CONFIG_USART6_SERIAL_CONSOLE
# define CONSOLE_UART 0
# undef HAVE_CONSOLE