Merged nuttx/apps into master

This commit is contained in:
ziggurat29 2016-04-24 17:19:43 -05:00
commit 1143984ede
11 changed files with 312 additions and 149 deletions

View File

@ -1581,4 +1581,6 @@
moved to Obsoleted/apps/system/sdcard (2016-03-29).
* apps/examples/alarm: Add a simple test of the ALARM iotcl calls
of the RTC driver (2016-04-03).
* apps/examples/nximage: No configuration option to select
greyscale.

View File

@ -129,6 +129,13 @@ config NXWIDGETS_BPP
Supported bits-per-pixel {8, 16, 24, 32}. Default: The smallest
BPP configuration supported by NX.
config NXWIDGETS_GREYSCALE
bool "Greyscale (vs RGB)"
default n
---help---
Select to use a greyscale vs RGB color image. This option is ignored if
CONFIG_NXWIDGETS_BPP > 8
config NXWIDGETS_SIZEOFCHAR
int "Size of a character (1 or 2 bytes)"
range 1 2
@ -1284,3 +1291,4 @@ endmenu # NxWM Media Player Display Settings
endif # NXWM
endmenu # NxWidgets/NxWM

View File

@ -60,6 +60,9 @@
# include <nuttx/lcd/lcd.h>
#else
# include <nuttx/video/fb.h>
# ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
# endif
#endif
#include <nuttx/nx/nx.h>
@ -425,10 +428,10 @@ static inline int nxeg_raise(NXEGWINDOW hwnd)
static inline int nxeg_suinitialize(void)
{
FAR NX_DRIVERTYPE *dev;
int ret;
#if defined(CONFIG_EXAMPLES_NX_EXTERNINIT)
struct boardioc_graphics_s devinfo;
int ret;
/* Use external graphics driver initialization */
@ -449,8 +452,6 @@ static inline int nxeg_suinitialize(void)
dev = devinfo.dev;
#elif defined(CONFIG_NX_LCDDRIVER)
int ret;
/* Initialize the LCD device */
printf("nxeg_initialize: Initializing LCD\n");
@ -476,9 +477,8 @@ static inline int nxeg_suinitialize(void)
/* Turn the LCD on at 75% power */
(void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
#else
int ret;
#else
/* Initialize the frame buffer device */
printf("nxeg_initialize: Initializing framebuffer\n");
@ -515,6 +515,20 @@ static inline int nxeg_suinitialize(void)
g_exitcode = NXEXIT_NXOPEN;
return ERROR;
}
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
nx_close(g_hnx);
g_exitcode = NXEXIT_FBINITIALIZE;
return ERROR;
}
#endif
return OK;
}
#endif
@ -565,6 +579,18 @@ static inline int nxeg_muinitialize(void)
{
pthread_attr_t attr;
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
nx_disconnect(g_hnx);
g_exitcode = NXEXIT_FBINITIALIZE;
return ERROR;
}
#endif
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.
@ -600,6 +626,7 @@ static inline int nxeg_muinitialize(void)
g_exitcode = NXEXIT_NXCONNECT;
return ERROR;
}
return OK;
}
#endif

View File

@ -60,6 +60,9 @@
# include <nuttx/lcd/lcd.h>
#else
# include <nuttx/video/fb.h>
# ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
# endif
#endif
#include <nuttx/nx/nx.h>
@ -124,10 +127,10 @@ struct nxhello_data_s g_nxhello =
static inline int nxhello_initialize(void)
{
FAR NX_DRIVERTYPE *dev;
int ret;
#if defined(CONFIG_EXAMPLES_NXHELLO_EXTERNINIT)
struct boardioc_graphics_s devinfo;
int ret;
/* Use external graphics driver initialization */
@ -148,8 +151,6 @@ static inline int nxhello_initialize(void)
dev = devinfo.dev;
#elif defined(CONFIG_NX_LCDDRIVER)
int ret;
/* Initialize the LCD device */
printf("nxhello_initialize: Initializing LCD\n");
@ -175,9 +176,8 @@ static inline int nxhello_initialize(void)
/* Turn the LCD on at 75% power */
(void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
#else
int ret;
#else
/* Initialize the frame buffer device */
printf("nxhello_initialize: Initializing framebuffer\n");
@ -212,6 +212,21 @@ static inline int nxhello_initialize(void)
g_nxhello.code = NXEXIT_NXOPEN;
return ERROR;
}
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_nxhello.hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
nx_close(g_nxhello.hnx);
g_nxhello.code = NXEXIT_FBINITIALIZE;
return ERROR;
}
#endif
return OK;
}

View File

@ -12,72 +12,79 @@ config EXAMPLES_NXIMAGE
if EXAMPLES_NXIMAGE
config EXAMPLES_NXIMAGE_VPLANE
int "Video Plane"
default 0
---help---
The plane to select from the framebuffer driver for use in the test.
Default: 0
int "Video Plane"
default 0
---help---
The plane to select from the framebuffer driver for use in the test.
Default: 0
config EXAMPLES_NXIMAGE_DEVNO
int "Video Device Number"
default 0
---help---
The LCD device to select from the LCD driver for use in the test:
Default: 0
int "Video Device Number"
default 0
---help---
The LCD device to select from the LCD driver for use in the test:
Default: 0
config EXAMPLES_NXIMAGE_BPP
int "Bits-Per-Pixel"
default 32
---help---
Pixels per pixel to use. Valid options include 1, 2, 4, 8, 16, 24,
and 32. Default is 32.
int "Bits-Per-Pixel"
default 32
---help---
Pixels per pixel to use. Valid options include 1, 2, 4, 8, 16, 24,
and 32. Default is 32.
config EXAMPLES_NXIMAGE_GREYSCALE
bool "Greyscale (vs RGB)"
default n
---help---
Select to use a greyscale vs RGB color image. This option is ignored if
CONFIG_EXAMPLES_NXIMAGE_BPP > 8
config EXAMPLES_NXIMAGE_XSCALEp5
bool "Scale X by 50%"
default n
---help---
Reduce image scale by 50% of its original size.
bool "Scale X by 50%"
default n
---help---
Reduce image scale by 50% of its original size.
config EXAMPLES_NXIMAGE_XSCALE1p0
bool "Don't scale image."
default y
---help---
Keep original image size.
bool "Don't scale image."
default y
---help---
Keep original image size.
config EXAMPLES_NXIMAGE_XSCALE1p5
bool "Scale X by 150%"
default n
---help---
Increase image scale by 50% of its original size.
bool "Scale X by 150%"
default n
---help---
Increase image scale by 50% of its original size.
config EXAMPLES_NXIMAGE_XSCALE2p0
bool "Scale X by 200%"
default n
---help---
Increase image scale by 200% of its original size.
bool "Scale X by 200%"
default n
---help---
Increase image scale by 200% of its original size.
config EXAMPLES_NXIMAGE_YSCALEp5
bool "Scale Y by 50%"
default n
---help---
Reduce image scale by 50% of its original size.
bool "Scale Y by 50%"
default n
---help---
Reduce image scale by 50% of its original size.
config EXAMPLES_NXIMAGE_YSCALE1p0
bool "Don't scale image."
default y
---help---
Keep original image size.
bool "Don't scale image."
default y
---help---
Keep original image size.
config EXAMPLES_NXIMAGE_YSCALE1p5
bool "Scale Y by 150%"
default n
---help---
Increase image scale by 50% of its original size.
bool "Scale Y by 150%"
default n
---help---
Increase image scale by 50% of its original size.
config EXAMPLES_NXIMAGE_YSCALE2p0
bool "Scale Y by 200%"
default n
---help---
Increase image scale by 200% of its original size.
bool "Scale Y by 200%"
default n
---help---
Increase image scale by 200% of its original size.
endif

View File

@ -60,6 +60,9 @@
# include <nuttx/lcd/lcd.h>
#else
# include <nuttx/video/fb.h>
# ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
# endif
#endif
#include <nuttx/nx/nx.h>
@ -128,10 +131,10 @@ struct nximage_data_s g_nximage =
static inline int nximage_initialize(void)
{
FAR NX_DRIVERTYPE *dev;
int ret;
#if defined(CONFIG_EXAMPLES_NXIMAGE_EXTERNINIT)
struct boardioc_graphics_s devinfo;
int ret;
/* Use external graphics driver initialization */
@ -152,8 +155,6 @@ static inline int nximage_initialize(void)
dev = devinfo.dev;
#elif defined(CONFIG_NX_LCDDRIVER)
int ret;
/* Initialize the LCD device */
printf("nximage_initialize: Initializing LCD\n");
@ -180,8 +181,6 @@ static inline int nximage_initialize(void)
(void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
#else
int ret;
/* Initialize the frame buffer device */
printf("nximage_initialize: Initializing framebuffer\n");
@ -213,10 +212,25 @@ static inline int nximage_initialize(void)
if (!g_nximage.hnx)
{
printf("nximage_initialize: nx_open failed: %d\n", errno);
g_nximage.code = NXEXIT_NXOPEN;
return ERROR;
}
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_nximage.hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
g_nximage.code = NXEXIT_FBINITIALIZE;
nx_close(g_nximage.hnx);
return ERROR;
}
#endif
return OK;
}

View File

@ -58,6 +58,9 @@
# include <nuttx/lcd/lcd.h>
#else
# include <nuttx/video/fb.h>
# ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
# endif
#endif
#include <nuttx/nx/nx.h>
@ -120,10 +123,10 @@ struct nxlines_data_s g_nxlines =
static inline int nxlines_initialize(void)
{
FAR NX_DRIVERTYPE *dev;
int ret;
#if defined(CONFIG_EXAMPLES_NXLINES_EXTERNINIT)
struct boardioc_graphics_s devinfo;
int ret;
/* Use external graphics driver initialization */
@ -144,8 +147,6 @@ static inline int nxlines_initialize(void)
dev = devinfo.dev;
#elif defined(CONFIG_NX_LCDDRIVER)
int ret;
/* Initialize the LCD device */
printf("nxlines_initialize: Initializing LCD\n");
@ -172,8 +173,6 @@ static inline int nxlines_initialize(void)
(void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
#else
int ret;
/* Initialize the frame buffer device */
printf("nxlines_initialize: Initializing framebuffer\n");
@ -211,6 +210,19 @@ static inline int nxlines_initialize(void)
return ERROR;
}
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_nxlines.hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
nx_close(g_nxlines.hnx);
g_nxlines.code = NXEXIT_FBINITIALIZE;
return ERROR;
}
#endif
return OK;
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
* examples/nxterm/nxterm_main.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -55,6 +55,9 @@
# include <nuttx/lcd/lcd.h>
#else
# include <nuttx/video/fb.h>
# ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
# endif
#endif
#include <nuttx/arch.h>
@ -140,6 +143,16 @@ static int nxterm_initialize(void)
{
pthread_attr_t attr;
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_nxterm_vars.hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
return ERROR;
}
#endif
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.

View File

@ -60,6 +60,9 @@
# include <nuttx/lcd/lcd.h>
#else
# include <nuttx/video/fb.h>
# ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
# endif
#endif
#include <nuttx/nx/nx.h>
@ -166,10 +169,10 @@ int g_exitcode = NXEXIT_SUCCESS;
static inline int nxtext_suinitialize(void)
{
FAR NX_DRIVERTYPE *dev;
int ret;
#if defined(CONFIG_EXAMPLES_NXTEXT_EXTERNINIT)
struct boardioc_graphics_s devinfo;
int ret;
/* Use external graphics driver initialization */
@ -190,8 +193,6 @@ static inline int nxtext_suinitialize(void)
dev = devinfo.dev;
#elif defined(CONFIG_NX_LCDDRIVER)
int ret;
/* Initialize the LCD device */
printf("nxtext_initialize: Initializing LCD\n");
@ -217,9 +218,8 @@ static inline int nxtext_suinitialize(void)
/* Turn the LCD on at 75% power */
(void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
#else
int ret;
#else
/* Initialize the frame buffer device */
printf("nxtext_initialize: Initializing framebuffer\n");
@ -257,6 +257,20 @@ static inline int nxtext_suinitialize(void)
return ERROR;
}
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, g_hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
nx_close(g_hnx);
g_exitcode = NXEXIT_FBINITIALIZE;
return ERROR;
}
#endif
return OK;
}
#endif
@ -305,43 +319,58 @@ static inline int nxtext_muinitialize(void)
g_hnx = nx_connect();
if (g_hnx)
{
pthread_attr_t attr;
pthread_attr_t attr;
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.
*/
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
(void)pthread_attr_init(&attr);
param.sched_priority = CONFIG_EXAMPLES_NXTEXT_LISTENERPRIO;
(void)pthread_attr_setschedparam(&attr, &param);
(void)pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NXTEXT_STACKSIZE);
ret = vnc_default_fbinitialize(0, g_hnx);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
ret = pthread_create(&thread, &attr, nxtext_listener, NULL);
if (ret != 0)
{
printf("nxtext_initialize: pthread_create failed: %d\n", ret);
g_exitcode = NXEXIT_PTHREADCREATE;
return ERROR;
}
g_exitcode = NXEXIT_FBINITIALIZE;
return ERROR;
}
#endif
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.
*/
/* Don't return until we are connected to the server */
(void)pthread_attr_init(&attr);
param.sched_priority = CONFIG_EXAMPLES_NXTEXT_LISTENERPRIO;
(void)pthread_attr_setschedparam(&attr, &param);
(void)pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NXTEXT_STACKSIZE);
while (!g_connected)
{
/* Wait for the listener thread to wake us up when we really
* are connected.
*/
ret = pthread_create(&thread, &attr, nxtext_listener, NULL);
if (ret != 0)
{
printf("nxtext_initialize: pthread_create failed: %d\n", ret);
(void)sem_wait(&g_semevent);
}
g_exitcode = NXEXIT_PTHREADCREATE;
return ERROR;
}
/* Don't return until we are connected to the server */
while (!g_connected)
{
/* Wait for the listener thread to wake us up when we really
* are connected.
*/
(void)sem_wait(&g_semevent);
}
}
else
{
printf("nxtext_initialize: nx_connect failed: %d\n", errno);
g_exitcode = NXEXIT_NXCONNECT;
return ERROR;
}
return OK;
}
#endif

View File

@ -1,7 +1,7 @@
/****************************************************************************
* apps/examples/screenshot/screenshot_main.c
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Petteri Aimonen <jpa@kapsi.fi>
*
@ -38,19 +38,24 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdbool.h>
#include <string.h>
#include <semaphore.h>
#include <errno.h>
#include <apps/tiff.h>
#include <semaphore.h>
#include <nuttx/config.h>
#include <nuttx/nx/nx.h>
#ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
#endif
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
@ -118,15 +123,15 @@ static void replace_extension(FAR const char *filename, FAR const char *newext,
int save_screenshot(FAR const char *filename)
{
struct tiff_info_s info;
FAR uint8_t *strip;
int row;
int ret;
char tempf1[64];
char tempf2[64];
NXHANDLE server;
NXWINDOW window;
struct nx_callback_s cb = {};
struct nxgl_size_s size = {CONFIG_SCREENSHOT_WIDTH, CONFIG_SCREENSHOT_HEIGHT};
FAR uint8_t *strip;
NXHANDLE server;
NXWINDOW window;
char tempf1[64];
char tempf2[64];
int row;
int ret;
replace_extension(filename, ".tm1", tempf1, sizeof(tempf1));
replace_extension(filename, ".tm2", tempf2, sizeof(tempf2));
@ -135,19 +140,31 @@ int save_screenshot(FAR const char *filename)
server = nx_connect();
if (!server)
{
perror("nx_connect");
return 1;
}
{
perror("nx_connect");
return 1;
}
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, server);
if (ret < 0)
{
printf("vnc_default_fbinitialize failed: %d\n", ret);
nx_disconnect(server);
return 1;
}
#endif
/* Wait for "connected" event */
if (nx_eventhandler(server) < 0)
{
perror("nx_eventhandler");
nx_disconnect(server);
return 1;
}
{
perror("nx_eventhandler");
nx_disconnect(server);
return 1;
}
/* Open invisible dummy window for communication */

View File

@ -46,10 +46,15 @@
#include "trv_graphics.h"
#include <string.h>
#ifdef CONFIG_NX_MULTIUSER
# include <semaphore.h>
#endif
#ifdef CONFIG_VNCSERVER
# include <nuttx/video/vnc.h>
#endif
/****************************************************************************
* Public Data
****************************************************************************/
@ -202,6 +207,17 @@ static inline int trv_nxsu_initialize(FAR struct trv_graphics_info_s *ginfo)
trv_abort("trv_nxsu_initialize: nx_open failed: %d\n", errno);
}
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
ret = vnc_default_fbinitialize(0, ginfo->hnx);
if (ret < 0)
{
nx_close(ginfo->hnx);
trv_abort("vnc_default_fbinitialize failed: %d\n", ret);
}
#endif
/* And use the background window */
trv_use_bgwindow(ginfo);
@ -247,9 +263,7 @@ static inline int trv_nxmu_initialize(FAR struct trv_graphics_info_s *ginfo)
ret = sched_setparam(0, &param);
if (ret < 0)
{
printf("nxeg_initialize: sched_setparam failed: %d\n" , ret);
g_exitcode = NXEXIT_SCHEDSETPARAM;
return ERROR;
trv_abort("nxeg_initialize: sched_setparam failed: %d\n" , ret);
}
/* Start the server task */
@ -259,9 +273,8 @@ static inline int trv_nxmu_initialize(FAR struct trv_graphics_info_s *ginfo)
CONFIG_EXAMPLES_NX_STACKSIZE, trv_servertask, NULL);
if (servrid < 0)
{
printf("nxeg_initialize: Failed to create trv_servertask task: %d\n", errno);
g_exitcode = NXEXIT_TASKCREATE;
return ERROR;
trv_abort("nxeg_initialize: Failed to create trv_servertask task: %d\n",
errno);
}
/* Wait a bit to let the server get started */
@ -273,42 +286,48 @@ static inline int trv_nxmu_initialize(FAR struct trv_graphics_info_s *ginfo)
ginfo->hnx = nx_connect();
if (ginfo->hnx)
{
pthread_attr_t attr;
pthread_attr_t attr;
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.
*/
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
(void)pthread_attr_init(&attr);
param.sched_priority = CONFIG_EXAMPLES_NX_LISTENERPRIO;
(void)pthread_attr_setschedparam(&attr, &param);
(void)pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NX_STACKSIZE);
ret = vnc_default_fbinitialize(0, ginfo->hnx);
if (ret < 0)
{
trv_abort("vnc_default_fbinitialize failed: %d\n", ret);
}
#endif
ret = pthread_create(&thread, &attr, trv_nxlistener, NULL);
if (ret != 0)
{
printf("nxeg_initialize: pthread_create failed: %d\n", ret);
g_exitcode = NXEXIT_PTHREADCREATE;
return ERROR;
}
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.
*/
/* Don't return until we are connected to the server */
(void)pthread_attr_init(&attr);
param.sched_priority = CONFIG_EXAMPLES_NX_LISTENERPRIO;
(void)pthread_attr_setschedparam(&attr, &param);
(void)pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NX_STACKSIZE);
while (!g_trv_nxrconnected)
{
/* Wait for the listener thread to wake us up when we really
* are connected.
*/
ret = pthread_create(&thread, &attr, trv_nxlistener, NULL);
if (ret != 0)
{
trv_abort("nxeg_initialize: pthread_create failed: %d\n", ret);
}
(void)sem_wait(&g_trv_nxevent);
}
/* Don't return until we are connected to the server */
while (!g_trv_nxrconnected)
{
/* Wait for the listener thread to wake us up when we really
* are connected.
*/
(void)sem_wait(&g_trv_nxevent);
}
}
else
{
printf("nxeg_initialize: nx_connect failed: %d\n", errno);
g_exitcode = NXEXIT_NXCONNECT;
return ERROR;
trv_abort("nxeg_initialize: nx_connect failed: %d\n", errno);
}
/* And use the background window */