Advertisement
filssavi

Untitled

Jan 26th, 2016
1,781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void podometro(int Axl, int Axh){
  2.    
  3.     int Ax = Axl+ 255*Axh;
  4.      AverageSampleBuffer[ AverageSampleBufferPointer] = Ax;
  5.    
  6.     if ( AverageSampleBufferPointer==7)
  7.     {
  8.          AverageSampleBufferPointer = 0;
  9.     } else
  10.          AverageSampleBufferPointer++;
  11.  
  12.  
  13.     MovingAverage = MovingAverage + Ax -  AverageSampleBuffer[ AverageSampleBufferPointer]/AverageWindow;
  14.     MaxAx = 0
  15.     MinAx = 65536;
  16.     Precision = 1250
  17.     npassi = 0
  18.      index = 0
  19.      sampleNew = 0
  20.      sampleOld = 0
  21.     DynamicTresholdLevel=0
  22.  
  23.     if( index==50){
  24.          index =0;
  25.     }
  26.  
  27.      sampleOld =  sampleNew;
  28.  
  29.     if(abs(MovingAverage- sampleNew)> Precision)  sampleNew = Precision;
  30.     else  sampleNew =  sampleNew;
  31.  
  32.  
  33.     if (( sampleNew< DynamicTresholdLevel) && ( sampleOld> DynamicTresholdLevel)){
  34.         npassi +=1;
  35.     }
  36.    
  37.     if(i > MaxAx)
  38.         MaxAx = i;
  39.     if(i < MinAx)
  40.         MinAx = i;
  41.  
  42.     if( index==49){
  43.         tmp = MaxAx
  44.         DynamicTresholdLevel = (MaxAx+MinAx)/2
  45.         MaxAx = MinAx
  46.         MinAx = MaxAx      
  47.     }
  48.  
  49.      index++;
  50.  
  51. }
  52.  
  53.  
  54. int distanceCalculator(void){
  55.     int distance=0;
  56.  
  57.     switch( NumeroPassiEseguitii){
  58.  
  59.     case 0:
  60.         distance = 0;
  61.         break;
  62.     case 1:
  63.     case 2:
  64.         distance = 2*( height/5);
  65.         break;
  66.     case 3:
  67.         distance = 2*( height/4);
  68.         break;
  69.     case 4:
  70.         distance = 2*( height/3);
  71.         break;
  72.     case 5:
  73.         distance = 2*( height/2);
  74.         break;
  75.     case 6:
  76.         distance = 2*(6*( height)/5);
  77.         break;
  78.     case 7;
  79.         distance = 2* height;
  80.         break:
  81.     default:
  82.         distance = 6* height/5;
  83.         break
  84.     }
  85.  
  86.  
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement