cpled.c File Reference


Detailed Description

AVR32 UC3 Control Panel leds actuators module.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file cpled.c.

#include <string.h>
#include "compiler.h"
#include "FreeRTOS.h"
#include "datalog.h"
#include "shell.h"
#include "board.h"
#include "supervisor.h"
#include "cptime.h"
#include "actuator.h"
#include "cpled.h"

Go to the source code of this file.

Functions

Bool b_ledb1_get_value (xLogDef *pxLog)
 Get the ledb1 current value.
Bool b_ledb2_get_value (xLogDef *pxLog)
 Get the ledb2 current value.
Bool b_ledm1_get_value (xLogDef *pxLog)
 Get the ledm1 current value.
Bool b_ledm2_get_value (xLogDef *pxLog)
 Get the ledm2 current value.
eExecStatus e_ledb1_set_value (eModId xModId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The set bicolor ledb1 value command: set the value of the bicolor ledb1. Takes up to six parameters the first parameter is the green parameter, the second parameter is its value in [0,255], the third parameter is the red parameter, the fourth parameter is its value in [0,255], the fifth is the time parameter(optional), the sixth is the time value(optional) expressed in seconds. Format: set_actuator_value actuator=actuatorname green=value red=value [time=date].
eExecStatus e_ledb2_set_value (eModId xModId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The set bicolor ledb2 value command: set the value of the bicolor ledb2. Takes up to six parameters the first parameter is the green parameter, the second parameter is its value in [0,255], the third parameter is the red parameter, the fourth parameter is its value in [0,255], the fifth is the time parameter(optional), the sixth is the time value(optional) expressed in seconds. Format: set_actuator_value actuator=actuatorname green=value red=value [time=date].
eExecStatus e_ledm1_set_value (eModId xModId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
eExecStatus e_ledm2_set_value (eModId xModId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The set monocolor led2 value command: set the value of the monocolor led2. Takes up to four parameters the first parameter is the state parameter, the second parameter is its value(on/off), the third is the time parameter(optional), the fourth is the time value(optional). Format: set_actuator_value actuator=actuatorname state=value [time=date].
int sprintf (char *out, const char *format,...)

Variables

const signed portCHAR *const CPLED_OFF_STR = (signed portCHAR *)"off"
const signed portCHAR *const CPLED_ON_STR = (signed portCHAR *)"on"


Function Documentation

Bool b_ledb1_get_value ( xLogDef pxLog  ) 

Get the ledb1 current value.

Parameters:
pxLog a Log structure.
Returns:
TRUE upon success, FALSE if error.

Definition at line 121 of file cpled.c.

References LEDB1G, LEDB1R, LogDef::pcStringLog, LogDef::pfFreeStringLog, and sprintf().

00122 {
00123    // Alloc memory for the log string.
00124    pxLog->pcStringLog = pvPortMalloc( 8*sizeof( char ) );
00125    if( NULL == pxLog->pcStringLog )
00126    {
00127       return( FALSE );
00128    }
00129    pxLog->pfFreeStringLog = vPortFree; // Because pvPortMalloc() was used to
00130                                        // alloc the log string.
00131    // Build the log string.
00132    sprintf( pxLog->pcStringLog, "%d,%d", LED_Get_Intensity( LEDB1G ),
00133             LED_Get_Intensity( LEDB1R ) );
00134 
00135    return( TRUE );
00136 }

Bool b_ledb2_get_value ( xLogDef pxLog  ) 

Get the ledb2 current value.

Parameters:
pxLog a Log structure.
Returns:
TRUE upon success, FALSE if error.

Definition at line 146 of file cpled.c.

References LEDB2G, LEDB2R, LogDef::pcStringLog, LogDef::pfFreeStringLog, and sprintf().

00147 {
00148    // Alloc memory for the log string.
00149    pxLog->pcStringLog = pvPortMalloc( 8*sizeof( char ) );
00150    if( NULL == pxLog->pcStringLog )
00151    {
00152       return( FALSE );
00153    }
00154    pxLog->pfFreeStringLog = vPortFree; // Because pvPortMalloc() was used to
00155                                        // alloc the log string.
00156    // Build the log string.
00157    sprintf( pxLog->pcStringLog, "%d,%d", LED_Get_Intensity( LEDB2G ),
00158             LED_Get_Intensity( LEDB2R ) );
00159 
00160    return( TRUE );
00161 }

Bool b_ledm1_get_value ( xLogDef pxLog  ) 

Get the ledm1 current value.

Parameters:
pxLog a Log structure.
Returns:
TRUE upon success, FALSE if error.

Definition at line 81 of file cpled.c.

References CPLED_OFF_STR, CPLED_ON_STR, LEDM1, LogDef::pcStringLog, and LogDef::pfFreeStringLog.

00082 {
00083    // Build the log string.
00084    if( LED_Test( LEDM1 ) )
00085       pxLog->pcStringLog = (char *)CPLED_ON_STR;
00086    else
00087       pxLog->pcStringLog = (char *)CPLED_OFF_STR;
00088    pxLog->pfFreeStringLog = NULL; // We use a constant
00089 
00090    return( TRUE );
00091 }

Bool b_ledm2_get_value ( xLogDef pxLog  ) 

Get the ledm2 current value.

Parameters:
pxLog a Log structure.
Returns:
TRUE upon success, FALSE if error.

Definition at line 101 of file cpled.c.

References CPLED_OFF_STR, CPLED_ON_STR, LEDM2, LogDef::pcStringLog, and LogDef::pfFreeStringLog.

00102 {
00103    // Build the log string.
00104    if( LED_Test( LEDM2 ) )
00105       pxLog->pcStringLog = (char *)CPLED_ON_STR;
00106    else
00107       pxLog->pcStringLog = (char *)CPLED_OFF_STR;
00108    pxLog->pfFreeStringLog = NULL; // We use a constant
00109 
00110    return( TRUE );
00111 }

eExecStatus e_ledb1_set_value ( eModId  xModId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The set bicolor ledb1 value command: set the value of the bicolor ledb1. Takes up to six parameters the first parameter is the green parameter, the second parameter is its value in [0,255], the third parameter is the red parameter, the fourth parameter is its value in [0,255], the fifth is the time parameter(optional), the sixth is the time value(optional) expressed in seconds. Format: set_actuator_value actuator=actuatorname green=value red=value [time=date].

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
ac Input. The argument counter. For this command, should be at least 4, at most 6.
av Input. The argument vector.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 309 of file cpled.c.

References ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR, CPTIME_SCHEDCMDID_SETLEDB1VAL, e_actuator_ScheduleCmdSet(), LEDB1G, LEDB1R, SHELL_EXECSTATUS_KO, and SHELL_EXECSTATUS_OK.

Referenced by vExecScheduledSet().

00311 {
00312    /* 1) Check the input. */
00313    //  i) Arguments: at least 4, at most 6.
00314    if( ( 4 > ac ) || ( 6 < ac ) )
00315    {   // Syntax error.
00316       *ppcStringReply = (signed portCHAR *)ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR;
00317       return( SHELL_EXECSTATUS_KO );
00318    }
00319 
00320    //  ii) Check that the 1st arg is 'green' and that the 3rd is 'red'.
00321    if( strcmp( (char *)av[0], "green" ) || strcmp( (char *)av[2], "red" ))
00322    {
00323       *ppcStringReply = (signed portCHAR *)ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR;
00324       return( SHELL_EXECSTATUS_KO );
00325    }
00326 
00327    //  iii) If there is a fifth parameter, check that it is equal to "time" and
00328    // record a new scheduling.
00329    if( 6 == ac )
00330    {
00331       return( e_actuator_ScheduleCmdSet( CPTIME_SCHEDCMDID_SETLEDB1VAL, ac, av, ppcStringReply ) );
00332    }
00333 
00334    /* 2) Set the val. */
00335    LED_Set_Intensity( LEDB1G, atoi( (char *)av[1] ) );
00336    LED_Set_Intensity( LEDB1R, atoi( (char *)av[3] ) );
00337 
00338    return( SHELL_EXECSTATUS_OK );
00339 }

eExecStatus e_ledb2_set_value ( eModId  xModId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The set bicolor ledb2 value command: set the value of the bicolor ledb2. Takes up to six parameters the first parameter is the green parameter, the second parameter is its value in [0,255], the third parameter is the red parameter, the fourth parameter is its value in [0,255], the fifth is the time parameter(optional), the sixth is the time value(optional) expressed in seconds. Format: set_actuator_value actuator=actuatorname green=value red=value [time=date].

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
ac Input. The argument counter. For this command, should be at least 4, at most 6.
av Input. The argument vector.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 363 of file cpled.c.

References ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR, CPTIME_SCHEDCMDID_SETLEDB2VAL, e_actuator_ScheduleCmdSet(), LEDB2G, LEDB2R, SHELL_EXECSTATUS_KO, and SHELL_EXECSTATUS_OK.

Referenced by vExecScheduledSet().

00365 {
00366    /* 1) Check the input. */
00367    //  i) Arguments: at least 4, at most 6.
00368    if( ( 4 > ac ) || ( 6 < ac ) )
00369    {   // Syntax error.
00370       *ppcStringReply = (signed portCHAR *)ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR;
00371       return( SHELL_EXECSTATUS_KO );
00372    }
00373 
00374    //  ii) Check that the 1st arg is 'green' and that the 3rd is 'red'.
00375    if( strcmp( (char *)av[0], "green" ) || strcmp( (char *)av[2], "red" ))
00376    {
00377       *ppcStringReply = (signed portCHAR *)ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR;
00378       return( SHELL_EXECSTATUS_KO );
00379    }
00380 
00381    //  iii) If there is a fifth parameter, check that it is equal to "time" and
00382    // record a new scheduling.
00383    if( 6 == ac )
00384    {
00385       return( e_actuator_ScheduleCmdSet( CPTIME_SCHEDCMDID_SETLEDB2VAL, ac, av, ppcStringReply ) );
00386    }
00387 
00388    /* 2) Set the val. */
00389    LED_Set_Intensity( LEDB2G, atoi( (char *)av[1] ) );
00390    LED_Set_Intensity( LEDB2R, atoi( (char *)av[3] ) );
00391 
00392    return( SHELL_EXECSTATUS_OK );
00393 }

eExecStatus e_ledm1_set_value ( eModId  xModId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

Definition at line 183 of file cpled.c.

References ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR, CPLED_OFF_STR, CPLED_ON_STR, CPTIME_SCHEDCMDID_SETLEDM1VAL, e_actuator_ScheduleCmdSet(), LEDM1, SHELL_EXECSTATUS_KO, and SHELL_EXECSTATUS_OK.

Referenced by vExecScheduledSet().

00185 {
00186    /* 1) Check the input. */
00187    //  i) Arguments: at least 2, at most 4.
00188    if( ( 2 > ac ) || ( 4 < ac ) )
00189    {   // Syntax error.
00190       *ppcStringReply = (signed portCHAR *)ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR;
00191       return( SHELL_EXECSTATUS_KO );
00192    }
00193 
00194    //  ii) Check that the 1st arg is state.
00195    if( strcmp( (char *)av[0], "state" ) )
00196    {
00197       *ppcStringReply = (signed portCHAR *)ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR;
00198       return( SHELL_EXECSTATUS_KO );
00199    }
00200 
00201    //  iii) If there is a third parameter, check that it is equal to "time" and
00202    // record a new scheduling.
00203    if( 4 == ac )
00204    {
00205       return( e_actuator_ScheduleCmdSet( CPTIME_SCHEDCMDID_SETLEDM1VAL, ac, av, ppcStringReply ) );
00206    }
00207 
00208    if( !strcmp( (char *)av[1], (char *)CPLED_ON_STR ) )
00209    {
00210       LED_On( LEDM1 );
00211    }
00212    else if( !strcmp( (char *)av[1], (char *)CPLED_OFF_STR ) )
00213    {
00214       LED_Off( LEDM1 );
00215    }
00216    else
00217    {
00218       *ppcStringReply = (signed portCHAR *)ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR;
00219       return( SHELL_EXECSTATUS_KO );
00220    }
00221    return( SHELL_EXECSTATUS_OK );
00222 }

eExecStatus e_ledm2_set_value ( eModId  xModId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The set monocolor led2 value command: set the value of the monocolor led2. Takes up to four parameters the first parameter is the state parameter, the second parameter is its value(on/off), the third is the time parameter(optional), the fourth is the time value(optional). Format: set_actuator_value actuator=actuatorname state=value [time=date].

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
ac Input. The argument counter. For this command, should be at least 2, at most 4.
av Input. The argument vector.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 245 of file cpled.c.

References ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR, CPLED_OFF_STR, CPLED_ON_STR, CPTIME_SCHEDCMDID_SETLEDM2VAL, e_actuator_ScheduleCmdSet(), LEDM2, SHELL_EXECSTATUS_KO, and SHELL_EXECSTATUS_OK.

Referenced by vExecScheduledSet().

00247 {
00248    /* 1) Check the input. */
00249    //  i) Arguments: at least 2, at most 4.
00250    if( ( 2 > ac ) || ( 4 < ac ) )
00251    {   // Syntax error.
00252       *ppcStringReply = (signed portCHAR *)ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR;
00253       return( SHELL_EXECSTATUS_KO );
00254    }
00255 
00256    //  ii) Check that the 1st arg is state.
00257    if( strcmp( (char *)av[0], "state" ) )
00258    {
00259       *ppcStringReply = (signed portCHAR *)ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR;
00260       return( SHELL_EXECSTATUS_KO );
00261    }
00262 
00263    //  iii) If there is a third parameter, check that it is equal to "time" and
00264    // record a new scheduling.
00265    if( 4 == ac )
00266    {
00267       return( e_actuator_ScheduleCmdSet( CPTIME_SCHEDCMDID_SETLEDM2VAL, ac, av, ppcStringReply ) );
00268    }
00269 
00270    if( !strcmp( (char *)av[1], (char *)CPLED_ON_STR ) )
00271    {
00272       LED_On( LEDM2 );
00273    }
00274    else if( !strcmp( (char *)av[1], (char *)CPLED_OFF_STR ) )
00275    {
00276       LED_Off( LEDM2 );
00277    }
00278    else
00279    {
00280       *ppcStringReply = (signed portCHAR *)ACTUATOR_ERRMSG_SETVAL_SYNTAXERROR;
00281       return( SHELL_EXECSTATUS_KO );
00282    }
00283    return( SHELL_EXECSTATUS_OK );
00284 }

int sprintf ( char *  out,
const char *  format,
  ... 
)


Variable Documentation

const signed portCHAR* const CPLED_OFF_STR = (signed portCHAR *)"off"

Definition at line 67 of file cpled.c.

Referenced by b_ledm1_get_value(), b_ledm2_get_value(), e_ledm1_set_value(), and e_ledm2_set_value().

const signed portCHAR* const CPLED_ON_STR = (signed portCHAR *)"on"

Definition at line 68 of file cpled.c.

Referenced by b_ledm1_get_value(), b_ledm2_get_value(), e_ledm1_set_value(), and e_ledm2_set_value().


Generated on Fri Feb 19 02:22:43 2010 for AVR32 - Control Panel demonstration. by  doxygen 1.5.5