Android Question Heartbeatview does not compile

Status
Not open for further replies.

grafsoft

Well-Known Member
Licensed User
Longtime User
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is an old and unmaintained library. Don't use such libraries.

Here, cross platform code:
B4X:
Private Sub AnimateHeart
    Dim SmallSize As Int = 100dip
    Dim LargeSize As Int = 130dip
    Dim cx = imgHeart.Left + imgHeart.Width / 2, cy = imgHeart.Top + imgHeart.Height / 2 As Int
   
    Dim StartTime As Long = DateTime.Now
    Do While True
        Dim PulseIntervalMs As Int = 60000 / RatePerMinute
        Dim x As Float = ((DateTime.Now - StartTime) Mod PulseIntervalMs) / PulseIntervalMs
        Dim size As Float
        If x <= 0.5 Then
            size = SmallSize + (LargeSize - SmallSize) * x * 2 'growing
        Else
            size = LargeSize - (LargeSize - SmallSize) * (x - 0.5) * 2 'shrinking
        End If
        imgHeart.SetLayoutAnimated(0, cx - size / 2, cy - size / 2, size, size)
        Sleep(10)
    Loop
End Sub

Test it in release mode.


 

Attachments

  • Project.zip
    14.2 KB · Views: 104
Upvote 0

grafsoft

Well-Known Member
Licensed User
Longtime User
Works, thanks.

But I put the wrong question: I need the real heart rate from a device.

I tried this:


I added this to main.b4a:

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private hr As HeartRate
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
     hr.Initialize
End Sub
But I seem not to understand the class right. All I get is "state changed: 12".

The real device is on my hand and sends data to the android cell phone.

What am I doing wrong?

Thanks!!
 

Attachments

  • Pulstest.zip
    10 KB · Views: 57
Upvote 0
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…