My modifications/additions to the code
Dependencies: ADXL345 ADXL345_I2C IMUfilter ITG3200 Servo fishgait mbed-rtos mbed pixy_cam
Fork of robotic_fish_ver_4_8 by
Diff: guardian.cpp
- Revision:
- 2:430c068cf570
- Child:
- 5:090ef6275773
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guardian.cpp Fri Jan 24 21:55:00 2014 +0000 @@ -0,0 +1,84 @@ +#include "guardian.h" + +Guardian::Guardian(PinName ailpin, PinName modpin, PinName elvpin, PinName rudpin, PinName auxpin, PinName gainpin) +{ + ail=new Servo(ailpin); + mod=new Servo(modpin); + elv=new Servo(elvpin); + /*rud=new Servo(rudpin); + aux=new Servo(auxpin); + */ + gain=new Servo(gainpin); + mod->write(0.5); + ail->write(0.5); + elv->write(0.5); + /*rud->write(0.5); + aux->write(0.00); + */ + gain->write(1.00); +} + +Guardian::~Guardian() +{ + delete ail, mod, elv, rud, aux, gain; +} + +void Guardian::set3D() +{ + mod->write(1.00); + return; +} + +void Guardian::set2D() +{ + mod->write(0.00); + return; +} + +void Guardian::setoff() +{ + mod->write(0.5); + return; +} + +void Guardian::calibrate() //must be done within 15 sec of power on +{ + set2D(); + wait(500); + set3D(); + wait(500); + set2D(); + wait(2000); + //now look for the twitch + return; +} + +void Guardian::setail(float val) +{ + ail->write(val); + return; +} + +void Guardian::setmod(float val) +{ + mod->write(val); + return; +} + +void Guardian::setelv(float val) +{ + elv->write(val); + return; +} + +void Guardian::setrud(float val) +{ + rud->write(val); + return; +} + +void Guardian::setaux(float val) +{ + aux->write(val); + return; +} \ No newline at end of file