Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: ReceiverIR.cpp
- Revision:
- 13:5e445169cf83
- Parent:
- 12:96209c979a7f
- Child:
- 14:2fafd2e7dea8
--- a/ReceiverIR.cpp Wed Jun 05 04:49:42 2019 +0000
+++ b/ReceiverIR.cpp Wed Jun 05 13:56:09 2019 +0000
@@ -18,9 +18,11 @@
evt.rise(this, &ReceiverIR::isr_rise);
evt.mode(PullUp);
ticker.attach_us(this, &ReceiverIR::isr_wdt, 10 * 1000);
- Speed_L = 0.09 ;
+ Speed_L = 0.35 ;
//Speed_R = _speed *1.005;
- Speed_R = 0.085 ;
+ Speed_R = 0.345 ;
+ init_sp_l = Speed_L;
+ init_sp_r = Speed_R;
}
/**
@@ -93,68 +95,85 @@
}
// left
if(!strncmp(buffer, "00FF08F7",8)){
- //pc.printf("left!\r\n");
- start = 1;
+ //pc.printf("left!\r\n");
+ left();
}
// right
if(!strncmp(buffer, "00FF5AA5",8)){
- //pc.printf("right!\r\n");
- right();
+ //pc.printf("right!\r\n");
+ right();
}
// stop
if(!strncmp(buffer, "00FF0CF3",8)){
- speedup_l(1);
+ speedup_l();
}
if(!strncmp(buffer, "00FF5EA1",8)){
- speedup_r(1);
+ speedup_r();
}
if(!strncmp(buffer, "00FF42BD",8)){
- speeddown_l(1);
+ speeddown_l();
}
if(!strncmp(buffer, "00FF4AB5",8)){
- speeddown_r(1);
+ speeddown_r();
}
if(!strncmp(buffer, "00FF1CE3",8)){
-// pc.printf("stop!\r\n");
stop();
+ }
+ if(!strncmp(buffer, "00FF45BA", 8)){
+ cal_start = 1;
+ }
+ if(!strncmp(buffer, "00FF47B8", 8)){
+ cal_stop = 1;
}
}
-void ReceiverIR::speedup_l(int weight){
- Speed_L += 0.0003*weight;
- if(Speed_L > 0.5){
- Speed_L = 0.5;
- }
- pwma = Speed_L;
+void ReceiverIR::speedup_l(void){
+ //Speed_L += 0.0005;
+// if(Speed_L > 0.5){
+// Speed_L = 0.5;
+// }
+// pwma = Speed_L;
+ kp += 0.5;
}
-void ReceiverIR::speeddown_l(int weight){
- Speed_L -= 0.0003*weight;
- if(Speed_L < 0){
- Speed_L = 0;
- }
- pwma = Speed_L;
+void ReceiverIR::speeddown_l(void){
+ //Speed_L -= 0.0005;
+// if(Speed_L < 0){
+// Speed_L = 0;
+// }
+// pwma = Speed_L;
+ kp -= 0.5;
}
-void ReceiverIR::speedup_r(int weight){
- Speed_R += 0.0003*weight;
- if(Speed_R > 0.5){
- Speed_R = 0.5;
- }
- pwmb = Speed_R;
+void ReceiverIR::speedup_r(void){
+ // Speed_R += 0.0005;
+// if(Speed_R > 0.5){
+// Speed_R = 0.5;
+// }
+// pwmb = Speed_R;
+ max += 5;
}
-void ReceiverIR::speeddown_r(int weight){
- Speed_R -= 0.0003*weight;
- if(Speed_R < 0){
- Speed_R = 0;
- }
- pwmb = Speed_R;
+void ReceiverIR::speeddown_r(void){
+// Speed_R -= 0.0005;
+// if(Speed_R < 0){
+// Speed_R = 0;
+// }
+// pwmb = Speed_R;
+ max -= 5;
}
void ReceiverIR::speed_l(float sp_l){
Speed_L = sp_l;
+ if(Speed_L > 0.6){
+ Speed_L = 0.6;
+ }
+ pwma = Speed_L;
}
void ReceiverIR::speed_r(float sp_r){
Speed_R = sp_r;
+ if(Speed_R > 0.6){
+ Speed_R = 0.6;
+ }
+ pwmb = Speed_R;
}
void ReceiverIR::forward(void){