B4R Question frequency counter

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try this:
B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Private frq As ULong 'ignore
   Private timer1 As Timer
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   timer1.Initialize("timer1_Tick", 20)
   timer1.Enabled = True
End Sub

Sub Timer1_Tick
   RunNative("FreqCounterStart", Null)
   RunNative("FreqCounterGet", Null)
   Log(frq)
End Sub

#if C
#include <FreqCounter.h>
void FreqCounterStart(B4R::Object* o) {
FreqCounter::f_comp= 8;        
 FreqCounter::start(100);  
 while (FreqCounter::f_ready == 0);
}
void FreqCounterGet(B4R::Object* o) {
   b4r_main::_frq = FreqCounter::f_freq;
}

#end if

The library should be copied to the arduino libraries folder:

SS-2018-03-01_17.06.44.png
 
Upvote 0
Top