add support for float type 'flt '

This commit is contained in:
Denis Ahrens
2018-02-21 16:37:02 +01:00
parent 2308d9b194
commit cbe7057bb2
2 changed files with 9 additions and 0 deletions

View File

@ -199,6 +199,11 @@ void printPWM(SMCVal_t val)
printf("%.1f%% ", ntohs(*(UInt16*)val.bytes) * 100 / 65536.0); printf("%.1f%% ", ntohs(*(UInt16*)val.bytes) * 100 / 65536.0);
} }
void printFLT(SMCVal_t val)
{
printf("%f ", *(float*)val.bytes);
}
void printBytesHex(SMCVal_t val) void printBytesHex(SMCVal_t val)
{ {
int i; int i;
@ -262,6 +267,8 @@ void printVal(SMCVal_t val)
printSI16(val); printSI16(val);
else if (strcmp(val.dataType, DATATYPE_PWM) == 0 && val.dataSize == 2) else if (strcmp(val.dataType, DATATYPE_PWM) == 0 && val.dataSize == 2)
printPWM(val); printPWM(val);
else if (strcmp(val.dataType, DATATYPE_FLT) == 0 && val.dataSize == 4)
printFLT(val);
printBytesHex(val); printBytesHex(val);
} }

View File

@ -68,6 +68,8 @@
#define DATATYPE_SI8 "si8 " #define DATATYPE_SI8 "si8 "
#define DATATYPE_SI16 "si16" #define DATATYPE_SI16 "si16"
#define DATATYPE_FLT "flt "
#define DATATYPE_PWM "{pwm" #define DATATYPE_PWM "{pwm"
typedef struct { typedef struct {