diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2013-12-24 12:00:20 -0500 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2013-12-24 12:00:20 -0500 |
commit | 39a420f13e8000e2dfa53777b9e51594ba03e5d4 (patch) | |
tree | 95d8a0975bf7016a71b64fea1162375a1b916985 /src/canutil/write.c | |
parent | bc1baf25a0844861713829c0e9e69e4a2d447cc6 (diff) |
Add test cases from vi-firmware.
Diffstat (limited to 'src/canutil/write.c')
-rw-r--r-- | src/canutil/write.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/canutil/write.c b/src/canutil/write.c index fdcba1f5..741778c7 100644 --- a/src/canutil/write.c +++ b/src/canutil/write.c @@ -1,18 +1,18 @@ #include "write.h" -uint64_t encodeFloat(float value, float offset, float factor, uint8_t bitPosition, - uint8_t bitSize) { +uint64_t encodeFloat(float value, uint8_t bitPosition, uint8_t bitSize, + float factor, float offset) { float rawValue = (value - offset) / factor; if(rawValue > 0) { // round up to avoid losing precision when we cast to an int rawValue += 0.5; } uint64_t result = 0; - setBitField(&result, rawValue, bitPosition, bitSize); + setBitField(&result, (uint64_t)rawValue, bitPosition, bitSize); return result; } -uint64_t encodeBoolean(bool value, float offset, float factor, - uint8_t bitPosition, uint8_t bitSize) { - return encodeFloat(value, offset, factor, bitPosition, bitSize); +uint64_t encodeBoolean(bool value, uint8_t bitPosition, uint8_t bitSize, + float factor, float offset) { + return encodeFloat(value, offset, factor, bitPosition, bitSize); } |