B4R Question B4R time options available ?

inakigarm

Well-Known Member
Licensed User
Longtime User
Hi Erel:

In several sensor communications is basic to find the exact time when a pin is triggered comparing an initial state or between states (distance sensors, etc..)

Are you thinking about including these in core functions ? (like DateTime)

Thanks

P.D:

Arduino Time Library

PJRC Time Library
 

inakigarm

Well-Known Member
Licensed User
Longtime User
Yes, tried with millis,but the problem with that function is resolution (only miliseconds). In several schematics, we'll need more timing resolutions (like microseconds - Arduino function)
ex:
distance sensor: measuring distance finding the time between a trigger and an echo sound (using sound speed - air - formula)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I will add it. Note that you can also call it with this code:
B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Private microsTime As ULong 'ignore
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   RunNative("micro", Null)
   Log(microsTime)
   RunNative("micro", Null)
   Log(microsTime)
End Sub

#if C
void micro (B4R::Object* o) {
   b4r_main::_microstime = micros();
}
#End if

https://www.b4x.com/android/forum/threads/inline-c-c.65714/
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Upvote 0
Top