![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
TRR2018 omar
Fork of biniou by
Diff: stateMachines.cpp
- Revision:
- 48:df2b4b6feceb
- Parent:
- 45:7d67809bd7bf
- Child:
- 49:6a939e2ffb32
--- a/stateMachines.cpp Thu Sep 20 12:11:11 2018 +0000 +++ b/stateMachines.cpp Thu Sep 20 18:56:13 2018 +0000 @@ -120,7 +120,7 @@ #endif s_Section* p_sectionCourante = NULL; -bool dumped = false; +int dumped = 0; // +++++++++++++++++++++++++++++++++++++++++++ SAMPLING +++++++++++++++++++++++++++++++++++++++++++ @@ -221,15 +221,26 @@ #if DEBUG > 0 pc.printf("[BTN PRESSED]\r\n"); #endif -if(!dumped) -{ +switch(dumped) +{case 0: + PwmMotor.period_us(DIRECTION_PERIOD_MS); //20 ms is default + PwmMotor.pulsewidth_us(1000);//MIN + wait(3); + PwmMotor.pulsewidth_us(2000);//MAX + wait(1); + PwmMotor.pulsewidth_us(1500);//ZEROING + wait(1); + pulseSpeed_us = INITAL_PULSE_SPEED_US; + p_sectionCourante = &p_section1; + initSamples(); +break; +case 1: transmitData(); - dumped = true; -}else{ - initSamples(); - p_sectionCourante = &p_section1; - dumped = false; + break; + default: + break; } + dumped ++; } #endif @@ -350,7 +361,7 @@ pc.printf("Init Section\r\n"); #endif st_currentSection=ARRET; - p_sectionCourante=&p_section1; + //p_sectionCourante=&p_section1; it_tachymeter.fall(&it4cm); timerSinceTachy.start(); tachySectionDist_cm = 0; @@ -402,14 +413,6 @@ pc.printf("Init Throttle\r\n"); #endif st_thro = REGULATION_SPEED; - PwmMotor.period_us(DIRECTION_PERIOD_MS); //20 ms is default - PwmMotor.pulsewidth_us(1000);//MIN - wait(3); - PwmMotor.pulsewidth_us(2000);//MAX - wait(1); - PwmMotor.pulsewidth_us(1500);//ZEROING - wait(1); - pulseSpeed_us = INITAL_PULSE_SPEED_US; #if DEBUG > 0 pc.printf("temps init: %.4lf micros\r\n",timeSinceStart.read_us()); pc.printf("\r\nStates INIT: state Murs: %.4lf, state Section %.4lf, state MaxSpeed %.4lf, state Throttle %.4lf\r\n",st_murs,st_currentSection,st_maxSpeed,st_thro);