Update of /cvsroot/playerstage/code/player/client_libs/libplayerc
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15262/client_libs/libplayerc
Modified Files:
Makefile.am dev_ir.c dev_vectormap.c playerc.h
Added Files:
dev_blinkenlight.c
Log Message:
added chatterbox driver, fixed build bug in libplayerc/dev_vectormap.c, fixed
shallow copy bug in libplayerc/dev_ir.c
Index: dev_vectormap.c
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc/dev_vectormap.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** dev_vectormap.c 4 Feb 2008 18:59:43 -0000 1.5
--- dev_vectormap.c 7 Feb 2008 02:22:59 -0000 1.6
***************
*** 109,113 ****
--- 109,115 ----
if (device->geom)
{
+ #ifdef HAVE_GEOS
GEOSGeom_destroy(device->geom);
+ #endif
device->geom = NULL;
}
--- NEW FILE: dev_blinkenlight.c ---
/*
* libplayerc : a Player client library
* dev_blinkenlight.c - interface to a Player blinkenlight device
* Copyright (C) Richard Vaughan 2008, based on examples by Andrew Howard
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <string.h>
#include <stdlib.h>
#include "playerc.h"
#include "error.h"
// Local declarations
void playerc_blinkenlight_putmsg(playerc_blinkenlight_t *device,
player_msghdr_t *header,
void* data, size_t len);
// Create an blinkenlight proxy
playerc_blinkenlight_t *playerc_blinkenlight_create(playerc_client_t *client,
int index)
{
playerc_blinkenlight_t *device;
device = malloc(sizeof(playerc_blinkenlight_t));
memset(device, 0, sizeof(playerc_blinkenlight_t));
playerc_device_init(&device->info, client, PLAYER_BLINKENLIGHT_CODE, index,
(playerc_putmsg_fn_t) playerc_blinkenlight_putmsg);
return device;
}
// Destroy an blinkenlight proxy
void playerc_blinkenlight_destroy(playerc_blinkenlight_t *device)
{
playerc_device_term(&device->info);
free(device);
}
// Subscribe to the blinkenlight device
int playerc_blinkenlight_subscribe(playerc_blinkenlight_t *device, int access)
{
return playerc_device_subscribe(&device->info, access);
}
// Un-subscribe from the blinkenlight device
int playerc_blinkenlight_unsubscribe(playerc_blinkenlight_t *device)
{
return playerc_device_unsubscribe(&device->info);
}
void playerc_blinkenlight_putmsg(playerc_blinkenlight_t *device,
player_msghdr_t *header,
void* data, size_t len)
{
int i = 0;
if((header->type == PLAYER_MSGTYPE_DATA) &&
(header->subtype == PLAYER_BLINKENLIGHT_DATA_STATE))
{
player_blinkenlight_data_t* blink = (player_blinkenlight_data_t*)data;
device->enabled = blink->enable;
device->duty_cycle = blink->dutycycle;
device->period = blink->period;
device->red = blink->color.red;
device->green = blink->color.green;
device->blue = blink->color.blue;
}
else
PLAYERC_WARN2("skipping blinkenlight message with unknown type/subtype:
%s/%d\n",
msgtype_to_str(header->type), header->subtype);
}
/** Set the light color. The light should probably also be enabled before you
see it.*/
int playerc_blinkenlight_color( playerc_blinkenlight_t *device,
uint32_t id,
uint8_t red,
uint8_t green,
uint8_t blue )
{
player_blinkenlight_cmd_color_t cmd;
memset( &cmd, 0, sizeof(cmd));
cmd.id = id;
cmd.color.red = red;
cmd.color.green = green;
cmd.color.blue = blue;
return playerc_client_write( device->info.client,
&device->info,
PLAYER_BLINKENLIGHT_CMD_COLOR,
&cmd, NULL);
}
/** Turn the light on and off (may not be visible when on depending on the
color).*/
int playerc_blinkenlight_enable( playerc_blinkenlight_t *device,
uint32_t enable )
{
player_blinkenlight_cmd_power_t cmd;
memset( &cmd, 0, sizeof(cmd));
cmd.enable = enable;
return playerc_client_write( device->info.client,
&device->info,
PLAYER_BLINKENLIGHT_CMD_POWER,
&cmd, NULL);
}
/** Set the light flashing by specifying the period in seconds and the
mark/space ratio (0.0 to 1.0) */
int playerc_blinkenlight_blink( playerc_blinkenlight_t *device,
uint32_t id,
float period,
float duty_cycle )
{
player_blinkenlight_cmd_flash_t cmd;
memset( &cmd, 0, sizeof(cmd));
cmd.id = id;
cmd.period = period;
cmd.dutycycle = duty_cycle;
return playerc_client_write( device->info.client,
&device->info,
PLAYER_BLINKENLIGHT_CMD_FLASH,
&cmd, NULL);
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/Makefile.am,v
retrieving revision 1.102
retrieving revision 1.103
diff -C2 -d -r1.102 -r1.103
*** Makefile.am 26 Sep 2007 23:07:44 -0000 1.102
--- Makefile.am 7 Feb 2008 02:22:59 -0000 1.103
***************
*** 28,31 ****
--- 28,32 ----
dev_audio.c \
dev_blackboard.c \
+ dev_blinkenlight.c \
dev_bumper.c \
dev_blobfinder.c \
Index: playerc.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/playerc.h,v
retrieving revision 1.251
retrieving revision 1.252
diff -C2 -d -r1.251 -r1.252
*** playerc.h 6 Feb 2008 19:38:35 -0000 1.251
--- playerc.h 7 Feb 2008 02:22:59 -0000 1.252
***************
*** 1170,1173 ****
--- 1170,1226 ----
/** @} */
+ /**************************************************************************/
+ /** @ingroup playerc_proxies
+ * @defgroup playerc_proxy_blinkenlight blinkenlight
+
+ The blinkenlight proxy provides an interface to a (possibly colored
+ and/or blinking) indicator light.
+
+ @{
+ */
+
+ /** Blinklight proxy data. */
+ typedef struct
+ {
+ /** Device info; must be at the start of all device structures. */
+ playerc_device_t info;
+
+ uint32_t enabled;
+ double duty_cycle;
+ double period;
+ uint8_t red, green, blue;
+ } playerc_blinkenlight_t;
+
+
+ /** Create a blinkenlight proxy. */
+ playerc_blinkenlight_t *playerc_blinkenlight_create(playerc_client_t *client,
int index);
+
+ /** Destroy a blinkenlight proxy. */
+ void playerc_blinkenlight_destroy(playerc_blinkenlight_t *device);
+
+ /** Subscribe to the blinkenlight device. */
+ int playerc_blinkenlight_subscribe(playerc_blinkenlight_t *device, int
access);
+
+ /** Un-subscribe from the blinkenlight device. */
+ int playerc_blinkenlight_unsubscribe(playerc_blinkenlight_t *device);
+
+ /** Enable/disable power to the blinkenlight device. */
+ int playerc_blinkenlight_enable( playerc_blinkenlight_t *device,
+ uint32_t enable );
+
+ /** Set the output color for the blinkenlight device. */
+ int playerc_blinkenlight_color( playerc_blinkenlight_t *device,
+ uint32_t id,
+ uint8_t red,
+ uint8_t green,
+ uint8_t blue );
+ /** Make the light blink, setting the period in seconds and the
+ mark/space ratiom (0.0 to 1.0). */
+ int playerc_blinkenlight_blink( playerc_blinkenlight_t *device,
+ uint32_t id,
+ float period,
+ float duty_cycle );
+ /** @} */
+
/***************************************************************************/
/** @ingroup playerc_proxies
***************
*** 1753,1757 ****
// data
! player_ir_data_t ranges;
// config
--- 1806,1810 ----
// data
! player_ir_data_t data;
// config
Index: dev_ir.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/dev_ir.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** dev_ir.c 24 Oct 2007 22:32:02 -0000 1.9
--- dev_ir.c 7 Feb 2008 02:22:59 -0000 1.10
***************
*** 39,43 ****
/***************************************************************************
* Desc: ir proxy
! * Author: Toby Collett (based on ir proxy by Andrew Howard)
* Date: 13 Feb 2004
* CVS: $Id$
--- 39,43 ----
/***************************************************************************
* Desc: ir proxy
! * Author: Toby Collett (based on ir proxy by Andrew Howard), Richard Vaughan
* Date: 13 Feb 2004
* CVS: $Id$
***************
*** 67,70 ****
--- 67,71 ----
device = malloc(sizeof(playerc_ir_t));
memset(device, 0, sizeof(playerc_ir_t));
+
playerc_device_init(&device->info, client, PLAYER_IR_CODE, index,
(playerc_putmsg_fn_t) playerc_ir_putmsg);
***************
*** 101,110 ****
void *data)
{
- //int i;
if((header->type == PLAYER_MSGTYPE_DATA) &&
(header->subtype == PLAYER_IR_DATA_RANGES))
! {
! device->ranges = *(player_ir_data_t *) data;
! }
}
--- 102,110 ----
void *data)
{
if((header->type == PLAYER_MSGTYPE_DATA) &&
(header->subtype == PLAYER_IR_DATA_RANGES))
! {
! player_ir_data_t_copy( &device->data,(player_ir_data_t *)data );
! }
}
***************
*** 124,127 ****
}
-
-
--- 124,125 ----
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit