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.
CMPS_KRAI.h@1:a129c630cee0, 2019-03-21 (annotated)
- Committer:
- hisyamfs
- Date:
- Thu Mar 21 13:50:22 2019 +0000
- Revision:
- 1:a129c630cee0
- Parent:
- 0:595938ba3741
- Child:
- 2:a45896ca96f0
tes
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| calmantara186 | 0:595938ba3741 | 1 | /** |
| calmantara186 | 0:595938ba3741 | 2 | * adopted from |
| calmantara186 | 0:595938ba3741 | 3 | * CMPS03 by: Aarom Berk |
| calmantara186 | 0:595938ba3741 | 4 | * |
| calmantara186 | 0:595938ba3741 | 5 | * Bismillahirahmanirrahim |
| calmantara186 | 0:595938ba3741 | 6 | */ |
| calmantara186 | 0:595938ba3741 | 7 | |
| calmantara186 | 0:595938ba3741 | 8 | #ifndef CMPS_KRAI_H |
| calmantara186 | 0:595938ba3741 | 9 | #define CMPS_KRAI_H |
| calmantara186 | 0:595938ba3741 | 10 | |
| calmantara186 | 0:595938ba3741 | 11 | /** |
| calmantara186 | 0:595938ba3741 | 12 | * Includes |
| calmantara186 | 0:595938ba3741 | 13 | */ |
| calmantara186 | 0:595938ba3741 | 14 | #include "mbed.h" |
| calmantara186 | 0:595938ba3741 | 15 | |
| calmantara186 | 0:595938ba3741 | 16 | #define CMPS_DEFAULT_I2C_ADDRESS 0xC0 |
| calmantara186 | 0:595938ba3741 | 17 | //set register kompas |
| calmantara186 | 0:595938ba3741 | 18 | #define SOFTWARE_REVISION_REG 0x0 |
| calmantara186 | 0:595938ba3741 | 19 | #define COMPASS_BEARING_WORD_REG 0x2 |
| calmantara186 | 0:595938ba3741 | 20 | |
| calmantara186 | 0:595938ba3741 | 21 | //Inisiasi I2C komunikasi dari kompas |
| calmantara186 | 0:595938ba3741 | 22 | class CMPS_KRAI { |
| calmantara186 | 0:595938ba3741 | 23 | |
| calmantara186 | 0:595938ba3741 | 24 | I2C* i2c; |
| calmantara186 | 0:595938ba3741 | 25 | int i2cAddress; |
| calmantara186 | 0:595938ba3741 | 26 | |
| calmantara186 | 0:595938ba3741 | 27 | public: |
| calmantara186 | 0:595938ba3741 | 28 | |
| calmantara186 | 0:595938ba3741 | 29 | /** |
| calmantara186 | 0:595938ba3741 | 30 | * Constructor. |
| calmantara186 | 0:595938ba3741 | 31 | * |
| calmantara186 | 0:595938ba3741 | 32 | * @param sda mbed pin to use for I2C SDA |
| calmantara186 | 0:595938ba3741 | 33 | * @param scl mbed pin to use for I2C SCL |
| calmantara186 | 0:595938ba3741 | 34 | * @param address I2C address of this device. |
| calmantara186 | 0:595938ba3741 | 35 | */ |
| calmantara186 | 0:595938ba3741 | 36 | CMPS_KRAI(PinName sda, PinName scl, int address); |
| calmantara186 | 0:595938ba3741 | 37 | |
| calmantara186 | 0:595938ba3741 | 38 | /** |
| calmantara186 | 0:595938ba3741 | 39 | * Membaca revisi dari kompas |
| calmantara186 | 0:595938ba3741 | 40 | */ |
| calmantara186 | 0:595938ba3741 | 41 | char readSoftwareRevision(void); |
| calmantara186 | 0:595938ba3741 | 42 | |
| calmantara186 | 0:595938ba3741 | 43 | /** |
| calmantara186 | 0:595938ba3741 | 44 | * Membaca nilai dari kompas |
| calmantara186 | 0:595938ba3741 | 45 | * Range nilai 0 - 3599 |
| calmantara186 | 0:595938ba3741 | 46 | */ |
| calmantara186 | 0:595938ba3741 | 47 | int readBearing(void); |
| calmantara186 | 0:595938ba3741 | 48 | |
| calmantara186 | 0:595938ba3741 | 49 | /** |
| calmantara186 | 0:595938ba3741 | 50 | * Kalibrasi kompas |
| calmantara186 | 0:595938ba3741 | 51 | */ |
| calmantara186 | 0:595938ba3741 | 52 | void calibrate(void); |
| calmantara186 | 0:595938ba3741 | 53 | |
| calmantara186 | 0:595938ba3741 | 54 | /** |
| calmantara186 | 0:595938ba3741 | 55 | * Stop calibrate |
| calmantara186 | 0:595938ba3741 | 56 | */ |
| calmantara186 | 0:595938ba3741 | 57 | void stopCalibrate(void); |
| hisyamfs | 1:a129c630cee0 | 58 | |
| hisyamfs | 1:a129c630cee0 | 59 | /** |
| hisyamfs | 1:a129c630cee0 | 60 | /* Menghapus calibration profile |
| hisyamfs | 1:a129c630cee0 | 61 | */ |
| hisyamfs | 1:a129c630cee0 | 62 | void eraseProfile(); |
| hisyamfs | 1:a129c630cee0 | 63 | |
| hisyamfs | 1:a129c630cee0 | 64 | // Menyimpan calibration profile |
| hisyamfs | 1:a129c630cee0 | 65 | void storeProfile(); |
| calmantara186 | 0:595938ba3741 | 66 | }; |
| calmantara186 | 0:595938ba3741 | 67 | |
| calmantara186 | 0:595938ba3741 | 68 | #endif /* CMPS_KRAI_H */ |