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 IEEE_14_Freescale by
gyroReader.h@4:adc885f4ab75, 2013-11-17 (annotated)
- Committer:
- soonerbot
- Date:
- Sun Nov 17 21:04:47 2013 +0000
- Revision:
- 4:adc885f4ab75
- Parent:
- 1:c28fac16a109
- Child:
- 7:3b2cf7efe5d1
Gyro working, compass giving values, and fiddling with control systems for driving forward/back
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
soonerbot | 1:c28fac16a109 | 1 | /* |
soonerbot | 1:c28fac16a109 | 2 | * File: gyroReader.h |
soonerbot | 1:c28fac16a109 | 3 | * Author: Shawn Swatek |
soonerbot | 1:c28fac16a109 | 4 | * Originated: Spring 2013 |
soonerbot | 1:c28fac16a109 | 5 | * Revised: 3/29/13 |
soonerbot | 1:c28fac16a109 | 6 | */ |
soonerbot | 1:c28fac16a109 | 7 | |
soonerbot | 1:c28fac16a109 | 8 | #ifndef __GYROREADER__ |
soonerbot | 1:c28fac16a109 | 9 | #define __GYROREADER__ |
soonerbot | 1:c28fac16a109 | 10 | |
soonerbot | 1:c28fac16a109 | 11 | #include "mbed.h" |
soonerbot | 1:c28fac16a109 | 12 | //#include "rtos.h" |
soonerbot | 1:c28fac16a109 | 13 | #include "dbgprint.h" |
soonerbot | 1:c28fac16a109 | 14 | |
soonerbot | 1:c28fac16a109 | 15 | class gyroReader{ |
soonerbot | 1:c28fac16a109 | 16 | private: |
soonerbot | 1:c28fac16a109 | 17 | I2C accel; |
soonerbot | 1:c28fac16a109 | 18 | int gyroZcount; |
soonerbot | 1:c28fac16a109 | 19 | int gyroXcount; |
soonerbot | 1:c28fac16a109 | 20 | int zcal; |
soonerbot | 1:c28fac16a109 | 21 | int xcal; |
soonerbot | 1:c28fac16a109 | 22 | int polls; |
soonerbot | 1:c28fac16a109 | 23 | Ticker gyroUpkeepTicker; |
soonerbot | 1:c28fac16a109 | 24 | |
soonerbot | 1:c28fac16a109 | 25 | |
soonerbot | 1:c28fac16a109 | 26 | int startAccel(); |
soonerbot | 1:c28fac16a109 | 27 | |
soonerbot | 1:c28fac16a109 | 28 | float checkAccel(); |
soonerbot | 1:c28fac16a109 | 29 | |
soonerbot | 1:c28fac16a109 | 30 | int checkGyro(int& xacc, int& yacc, int& zacc); |
soonerbot | 1:c28fac16a109 | 31 | |
soonerbot | 1:c28fac16a109 | 32 | public: |
soonerbot | 4:adc885f4ab75 | 33 | |
soonerbot | 4:adc885f4ab75 | 34 | int xmag,ymag,zmag; |
soonerbot | 4:adc885f4ab75 | 35 | float checkCompass(); |
soonerbot | 4:adc885f4ab75 | 36 | |
soonerbot | 1:c28fac16a109 | 37 | void gyroUpkeep(); |
soonerbot | 1:c28fac16a109 | 38 | gyroReader(PinName pinA, PinName pinB); |
soonerbot | 1:c28fac16a109 | 39 | |
soonerbot | 1:c28fac16a109 | 40 | void setLevel(); |
soonerbot | 1:c28fac16a109 | 41 | void resetZ(); |
soonerbot | 1:c28fac16a109 | 42 | int getZ(); |
soonerbot | 4:adc885f4ab75 | 43 | double getZDegrees(); |
soonerbot | 1:c28fac16a109 | 44 | int getX(); |
soonerbot | 1:c28fac16a109 | 45 | int getPolls(){ return polls;} |
soonerbot | 4:adc885f4ab75 | 46 | int compZ(int compVal); |
soonerbot | 1:c28fac16a109 | 47 | void reset(); |
soonerbot | 1:c28fac16a109 | 48 | void calibrate(); |
soonerbot | 1:c28fac16a109 | 49 | }; |
soonerbot | 1:c28fac16a109 | 50 | |
soonerbot | 1:c28fac16a109 | 51 | #endif |