From 7ea2001e4987dc2c712dc9d19ace5810828f5302 Mon Sep 17 00:00:00 2001 From: Denis Ahrens Date: Sun, 3 Feb 2013 04:38:00 +0100 Subject: [PATCH] add '{pwm' decoding support --- smc-command/smc.c | 7 +++++++ smc-command/smc.h | 1 + 2 files changed, 8 insertions(+) diff --git a/smc-command/smc.c b/smc-command/smc.c index d8f2311..033606a 100644 --- a/smc-command/smc.c +++ b/smc-command/smc.c @@ -102,6 +102,11 @@ void printSI16(SMCVal_t val) printf("%d ", ntohs(*(SInt16*)val.bytes)); } +void printPWM(SMCVal_t val) +{ + printf("%.1f%% ", ntohs(*(UInt16*)val.bytes) * 100 / 65536.0); +} + void printBytesHex(SMCVal_t val) { int i; @@ -129,6 +134,8 @@ void printVal(SMCVal_t val) printSI8(val); else if (strcmp(val.dataType, DATATYPE_SI16) == 0 && val.dataSize == 2) printSI16(val); + else if (strcmp(val.dataType, DATATYPE_PWM) == 0 && val.dataSize == 2) + printPWM(val); printBytesHex(val); } diff --git a/smc-command/smc.h b/smc-command/smc.h index f19179e..9176543 100644 --- a/smc-command/smc.h +++ b/smc-command/smc.h @@ -45,6 +45,7 @@ #define DATATYPE_SP78 "sp78" #define DATATYPE_SI8 "si8 " #define DATATYPE_SI16 "si16" +#define DATATYPE_PWM "{pwm" typedef struct { char major;