Grenade Drone Controller
Dependencies: mbed
Revision 1:903bcc4d9628, committed 2018-08-20
- Comitter:
- halusis
- Date:
- Mon Aug 20 03:06:52 2018 +0000
- Parent:
- 0:4194aba3f887
- Commit message:
- Grenade Drone Controller
Changed in this revision
diff -r 4194aba3f887 -r 903bcc4d9628 Functions/Functions.cpp --- a/Functions/Functions.cpp Mon Jul 16 06:49:15 2018 +0000 +++ b/Functions/Functions.cpp Mon Aug 20 03:06:52 2018 +0000 @@ -35,8 +35,8 @@ } void SndPWM(void) { - pwm_t7 = (float)var7*0.000001; - pwm_t8 = (float)var8*0.000001; + pwm_t7 = var7*0.000001f; + pwm_t8 = var8*0.000001f; pwm1.pulsewidth_us(var1); pwm2.pulsewidth_us(var2);
diff -r 4194aba3f887 -r 903bcc4d9628 GranadeCtrl.cpp --- a/GranadeCtrl.cpp Mon Jul 16 06:49:15 2018 +0000 +++ b/GranadeCtrl.cpp Mon Aug 20 03:06:52 2018 +0000 @@ -3,21 +3,29 @@ #include "GlobalVars.h" #include "Functions.h" -bool fSndTimer=0; +bool fSndTimer=1; +bool fDebugTimer=1; Timeout SndTimer; +Ticker DebugTimer; void SndTimer_isr(void) {fSndTimer=1;} +void DebugTimer_isr(void) {fDebugTimer=1;} int main() { - SndTimer.attach(&SndTimer_isr,1); - InitPWM(); - pc.baud(115200); Switch.baud(9600); + InitPWM(); + + pc.printf("Start\n"); + + DebugTimer.attach(&DebugTimer_isr,1); + while(1) - { + { + if(Switch.readable()) RcvProc(); + if(fSndTimer==1) { fSndTimer=0; @@ -26,8 +34,15 @@ SigBit=RcvBit; Switch.putc(SigBit); + SndTimer.attach(&SndTimer_isr,0.02); } - if(Switch.readable()) RcvProc(); + if(fDebugTimer==1) + { + fDebugTimer=0; + pc.printf("%d %d %d %d %d %d %d %d\n",(int)var1,(int)var2,(int)var3,(int)var4,(int)var5,(int)var6,(int)var7,(int)var8); + } + + } }
diff -r 4194aba3f887 -r 903bcc4d9628 PinAssign/PinAssign.cpp --- a/PinAssign/PinAssign.cpp Mon Jul 16 06:49:15 2018 +0000 +++ b/PinAssign/PinAssign.cpp Mon Aug 20 03:06:52 2018 +0000 @@ -9,5 +9,5 @@ PwmOut pwm4(p24); PwmOut pwm5(p25); PwmOut pwm6(p26); -PwmOut pwm7(p19); -PwmOut pwm8(p20); +DigitalOut pwm7(p19); +DigitalOut pwm8(p20);
diff -r 4194aba3f887 -r 903bcc4d9628 PinAssign/PinAssign.h --- a/PinAssign/PinAssign.h Mon Jul 16 06:49:15 2018 +0000 +++ b/PinAssign/PinAssign.h Mon Aug 20 03:06:52 2018 +0000 @@ -11,6 +11,6 @@ extern PwmOut pwm4; extern PwmOut pwm5; extern PwmOut pwm6; -extern PwmOut pwm7; -extern PwmOut pwm8; +extern DigitalOut pwm7; +extern DigitalOut pwm8; #endif \ No newline at end of file