diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2013-12-29 11:55:35 -0500 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2013-12-29 12:00:52 -0500 |
commit | c2c7ef1dfe4cae6b5831ffab0ce5780b27e0c25e (patch) | |
tree | d490768ad2effe746406c60419aae905cfeead83 /src/canutil/write.c | |
parent | 6ce03a4f1b229e605da08b073fad6f7c0fe8bf10 (diff) |
Standardize on snake_case naming as this is a C library.
Diffstat (limited to 'src/canutil/write.c')
-rw-r--r-- | src/canutil/write.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/canutil/write.c b/src/canutil/write.c index 64b57297..14d2a449 100644 --- a/src/canutil/write.c +++ b/src/canutil/write.c @@ -1,19 +1,19 @@ #include "write.h" #include <bitfield/bitfield.h> -uint64_t encodeFloat(float value, uint8_t bitPosition, uint8_t bitSize, +uint64_t bitfield_encode_float(float value, uint8_t bit_offset, uint8_t bit_size, float factor, float offset) { - float rawValue = (value - offset) / factor; - if(rawValue > 0) { + float raw = (value - offset) / factor; + if(raw > 0) { // round up to avoid losing precision when we cast to an int - rawValue += 0.5; + raw += 0.5; } uint64_t result = 0; - setBitField(&result, (uint64_t)rawValue, bitPosition, bitSize); + set_bit_field(&result, (uint64_t)raw, bit_offset, bit_size); return result; } -uint64_t encodeBoolean(bool value, uint8_t bitPosition, uint8_t bitSize, +uint64_t bitfield_encode_bool(bool value, uint8_t bit_offset, uint8_t bit_size, float factor, float offset) { - return encodeFloat(value, offset, factor, bitPosition, bitSize); + return bitfield_encode_float(value, offset, factor, bit_offset, bit_size); } |