the fish that looks like a jet
Dependencies: ADXL345 ADXL345_I2C IMUfilter ITG3200 mbed Servo
guardian.cpp@12:7eeb29892625, 2014-02-01 (annotated)
- Committer:
- rkk
- Date:
- Sat Feb 01 00:03:40 2014 +0000
- Revision:
- 12:7eeb29892625
- Parent:
- 7:e005cfaff8d1
first design to put to water
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sandwich | 2:430c068cf570 | 1 | #include "guardian.h" |
sandwich | 2:430c068cf570 | 2 | |
rkk | 12:7eeb29892625 | 3 | Guardian::Guardian(PinName modpin, PinName gainpin) |
rkk | 12:7eeb29892625 | 4 | :mod(modpin), |
rkk | 12:7eeb29892625 | 5 | gain(gainpin) |
sandwich | 2:430c068cf570 | 6 | { |
sandwich | 2:430c068cf570 | 7 | |
rkk | 12:7eeb29892625 | 8 | mod.write(0.5); //set autopilot to off |
rkk | 12:7eeb29892625 | 9 | gain.write(1.00); |
sandwich | 2:430c068cf570 | 10 | } |
sandwich | 2:430c068cf570 | 11 | |
sandwich | 5:090ef6275773 | 12 | void Guardian::set3D() //set autopilot to 3D |
sandwich | 2:430c068cf570 | 13 | { |
rkk | 12:7eeb29892625 | 14 | mod.write(1.00); |
sandwich | 2:430c068cf570 | 15 | return; |
sandwich | 2:430c068cf570 | 16 | } |
sandwich | 2:430c068cf570 | 17 | |
sandwich | 5:090ef6275773 | 18 | void Guardian::set2D() //set autopilot 2D |
sandwich | 2:430c068cf570 | 19 | { |
rkk | 12:7eeb29892625 | 20 | mod.write(0.00); |
sandwich | 2:430c068cf570 | 21 | return; |
sandwich | 2:430c068cf570 | 22 | } |
sandwich | 2:430c068cf570 | 23 | |
sandwich | 2:430c068cf570 | 24 | void Guardian::setoff() |
sandwich | 2:430c068cf570 | 25 | { |
rkk | 12:7eeb29892625 | 26 | mod.write(0.5); |
sandwich | 2:430c068cf570 | 27 | return; |
sandwich | 2:430c068cf570 | 28 | } |
sandwich | 2:430c068cf570 | 29 | |
sandwich | 2:430c068cf570 | 30 | void Guardian::calibrate() //must be done within 15 sec of power on |
sandwich | 2:430c068cf570 | 31 | { |
sandwich | 2:430c068cf570 | 32 | set2D(); |
sandwich | 7:e005cfaff8d1 | 33 | wait(500); |
sandwich | 2:430c068cf570 | 34 | set3D(); |
sandwich | 7:e005cfaff8d1 | 35 | wait(500); |
sandwich | 2:430c068cf570 | 36 | set2D(); |
sandwich | 7:e005cfaff8d1 | 37 | wait(2000); |
sandwich | 2:430c068cf570 | 38 | //now look for the twitch |
sandwich | 2:430c068cf570 | 39 | return; |
sandwich | 2:430c068cf570 | 40 | } |
sandwich | 2:430c068cf570 | 41 | |
sandwich | 2:430c068cf570 | 42 | void Guardian::setmod(float val) |
sandwich | 2:430c068cf570 | 43 | { |
rkk | 12:7eeb29892625 | 44 | mod.write(val); |
sandwich | 2:430c068cf570 | 45 | return; |
sandwich | 2:430c068cf570 | 46 | } |
sandwich | 2:430c068cf570 | 47 | |
rkk | 12:7eeb29892625 | 48 | void Guardian::setgain(float val) |
sandwich | 2:430c068cf570 | 49 | { |
rkk | 12:7eeb29892625 | 50 | gain.write(val); |
sandwich | 2:430c068cf570 | 51 | return; |
sandwich | 2:430c068cf570 | 52 | } |