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

Dependents:   m3Dpi-helloworld

lib/LedRing.h

Committer:
sillevl
Date:
2016-01-20
Revision:
12:4cb092df6958
Parent:
10:4200a8140b10

File content as of revision 12:4cb092df6958:

#pragma once

#include "mbed.h"
#include "TLC59116.h"
#include "Color.h"

enum DistanceSensor{
    FRONT_LEFT,
    FRONT_MIDDLE_LEFT,
    BACK_MIDDLE_LEFT,
    BACK_LEFT,
    BACK_RIGHT,
    BACK_MIDDLE_RIGHT,
    FRONT_MIDDLE_RIGHT,
    FRONT_RIGHT  
}; 

class LedRing{
    public:
    LedRing(I2C &i2c);
    LedRing(PinName sda, PinName scl);
    
    void setColor(int led, Color* Color);
    void setColor(int led, int color);
    void setAll(int color);
    void setAll(Color* color);
    void setAll(int* colors);
    void setBrightness(float brightness);
    
    void greenRedGradient(int led, int value);
    
    protected:
    void initialize();
    void setLed(TLC59116* driver, int startChannel, Color* color);
    
    private:
    TLC59116 driver1;
    TLC59116 driver2;
    
    static const int DRIVER_1_ADDRESS = 0xC0;
    static const int DRIVER_2_ADDRESS = 0xC2;
    
};