Commit 4437c468 authored by Sander Boele's avatar Sander Boele
Browse files

fixed floating point problem in bcd conversions

parent 263179ea
...@@ -16,11 +16,11 @@ local id = 0 ...@@ -16,11 +16,11 @@ local id = 0
local dev_addr = 0x68 local dev_addr = 0x68
local function decToBcd(val) local function decToBcd(val)
return((val/10*16) + (val%10)) return((((val/10) - ((val/10)%1)) *16) + (val%10))
end end
local function bcdToDec(val) local function bcdToDec(val)
return((val/16*10) + (val%16)) return((((val/16) - ((val/16)%1)) *10) + (val%16))
end end
-- initialize i2c -- initialize i2c
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment