arduino-oled-auto-gauges
arduino-oled-auto-gauges copied to clipboard
Use arduino map function
Refactor code to use the built in map
function in place of the normaliseSensorData
and mapValueToYPos
functions.
Created as a pull request because this needs to be tested and my arduino is in my dashboard.
@half-finished Sure!
The boostPressure
variable contains the pressure as an int: boostPressure = 1234
would mean a measurement of 12.34psi
To convert 1234 to 12.34 I cast the int to a float and divide by 100.
I then use the dtostrf
function to convert and round the float to a char array so that it can be easily drawn to the screen. dtostrf
is a built in function which you can read about here:
http://www.hobbytronics.co.uk/arduino-float-vars
I ended up using the formula from the data sheet, I seemed to get a more accurate reading from it than when using the map function.