Practical Robotics Modular Robot Library

Dependents:   ModularRobot

led.h

Committer:
jah128
Date:
2016-11-28
Revision:
3:8762f6b2ea8d
Parent:
1:a6728adaf7e7
Child:
4:c2e933d53bea

File content as of revision 3:8762f6b2ea8d:

#ifndef LED_H
#define LED_H

/**
 *  The Led class contains the functions to control the robots LEDs
 */
class Led
{
public:

    /** 
     *  Sends the reset command to the reserved i2c address for the TLC59116 LED driver
     *
     *  As the led driver is powered independently from the MBED, and the MBED can be reset externally, this reset operation should
     *  be run as part of the initialisation routine to switch off the LEDs and restore them to the initial state.
     *
     * @return A zero if acknowledge recceived from LED driver chip, otherwise a non-zero
     */
    int reset_led_driver(void);
    
    /** 
     *  Turns on the oscillator and enables all the LED outputs on the TLC59116 LED driver
     *
     *
     * @return A zero if acknowledge recceived from LED driver chip, otherwise a non-zero
     */
    int init_led_driver(void);
    
    /**
     *  Set the brightness of all case LEDs to zero
     */
    void all_off(void);
    
    /**
     *
     *  Set an individual green led to the brightness specified
     * 
     * @param led - The index of the LED from 0 to 7 (corresponds the 1 to 8 on the PCB)
     * @param brightness - The PWM duty cycle from 0 to 255
     */
    void set_green_led (char led, char brightness);
    
    /**
     *
     *  Set an individual red led to the brightness specified
     * 
     * @param led - The index of the LED from 0 to 7 (corresponds the 1 to 8 on the PCB)
     * @param brightness - The PWM duty cycle from 0 to 255
     */
    void set_red_led (char led, char brightness);
  
    /**
     * Start a ticker-based simple routine that cycles through the LEDs for testing
     */
    void start_test(void);

    /**
     * Stops the ticker-based routine
     */    
    void stop_test(void);
    
    /**
     * The ticker loop for a simple routine that cycles through the LEDs for testing
     *
     */
    void test_ticker_routine(void);

};

#endif