cthhuynh / mobilewebcam-android

Automatically exported from code.google.com/p/mobilewebcam-android
0 stars 0 forks source link

Temperature in degrees fahrenheit is not correct. #9

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Configuring the Picture for Image Imprint (Battery/Temperature) an option is 
given to display temperature in degrees fahrenheit by removing "°C".

What is the expected output? What do you see instead?

As an example; before deleting the "°C", the temperature read 19.5°C. After 
deletion, the number displayed was 8.9. It should be 69.8 or warmer because of 
handling the phone between readings. 

What version of the product are you using? On what operating system?

mobilewebcam v3.13 running on LG Motion MS770 android v4.0.4

Please provide any additional information below.

The problem, I believe, is an error in the code, WorkImage.java, r17 on line 
130, which reads:

float fahrenheit = (float)(temp - 32) * (5f / 9.0f) / 10.0f;

The above line converts degrees F to C and it should be the other way around I 
think. Maybe something like this:

float fahrenheit = (float)(temp * (9f / 5.0f)) + 32) / 10.0f;

Original issue reported on code.google.com by gcand...@gmail.com on 30 Dec 2014 at 8:10

GoogleCodeExporter commented 8 years ago
After further examination of the code (WorkImage.java, r17 on line 130) I found 
another bug that makes conversion to fahrenheit incorrect. The value of 
“temp” is a 3 digit whole number that needs to be changed to 2 digit float 
BEFORE doing the conversion. Below is my proposed solution for this bug on line 
130.

Change this:
float fahrenheit = (float)(temp - 32) * (5f / 9.0f) / 10.0f;

To this:
float fahrenheit = (float) 32.0f + 1.8f * (temp / 10.0f);

This fix does work because I’ve tested it on two phones… LG Motion MS770 
and Samsung Conquer SPH-D600.

Original comment by gcand...@gmail.com on 20 Jan 2015 at 7:58