Android Question animation res0lution

Charles Carey

Member
Licensed User
Longtime User
I'm on B4A v3.0 and developing an interface for a temperature controller project. I have it all working but have one problem. In the attached picture you can see that the fermentation temperature is 75.5F but the Fermentation dial reads 75.0F. I can't get the dial to read 75.5F. My code seems to round off to an integer even though my math is all floating.
Where am I going wrong? Anyone? Please. :)

Here is my code: ***************************************************
Sub setTemp(Temp As Float)
Select strDialPick
Case "Ambient"
Angle = (150 + (Temp * 3)) Mod 360
Rotation.InitializeRotateCenter("Animation", Angle, Angle, pnlAmbientNeedle)
Rotation.Duration = 20000
Rotation.Start(pnlAmbientNeedle)

Case "BrewBox"
Angle = (150 + (Temp * 3)) Mod 360
Rotation.InitializeRotateCenter("Animation", Angle, Angle, pnlBrewBoxNeedle)
Rotation.Duration = 20000
Rotation.Start(pnlBrewBoxNeedle)

Case "Ferment"
Angle = (30 + (Temp * 6)) Mod 360
Rotation.InitializeRotateCenter("Animation", Angle, Angle, pnlFermentNeedle)
Rotation.Duration = 20000
Rotation.Start(pnlFermentNeedle)
End Select

End Sub

End Code here *********************************************************
 

Attachments

  • ScreenShot.jpg
    ScreenShot.jpg
    190.9 KB · Views: 197

udg

Expert
Licensed User
Longtime User
Hi,

is it Angle a double (as required by Animation.InitializeRotateCenter)?
Does Angledbl = round2(Angle,1) help? This one should return a single decimal digit (so 75.1, 75.2..).

udg
 
Upvote 0

Charles Carey

Member
Licensed User
Longtime User
Hi,

is it Angle a double (as required by Animation.InitializeRotateCenter)?
Does Angledbl = round2(Angle,1) help? This one should return a single decimal digit (so 75.1, 75.2..).

udg

The Panel rotation starts at zero degrees at the top. My temperature dial starts at 210 degrees on the dial and 20F or 30F for the temperature depending on which dial is used. In order to move the needle one degree F I have to move the needle 3 degrees or 6 degrees rotation on the dial depending on which dial is used. So, the math is required to get the needle to display properly on the dial face.
My temperature reading comes from a DS18B20 temperature probe. It's range is -55C to 125C but the project would never get below 0C or above 40C ( unless something goes terribly wrong, which has happened ). I'm a home brewer and the project is for a temperature controlled fermentation chamber.

I originally used Dim Angle as Double but tried Float and it was not rejected by the animation library method so I assumed it was acceptable. I have to confess I assumed double was an integer type so I went to float to get the decimal point.
 
Upvote 0

Charles Carey

Member
Licensed User
Longtime User
Hi,

is it Angle a double (as required by Animation.InitializeRotateCenter)?
Does Angledbl = round2(Angle,1) help? This one should return a single decimal digit (so 75.1, 75.2..).

udg

Angledbl = round2(Angle,1) would not help. The temperature probe will only return a single decimal point so as long as I multiply by whole numbers it will never get more than one decimal point.

I setup a test app which would allow me to send numbers to the dial to see where the needle fell and also included a debug label so I could print out the calculated angle. The math in the app calculated 120.0 degrees for 75.5F but my calculator returned 123 degrees.
I also changed Angle to Float type and it didn't make any difference.

If anyone wants to tinker with it I'll post it.
 
Upvote 0

Charles Carey

Member
Licensed User
Longtime User
Problem solved.

I was converting a string temperature value to type float and the procedure was loping off the decimal. The animation will resolve to a 10th of a degree just fine now. :)
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Glad to hear you solved it. Have a nice weekend.
 
Upvote 0
Top