comparison core/ClockSyncThread.cpp @ 149:134bff10e561 ClockSync

Added simple one-variable one-measurement Kalman filter, Pid controller(which output is not used). Virtual clock is now much more precise and reactive for period. Still it is lagging behind a bit on the overall offset.
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 21 Sep 2015 03:12:21 +0100
parents 44d07fa9bd03
children 8f98b32d0e23
comparison
equal deleted inserted replaced
148:6cd38e261027 149:134bff10e561
50 #endif /* USE_JUCE */ 50 #endif /* USE_JUCE */
51 51
52 void ClockSyncThread::setVirtualClock(VirtualClock &aVirtualClock){ 52 void ClockSyncThread::setVirtualClock(VirtualClock &aVirtualClock){
53 virtualClock=&aVirtualClock; 53 virtualClock=&aVirtualClock;
54 }; 54 };
55 55 #ifndef USE_JUCE
56 extern I2c_Codec* gAudioCodec;
57 #endif
56 void ClockSyncThread::run(){ 58 void ClockSyncThread::run(){
57 printf("var=["); 59 printf("variable=[");
58 while(!threadShouldExit()){ 60 while(!threadShouldExit()){
61 static int count = 0;
59 clockSync.sendReceiveLoop(); 62 clockSync.sendReceiveLoop();
63 #ifndef USE_JUCE
64 // if (count == 300){
65 // printf("0 0 0\n");
66 // gAudioCodec->setAudioSamplingRate(44101);
67 // }
68 #endif
69 count++;
60 // double now=virtualClock->getNow(); 70 // double now=virtualClock->getNow();
61 // printf("th(end+1)=%f;\n", now); 71 // printf("th(end+1)=%f;\n", now);
62 // printf("act(end+1)=%lld;\n", Clock::getTimeUs()); 72 // printf("act(end+1)=%lld;\n", Clock::getTimeUs());
63 } 73 }
64 printf("];\n"); 74 printf("];\n");