int main(int argc, char **argv) { int k, N = STD_N, adcNumber = STD_ADCPIN, bench = BENCH_FLAG; float yMax = STD_YMAX, lines = STD_LINES, DELTA = STD_DELTA; mraa_aio_context adc; struct timeval inicio, fim; double tmili; if (argc == 2) { yMax = atof(argv[1]); } else if (argc == 3) { yMax = atof(argv[1]); lines = atof(argv[2]); } adc = mraa_aio_init(adcNumber); if (adc == NULL) return 1; hideCursor(); clear(); while (1) { cplx samples[N]; double deltaFreq; gettimeofday(&inicio, NULL); for (k = 0; k < N; k++) { uint16_t sample = mraa_aio_read(adc); samples[k] = (cplx) 5*sample/(resolution - 1.0); } gettimeofday(&fim, NULL); tmili = (double) (1000 *(fim.tv_sec - inicio.tv_sec) + (fim.tv_usec - inicio.tv_usec) / 1000); deltaFreq = 1000.0 / tmili; if (bench == 1) { printf("\n>>>> Bench with:\n N=%d\n delta=%f\n", N, DELTA); printf(">>>> Sample time : %.2fms\n", tmili); printf(" deltaFreq : %.2fHz\n", deltaFreq); printf(" max freq. : %.2fHz\n", 500*N/tmili); } runFFT(samples, N, DELTA, deltaFreq, bench, yMax, lines); printCoord (N/2, 40); } mraa_aio_close(adc); return 0; }
void CLocomotion::lGoTo(int x, int y, bool detection) { if(detection) Timer5.start(); while(m_flag){ Serial.println("Blocked"); delay(50); } float distance = sqrt(pow(x-m_etat.x,2)+pow(y-m_etat.y,2)); if(distance==0) return; // Serial.print("distance : "); // Serial.print(distance); //from origin to new pos int phi = (int)(asin((y-m_etat.y)/distance)*180.0F/PI); Serial.print("phi : "); Serial.print(phi); if(x-m_etat.x<0) phi = 180- phi; //Final theta int phiF = phi; if (phiF<0) phiF += 360; // between actual and new pos int psi = phi - m_etat.theta; Serial.print("psi : "); Serial.print(psi); if(abs(psi) < 180){ if(psi > 0) lTurn(psi,RIGHT); else lTurn(-psi,LEFT); } else{ if(psi > 0) lTurn(360-psi,LEFT); else lTurn(360+psi,RIGHT); } printCoord(); // Serial.println("Avancer"); delay(500); lAvancer(distance,FORWARD); printCoord(); //Correct final angle delay(500); Serial.println("Correct FINAL THETA"); int corTheta = getCurrentTheta() - phiF; if(abs(corTheta)<180){ if(corTheta <0) lTurn(- corTheta,RIGHT); else{ if (corTheta > 0) lTurn(corTheta,LEFT); } } else { if(corTheta <0) lTurn(360+corTheta,LEFT); else{ if (corTheta > 0) lTurn(360-corTheta,RIGHT); } } printCoord(); }
void printParam() { std::cout << "class CPlane" << std::endl; printCoord(); printGeneralParam(); std::cout << "; height = " << m_height << "; num_pass = "******"\n \n" <<std::endl; }
void printParam() { std::cout << "class ССаr" << std::endl; printCoord(); printGeneralParam(); std::cout << "\n \n" <<std::endl; }
void printParam() { std::cout << "class CShip" << std::endl; printSpeed(); printCoord(); printGeneralParam(); std::cout << "; port_registry = " << m_port_registry << "; num_pass = "******"\n \n" <<std::endl; }
/* recap on C peculiarities. Pointers, passing by value/reference, passing arrays. classes */ int main(int argc, char *argv[]){ unsigned int array1[] = {1,2,3,4,5}; printarray(array1,sizeof(array1)/sizeof(unsigned int)); printptr(array1+2); array1[2] = 12; printptr(array1+2); printarray(array1,sizeof(array1)/sizeof(unsigned int)); Coord xxx = { 101, // should be x 2320, // should be y -1}; // should be bla printf("bla = %d\n",xxx.bla); printf("x = %d\n",xxx.x); printf("y = %d\n",xxx.y); printCoord(xxx); printCoord(xxx); printarray2(array1,sizeof(array1)/sizeof(unsigned int)); }
void inputCoord(COORDINATE* target) { scanf(" %c%d", &(target->column), &(target->row)); target->column = toupper(target->column); printf("Target entered: "); printCoord(target); printf("\n"); }