Programsko rješenje za uređaj koji mjeri nagib i udaljenost.

Dependencies:   mbed TextLCD

/https:/os.mbed.com/media/uploads/jpapratov/skiron_ii.jpeg

Committer:
jpapratov
Date:
Sat Nov 16 13:15:11 2019 +0000
Revision:
1:024485d1c677
Parent:
0:34c1f05d8d2c
uC

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jpapratov 0:34c1f05d8d2c 1 #ifndef MBED_MPU_H
jpapratov 0:34c1f05d8d2c 2 #define MBED_MPU_H
jpapratov 0:34c1f05d8d2c 3
jpapratov 0:34c1f05d8d2c 4 #include "mbed.h"
jpapratov 0:34c1f05d8d2c 5
jpapratov 0:34c1f05d8d2c 6 #define ADDRESS (0x68<<1)//iako je adresa 7 bitna mora biti shiftana za jedno mjesto u lijevo
jpapratov 0:34c1f05d8d2c 7 #define WHO_AM_I_REG 0x75// vraća adresu
jpapratov 0:34c1f05d8d2c 8 #define PWR_MGMT_1_REG 0x6B// podešavanje power mode i izvora sata
jpapratov 0:34c1f05d8d2c 9 #define CONFIG_REG 0x1A//konfiguracija
jpapratov 0:34c1f05d8d2c 10 #define GYRO_CONFIG_REG 0x1B//konfiguracija žiroskopa
jpapratov 0:34c1f05d8d2c 11 #define ACCELERO_CONFIG_REG 0x1C//konfiguracija akcelerometra
jpapratov 0:34c1f05d8d2c 12 #define GYRO_XOUT_H_REG 0x43
jpapratov 0:34c1f05d8d2c 13 #define ACCEL_XOUT_H_REG 0x3B
jpapratov 0:34c1f05d8d2c 14 #define TEMP_H_REG 0x41
jpapratov 0:34c1f05d8d2c 15
jpapratov 0:34c1f05d8d2c 16 class Senzor{
jpapratov 0:34c1f05d8d2c 17 public:
jpapratov 0:34c1f05d8d2c 18 Senzor(PinName Sda, PinName Scl);
jpapratov 0:34c1f05d8d2c 19 char testConnection ();
jpapratov 0:34c1f05d8d2c 20 void setBW (char command);
jpapratov 0:34c1f05d8d2c 21 void setPowerManagement (char command);
jpapratov 0:34c1f05d8d2c 22 void GYRO_CONFIG(char command);
jpapratov 0:34c1f05d8d2c 23 void ACCEL_CONFIG(char command);
jpapratov 0:34c1f05d8d2c 24 void getAccel(float *accel);
jpapratov 0:34c1f05d8d2c 25 void getGyro(float *gyro);
jpapratov 0:34c1f05d8d2c 26 void getAccAngle(float *angle);
jpapratov 0:34c1f05d8d2c 27 void getOffset(float *accOffset, float *gyroOffset, int sample);
jpapratov 0:34c1f05d8d2c 28 void finalAngle (float *angle);
jpapratov 0:34c1f05d8d2c 29 float getTemp();
jpapratov 0:34c1f05d8d2c 30
jpapratov 0:34c1f05d8d2c 31 private:
jpapratov 0:34c1f05d8d2c 32 I2C mpu;
jpapratov 0:34c1f05d8d2c 33
jpapratov 0:34c1f05d8d2c 34 };
jpapratov 0:34c1f05d8d2c 35 #endif