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.
Fork of CoilGun by
Diff: coilgun.cpp
- Revision:
- 2:781ea1999ad3
- Parent:
- 1:aa39e3a9d06f
- Child:
- 3:7273ba733560
--- a/coilgun.cpp Mon Sep 09 18:25:23 2013 +0000 +++ b/coilgun.cpp Sat Sep 14 17:30:54 2013 +0000 @@ -2,14 +2,23 @@ CoilGun::CoilGun(PinName chargePinName, PinName kickPinName, PinName donePin) : chargePin(chargePinName), kickPin(kickPinName), done(donePin) { - //done.fall(this, &CoilGun.doneCallback); + done.fall(this, &CoilGun::doneCallback); } -void CoilGun::kick(int length) { - +void CoilGun::kick(unsigned int length) { + chargePin = 0; + kickPin = 0; + Timeout kickFinish; + kickFinish.attach_us(this, &CoilGun::kickEnd, length); +} + +void CoilGun::kickEnd(void) { + chargePin = 1; + kickPin = 1; } void CoilGun::setCharge(bool chargeState) { + kickPin = 1; if (chargeState) { chargePin = 1; } else { @@ -19,6 +28,7 @@ void CoilGun::discharge() { chargePin = 0; + kickPin = 0; } void CoilGun::doneCallback(void) {