diff options
Diffstat (limited to 'src/canutil/write.c')
-rw-r--r-- | src/canutil/write.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/canutil/write.c b/src/canutil/write.c index 12c8fa28..09e6caa3 100644 --- a/src/canutil/write.c +++ b/src/canutil/write.c @@ -2,11 +2,13 @@ #include <bitfield/bitfield.h> #include <bitfield/8byte.h> -uint64_t bitfield_encode_float(float value, uint8_t bit_offset, uint8_t bit_size, +uint64_t eightbyte_encode_float(float value, uint8_t bit_offset, uint8_t bit_size, float factor, float offset) { float raw = (value - offset) / factor; if(raw > 0) { // round up to avoid losing precision when we cast to an int + // TODO do we need a way to encode an int back to a signal without any + // rounding? raw += 0.5; } uint64_t result = 0; @@ -16,7 +18,13 @@ uint64_t bitfield_encode_float(float value, uint8_t bit_offset, uint8_t bit_size return result; } -uint64_t bitfield_encode_bool(const bool value, const uint8_t bit_offset, +uint64_t eightbyte_encode_bool(const bool value, const uint8_t bit_offset, const uint8_t bit_size) { - return bitfield_encode_float(value, bit_offset, bit_size, 1.0, 0); + return eightbyte_encode_float(value, bit_offset, bit_size, 1.0, 0); +} + +bool bitfield_encode_float(float value, uint8_t bit_offset, + uint8_t bit_size, float factor, float offset, uint8_t destination[]) { + // TODO + return 0; } |