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.
I2cPeripherals.h
00001 #ifndef MBED_I2cPeripherals_H 00002 #define MBED_I2cPeripherals_H 00003 00004 #include "mbed.h" 00005 #include <iostream> 00006 #include "stdarg.h" 00007 00008 #define LPS331AP // baro 00009 #define L3GD20 // gyro 00010 #define MPU6050 // gyro and accelameter 00011 #define ITG3200 // gyro 00012 #define ACM1602 // I2C LCD 00013 #define ST7032 // I2C LCD 00014 #define ADXL345 // accelameter 00015 #define GYRO_ADDR 0 00016 #define ACCEL_ADDR 1 00017 #define LCD_ADDR 3 00018 #define BARO_ADDR 4 00019 #define ULTRASONIC_ADDR 5 00020 #define I2C_EEPROM_ADDR 0xA0 00021 00022 class I2cPeripherals 00023 { 00024 public: 00025 I2cPeripherals(PinName , PinName ); 00026 00027 void start(int contrast=60); 00028 int write_lcd(const char*); 00029 void write_reg(int,char,char*,int); 00030 void read_reg(int,char,char*,int); 00031 int write_EEPROM(short,char*,int); 00032 int read_EEPROM(short,char*,int); 00033 void cls(); 00034 void locate(int,int); 00035 int GetAddr(int); 00036 int angular(float*,float*,float*); 00037 int Acceleration(float*,float*,float*); 00038 int pressure(); 00039 int temperature(); 00040 float height_cm(); 00041 float height_mm(); 00042 float height_us(); 00043 private: 00044 // virtual int _putc(int value); 00045 // virtual int _getc(); 00046 void i2c_write(int,char*,int); 00047 void find(); 00048 int ultrasonic(char); 00049 I2C _i2c; 00050 int LCD_addr; 00051 char LCD_cmd; 00052 char LCD_data; 00053 int Gyro_addr; 00054 char Gyro_data; 00055 int Accel_addr; 00056 char Accel_data; 00057 int barometor_addr; 00058 char barometor_data; 00059 int ultrasonic_addr; 00060 char ultrasonic_data; 00061 int ultrasonic_distance; 00062 int LCD_contrast; 00063 struct SensorInf { 00064 char addr; 00065 char who; //WHO_AMI 00066 char whoaddr; //WHO_AMI resister address 00067 }; 00068 }; 00069 #endif
Generated on Wed Jul 13 2022 09:20:34 by
1.7.2