Skip to content

Commit

Permalink
#488 added set functions to parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
knmcguire committed Jun 30, 2020
1 parent 3a53e7b commit 913324c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/modules/interface/param.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ uint8_t paramVarSize(int type);
float paramGetFloat(int varid);
int paramGetInt(int varid);
unsigned int paramGetUint(int varid);
void paramSetInt(int varid, int valuei);
void paramSetFloat(int varid, float valuef);


/* Basic parameter structure */
struct param_s {
Expand Down
44 changes: 44 additions & 0 deletions src/modules/src/param.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,3 +667,47 @@ unsigned int paramGetUint(int varid)
{
return (unsigned int)paramGetInt(varid);
}

void paramSetInt(int varid, int valuei)
{
ASSERT(varid >= 0);

switch(params[varid].type)
{
case PARAM_UINT8:
*(uint8_t *)params[varid].address = (uint8_t) valuei;
break;
case PARAM_INT8:
*(int8_t *)params[varid].address = (int8_t) valuei;
break;
case PARAM_UINT16:
*(uint16_t *)params[varid].address = (uint16_t) valuei;
break;
case PARAM_INT16:
*(int16_t *)params[varid].address = (int16_t) valuei;
break;
case PARAM_UINT32:
*(uint32_t *)params[varid].address = (uint32_t) valuei;
break;
case PARAM_INT32:
*(int32_t *)params[varid].address = (int32_t) valuei;
break;
case PARAM_FLOAT:
// Todo: are floats handy to have here?
*(float *)params[varid].address = (float) valuei;

break;
}
}

void paramSetFloat(int varid, float valuef)
{
ASSERT(varid >= 0);

if (params[varid].type == PARAM_FLOAT )
*(float *)params[varid].address = valuef;
}




0 comments on commit 913324c

Please sign in to comment.