Practical Robotics Modular Robot Library
led.h@0:8a2dd255c508, 2016-11-26 (annotated)
- Committer:
- jah128
- Date:
- Sat Nov 26 17:28:53 2016 +0000
- Revision:
- 0:8a2dd255c508
- Child:
- 1:a6728adaf7e7
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jah128 | 0:8a2dd255c508 | 1 | #ifndef LED_H |
jah128 | 0:8a2dd255c508 | 2 | #define LED_H |
jah128 | 0:8a2dd255c508 | 3 | |
jah128 | 0:8a2dd255c508 | 4 | class Led |
jah128 | 0:8a2dd255c508 | 5 | { |
jah128 | 0:8a2dd255c508 | 6 | public: |
jah128 | 0:8a2dd255c508 | 7 | |
jah128 | 0:8a2dd255c508 | 8 | /** |
jah128 | 0:8a2dd255c508 | 9 | * Sends the reset command to the reserved i2c address for the TLC59116 LED driver |
jah128 | 0:8a2dd255c508 | 10 | * |
jah128 | 0:8a2dd255c508 | 11 | * As the led driver is powered independently from the MBED, and the MBED can be reset externally, this reset operation should |
jah128 | 0:8a2dd255c508 | 12 | * be run as part of the initialisation routine to switch off the LEDs and restore them to the initial state. |
jah128 | 0:8a2dd255c508 | 13 | * |
jah128 | 0:8a2dd255c508 | 14 | * @return A zero if acknowledge recceived from LED driver chip, otherwise a non-zero |
jah128 | 0:8a2dd255c508 | 15 | */ |
jah128 | 0:8a2dd255c508 | 16 | int reset_led_driver(void); |
jah128 | 0:8a2dd255c508 | 17 | |
jah128 | 0:8a2dd255c508 | 18 | /** |
jah128 | 0:8a2dd255c508 | 19 | * Turns on the oscillator and enables all the LED outputs on the TLC59116 LED driver |
jah128 | 0:8a2dd255c508 | 20 | * |
jah128 | 0:8a2dd255c508 | 21 | * |
jah128 | 0:8a2dd255c508 | 22 | * @return A zero if acknowledge recceived from LED driver chip, otherwise a non-zero |
jah128 | 0:8a2dd255c508 | 23 | */ |
jah128 | 0:8a2dd255c508 | 24 | int init_led_driver(void); |
jah128 | 0:8a2dd255c508 | 25 | |
jah128 | 0:8a2dd255c508 | 26 | /** |
jah128 | 0:8a2dd255c508 | 27 | * |
jah128 | 0:8a2dd255c508 | 28 | * Set an individual green led to the brightness specified |
jah128 | 0:8a2dd255c508 | 29 | * |
jah128 | 0:8a2dd255c508 | 30 | * @param led - The index of the LED from 0 to 7 (corresponds the 1 to 8 on the PCB) |
jah128 | 0:8a2dd255c508 | 31 | * @param brightness - The PWM duty cycle from 0 to 255 |
jah128 | 0:8a2dd255c508 | 32 | */ |
jah128 | 0:8a2dd255c508 | 33 | void set_green_led (char led, char brightness); |
jah128 | 0:8a2dd255c508 | 34 | |
jah128 | 0:8a2dd255c508 | 35 | /** |
jah128 | 0:8a2dd255c508 | 36 | * |
jah128 | 0:8a2dd255c508 | 37 | * Set an individual red led to the brightness specified |
jah128 | 0:8a2dd255c508 | 38 | * |
jah128 | 0:8a2dd255c508 | 39 | * @param led - The index of the LED from 0 to 7 (corresponds the 1 to 8 on the PCB) |
jah128 | 0:8a2dd255c508 | 40 | * @param brightness - The PWM duty cycle from 0 to 255 |
jah128 | 0:8a2dd255c508 | 41 | */ |
jah128 | 0:8a2dd255c508 | 42 | void set_red_led (char led, char brightness); |
jah128 | 0:8a2dd255c508 | 43 | |
jah128 | 0:8a2dd255c508 | 44 | /** |
jah128 | 0:8a2dd255c508 | 45 | * Start a ticker-based simple routine that cycles through the LEDs for testing |
jah128 | 0:8a2dd255c508 | 46 | */ |
jah128 | 0:8a2dd255c508 | 47 | void start_test(void); |
jah128 | 0:8a2dd255c508 | 48 | |
jah128 | 0:8a2dd255c508 | 49 | /** |
jah128 | 0:8a2dd255c508 | 50 | * The ticker loop for a simple routine that cycles through the LEDs for testing |
jah128 | 0:8a2dd255c508 | 51 | * |
jah128 | 0:8a2dd255c508 | 52 | */ |
jah128 | 0:8a2dd255c508 | 53 | void test_ticker_routine(void); |
jah128 | 0:8a2dd255c508 | 54 | |
jah128 | 0:8a2dd255c508 | 55 | }; |
jah128 | 0:8a2dd255c508 | 56 | |
jah128 | 0:8a2dd255c508 | 57 | #endif |