summaryrefslogtreecommitdiffstats
path: root/src/canutil/write.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/canutil/write.c')
-rw-r--r--src/canutil/write.c14
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);
}