Yaroslav Barabanov
/
turret_2017
для управления турелью
gun.cpp
- Committer:
- Yar
- Date:
- 2017-01-15
- Revision:
- 0:690effcc5be0
- Child:
- 3:e47c0c98f515
File content as of revision 0:690effcc5be0:
#include "gun.hpp" #include "mbed.h" #include "rtos.h" #include "sounds.hpp" DigitalOut gunPin(PA_13); PwmOut outSignalGun(PB_3); void shotGun(void) { gunPin = 1; outSignalGun.period(1.0/1500.0); // 1500hz period outSignalGun = 0.5; //50% duty cycle - max volume Thread::wait(10); short tik = 0; char isStateGun = 1; for (short i = 0; i < 1500; i = i + 100) { outSignalGun.period(1.0/(float)(1500.0 - i)); outSignalGun = 0.5; Thread::wait(20); if (tik < 3) { tik++; } else { tik = 0; isStateGun ^= 1; gunPin = isStateGun; } } outSignalGun = 0.0; //Thread::wait(200); gunPin = 0; } void enabledGun(void) { gunPin = 1; } void disabledGun(void) { gunPin = 0; }