diff projects/scope/render.cpp @ 141:44d07fa9bd03 ClockSync

Ultra-basic feedback for clock sync works^CIssues: response time of the IIR filter is too slow, requires PID and better filtering algorithm.
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 14 Sep 2015 15:42:11 +0100
parents e77e2e712fbc
children 55c1e591cb2e
line wrap: on
line diff
--- a/projects/scope/render.cpp	Mon Sep 14 14:57:54 2015 +0100
+++ b/projects/scope/render.cpp	Mon Sep 14 15:42:11 2015 +0100
@@ -26,6 +26,19 @@
 extern I2c_Codec* gAudioCodec;
 VirtualClock virtualClock;
 ClockSyncThread clockSyncThread;
+AuxiliaryTask testTime;
+void testTimeFunction(){
+	rt_printf("time=[");
+	while(!gShouldStop){
+		rt_task_sleep(50000*1e3);
+		rt_printf("%f, ", virtualClock.getNow());
+		rt_printf("%f, ", virtualClock.getPeriod());
+		rt_task_sleep(20000);
+		rt_printf("%f,", virtualClock.getNow());
+		rt_printf("%f\n", virtualClock.getPeriod());
+	}
+	rt_printf("];");
+}
 bool setup(BeagleRTContext *context, void *userData)
 {
 //	receiveAudio0.init(10000, context->audioFrames, 0);
@@ -35,7 +48,7 @@
 //	scope.setPort(0, 9999);
 //	scope.setPort(1, 10000);
 //	networkSend.setup(context->audioSampleRate, context->audioFrames, 0, 9999, "192.168.7.1");
-	clockSynchronizer.setup();
+//	clockSynchronizer.setup();
 	virtualClock.init();
 	clockSyncThread.init(true, 5000, virtualClock); //start as slave
 	gInverseSampleRate = 1.0/context->audioSampleRate;
@@ -46,6 +59,7 @@
 	gFrequency1 = 200.0;
 	gFrequency2 = 201.0;
 
+//	testTime=BeagleRT_createAuxiliaryTask(testTimeFunction, 80, "testTimeTask");
 	return true; 
 }
 
@@ -58,8 +72,10 @@
 {
 	virtualClock.sync(context->audioFrames);
 	static int count=0;
-	if(count==0)
-		clockSyncThread.startThread();
+	if(count==0){
+//		BeagleRT_scheduleAuxiliaryTask(testTime);
+		clockSyncThread.startThread(); //make sure you uncomment .init in setup()
+	}
 	static float phase=0;
 	float phaseInc=200.0/44100.0*2*M_PI;
 //	rt_printf("phaseInc: %f, phase: %f\n",phaseInc,phase);