- //int numbits;
- int ii;
- int loopCnt = 256;
- if (GraphTraceLen<loopCnt) loopCnt = GraphTraceLen;
- int clkCnt;
- int tol = 0;
- int bestErr=1000;
- int errCnt[]={0,0,0,0,0,0,0,0};
- // int good;
- for(clkCnt=0; clkCnt<6;++clkCnt){
- if (clk[clkCnt]==32){
- tol=1;
- }else{
- tol=0;
- }
- bestErr=1000;
- for (ii=0; ii<loopCnt; ++ii){
- if ((GraphBuffer[ii]>=peak) || (GraphBuffer[ii]<=low)){
- //numbits=0;
- //good=1;
- errCnt[clkCnt]=0;
- for (i=0; i<((int)(GraphTraceLen/clk[clkCnt])-1); ++i){
- if (GraphBuffer[ii+(i*clk[clkCnt])]>=peak || GraphBuffer[ii+(i*clk[clkCnt])]<=low){
- //numbits++;
- }else if(GraphBuffer[ii+(i*clk[clkCnt])-tol]>=peak || GraphBuffer[ii+(i*clk[clkCnt])-tol]<=low){
- }else if(GraphBuffer[ii+(i*clk[clkCnt])+tol]>=peak || GraphBuffer[ii+(i*clk[clkCnt])+tol]<=low){
- }else{ //error no peak detected
- //numbits=0;
- //good=0;
- errCnt[clkCnt]++;
- //break;
- }
- }
- if(errCnt[clkCnt]==0) return clk[clkCnt];
- if(errCnt[clkCnt]<bestErr) bestErr=errCnt[clkCnt];
- }
- }
- errCnt[clkCnt]=bestErr;
- }
- int iii=0;
- int best=0;
- for (iii=0; iii<6;++iii){
- if (errCnt[iii]<errCnt[best]){
- best = iii;
- }
+ GraphTraceLen=size;
+ RepaintGraphWindow();
+ return;
+}
+size_t getFromGraphBuf(uint8_t *buff)
+{
+ uint32_t i;
+ for (i=0;i<GraphTraceLen;++i){
+ if (GraphBuffer[i]>127) GraphBuffer[i]=127; //trim
+ if (GraphBuffer[i]<-127) GraphBuffer[i]=-127; //trim
+ buff[i]=(uint8_t)(GraphBuffer[i]+128);