library for m3Dpi robot, based on the Pololu 3pi and m3pi. m3Dpi has multiple distance sensors, gyroscope, compass and accelerometer sensor to be fully aware of its environment. With the addition of xbee or nrf24n01 module it has wireless communication capabilities.
Dependencies: m3pi ADXL345_I2C HMC5583L ITG3200 PCA9547 TLC59116 VL6180x RGB-fun xbee
Revision 10:4200a8140b10, committed 2015-12-19
- Comitter:
- sillevl
- Date:
- Sat Dec 19 10:42:51 2015 +0000
- Parent:
- 9:0af0a97f0ebf
- Child:
- 11:6f2440be5aa4
- Commit message:
- use single I2C instance shared with all i2c devices
Changed in this revision
--- a/M3Dpi.cpp Thu Dec 17 14:50:20 2015 +0000 +++ b/M3Dpi.cpp Sat Dec 19 10:42:51 2015 +0000 @@ -2,12 +2,13 @@ #include "M3Dpi.h" M3Dpi::M3Dpi() : + i2c(SDA,SCL), status(STATUS_RED,STATUS_GREEN,STATUS_BLUE), - compass(SDA, SCL, 0x3D), - gyro(SDA, SCL), - accelerometer(SDA,SCL), - leds(SDA, SCL), - distance(SDA, SCL), + compass(i2c), + gyro(i2c), + accelerometer(i2c), + leds(i2c), + distance(i2c), xbee(XBEE_TX, XBEE_RX, XBEE_RESET) { xbee.baud(XBEE_BAUD);
--- a/M3Dpi.h Thu Dec 17 14:50:20 2015 +0000 +++ b/M3Dpi.h Sat Dec 19 10:42:51 2015 +0000 @@ -33,6 +33,9 @@ // buttonhandler (interrupt based?) //protected: // public for hardware testing only + + I2C i2c; + StatusLed status; LedRing leds;
--- a/drivers/ADXL345_I2C.lib Thu Dec 17 14:50:20 2015 +0000 +++ b/drivers/ADXL345_I2C.lib Sat Dec 19 10:42:51 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/nimbusgb/code/ADXL345_I2C/#92fa975dab32 +http://mbed.org/users/nimbusgb/code/ADXL345_I2C/#a453a5e561c2
--- a/drivers/HMC5583L.lib Thu Dec 17 14:50:20 2015 +0000 +++ b/drivers/HMC5583L.lib Sat Dec 19 10:42:51 2015 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/sillevl/code/HMC5583L/#91f08ac76444 +https://developer.mbed.org/users/sillevl/code/HMC5583L/#097089f0feb1
--- a/drivers/ITG3200.lib Thu Dec 17 14:50:20 2015 +0000 +++ b/drivers/ITG3200.lib Sat Dec 19 10:42:51 2015 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/sillevl/code/ITG3200/#92aec36778a7 +https://developer.mbed.org/users/sillevl/code/ITG3200/#2dd53a8427e9
--- a/drivers/TLC59116.lib Thu Dec 17 14:50:20 2015 +0000 +++ b/drivers/TLC59116.lib Sat Dec 19 10:42:51 2015 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/sillevl/code/TLC59116/#52a1996ad711 +https://developer.mbed.org/users/sillevl/code/TLC59116/#c285b2c57b2e
--- a/drivers/VL6180x.lib Thu Dec 17 14:50:20 2015 +0000 +++ b/drivers/VL6180x.lib Sat Dec 19 10:42:51 2015 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/sillevl/code/VL6180x/#84c73bed7d92 +https://developer.mbed.org/users/sillevl/code/VL6180x/#6a00afc8dc84
--- a/lib/LedRing.cpp Thu Dec 17 14:50:20 2015 +0000 +++ b/lib/LedRing.cpp Sat Dec 19 10:42:51 2015 +0000 @@ -1,8 +1,17 @@ #include "LedRing.h" +LedRing::LedRing(I2C &i2c) : driver1(i2c, DRIVER_1_ADDRESS), driver2(i2c, DRIVER_2_ADDRESS) +{ + initialize(); +} LedRing::LedRing(PinName sda, PinName scl): driver1(sda, scl, DRIVER_1_ADDRESS), driver2(sda, scl, DRIVER_2_ADDRESS) { + initialize(); +} + +void LedRing::initialize() +{ driver1.enable(); driver2.enable();
--- a/lib/LedRing.h Thu Dec 17 14:50:20 2015 +0000 +++ b/lib/LedRing.h Sat Dec 19 10:42:51 2015 +0000 @@ -17,6 +17,7 @@ class LedRing{ public: + LedRing(I2C &i2c); LedRing(PinName sda, PinName scl); void setColor(int led, Color* Color); @@ -29,6 +30,7 @@ void greenRedGradient(int led, int value); protected: + void initialize(); void setLed(TLC59116* driver, int startChannel, Color* color); private:
--- a/lib/vl6180xManager.cpp Thu Dec 17 14:50:20 2015 +0000 +++ b/lib/vl6180xManager.cpp Sat Dec 19 10:42:51 2015 +0000 @@ -1,9 +1,18 @@ #include "vl6180xManager.h" +VL6180xManager::VL6180xManager(I2C &_i2c): mux(_i2c), i2c(_i2c), sensor(i2c) +{ + initialize(); +} VL6180xManager::VL6180xManager(PinName sda, PinName scl) : mux(sda, scl), i2c(sda, scl), sensor(sda, scl) { i2c.frequency(400000); + initialize(); +} + +void VL6180xManager::initialize() +{ for(int i = 0; i < SENSOR_COUNT; i++) { select(i); sensor.initialize();
--- a/lib/vl6180xManager.h Thu Dec 17 14:50:20 2015 +0000 +++ b/lib/vl6180xManager.h Sat Dec 19 10:42:51 2015 +0000 @@ -19,6 +19,7 @@ class VL6180xManager { public: + VL6180xManager(I2C &i2c); VL6180xManager(PinName sda, PinName scl); void select(int index); m3dpi::Distance getAllDistance(); @@ -36,6 +37,8 @@ LEFT, FRONT_LEFT };*/ + + void initialize(); PCA9547 mux; I2C i2c; int address;