AVR USB RGB LED Controller  1.1
 All Classes Namespaces Files Functions Variables Typedefs Properties Macros Pages
Classes | Macros | Typedefs | Functions
rgbledctrl.h File Reference
#include <usb.h>
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  s_rgbVal
 Structure for RGB values. More...
 
struct  s_rgbled_deviceSettings
 General device settings. More...
 
struct  s_rgbled_device
 RGB LED Device. More...
 
class  rgbledctrl
 C++ Wrapper class for C library. More...
 

Macros

#define RGBLED_IDLETIME_DISABLE   0
 

Typedefs

typedef unsigned char byte
 
typedef unsigned int uint
 
typedef uint16_t eepAddr_t
 

Functions

void rgbledctrl_init (void)
 
uint rgbledctrl_find (void)
 
bool rgbledctrl_sameDevice (usb_dev_handle *handle1, usb_dev_handle *handle2)
 
s_rgbled_devicergbledctrl_open (void)
 
s_rgbled_devicergbledctrl_open_byIndex (uint idx)
 
s_rgbled_devicergbledctrl_open_byEEPROM (byte value, eepAddr_t address)
 
void rgbledctrl_close (s_rgbled_device *device)
 
bool rgbledctrl_poke (s_rgbled_device *device)
 
bool rgbledctrl_reset (s_rgbled_device *device)
 
bool rgbledctrl_setIdleTime (s_rgbled_device *device, byte time)
 
bool rgbledctrl_setRGB (s_rgbled_device *device, s_rgbVal *colour)
 
bool rgbledctrl_setR (s_rgbled_device *device, byte value)
 
bool rgbledctrl_setG (s_rgbled_device *device, byte value)
 
bool rgbledctrl_setB (s_rgbled_device *device, byte value)
 
bool rgbledctrl_eeprom_write (s_rgbled_device *device, byte data, eepAddr_t address)
 
bool rgbledctrl_eeprom_read (s_rgbled_device *device, byte *data, eepAddr_t address)
 

Macro Definition Documentation

#define RGBLED_IDLETIME_DISABLE   0

Disable LED fade when no USB activity

Typedef Documentation

typedef unsigned char byte

Typedef for unsigned char

typedef uint16_t eepAddr_t

Unsigned 16bit type for EEPROM addresses

typedef unsigned int uint

Typedef for unsigned int

Function Documentation

void rgbledctrl_close ( s_rgbled_device device)

Close device.

Parameters
[device]Device to operate on
Returns
(none)
bool rgbledctrl_eeprom_read ( s_rgbled_device device,
byte data,
eepAddr_t  address 
)

Read device EEPROM

Parameters
[device]Device to operate on
[data]Pointer to buffer to write data to
[address]EEPROM address to read
Returns
true on success, false on failure
bool rgbledctrl_eeprom_write ( s_rgbled_device device,
byte  data,
eepAddr_t  address 
)

Write to device EEPROM

Parameters
[device]Device to operate on
[data]Data to write
[address]EEPROM address to write to
Returns
true on success, false on failure
uint rgbledctrl_find ( void  )

Update list of RGB LED controllers, should be called before opening devices.

Returns
Number of RGB LED controllers found.
void rgbledctrl_init ( void  )

Initialise, must be called before anything else!

Returns
(none)
s_rgbled_device* rgbledctrl_open ( void  )

Open whatever device is found first.

Returns
s_rgbled_device pointer if successful, NULL pointer if failed
s_rgbled_device* rgbledctrl_open_byEEPROM ( byte  value,
eepAddr_t  address 
)

Open device that has the specified value at the specified EEPROM address.

Parameters
[value]Value to check for
[address]EEPROM address to look at
Returns
s_rgbled_device pointer if successful, NULL pointer if failed
s_rgbled_device* rgbledctrl_open_byIndex ( uint  idx)

Open device using its position/index in the list of devices found by rgbledctrl_find().

Parameters
[idx]Index
Returns
s_rgbled_device pointer if successful, NULL pointer if failed
bool rgbledctrl_poke ( s_rgbled_device device)

Check if the device is still connected.

Parameters
[device]Device to operate on
Returns
true if connected, false if not
Todo:
Optional auto-reconnect
bool rgbledctrl_reset ( s_rgbled_device device)

Reset device (makes the watchdog timer timeout).

Parameters
[device]Device to operate on
Returns
true on success, false on failure
bool rgbledctrl_sameDevice ( usb_dev_handle *  handle1,
usb_dev_handle *  handle2 
)

Checks to see if two handles are handles for the same device.

Parameters
[handle1]Handle 1
[handle2]Handle 2
Returns
true if they are handles for the same device, otherwise false
bool rgbledctrl_setB ( s_rgbled_device device,
byte  value 
)

Set blue brightness

Parameters
[device]Device to operate on
[value]Brightness
Returns
true on success, false on failure
bool rgbledctrl_setG ( s_rgbled_device device,
byte  value 
)

Set green brightness

Parameters
[device]Device to operate on
[value]Brightness
Returns
true on success, false on failure
bool rgbledctrl_setIdleTime ( s_rgbled_device device,
byte  time 
)

Set idle time. Idle time is how long the controller waits (in seconds) before fading out the LEDs when there is no USB activity. RGBLED_IDLETIME_DISABLE = Disabled.

Parameters
[device]Device to operate on
[time]Timeout
Returns
true on success, false on failure
bool rgbledctrl_setR ( s_rgbled_device device,
byte  value 
)

Set red brightness

Parameters
[device]Device to operate on
[value]Brightness
Returns
true on success, false on failure
bool rgbledctrl_setRGB ( s_rgbled_device device,
s_rgbVal colour 
)

Set red, green and blue brightnesses in one go

Parameters
[device]Device to operate on
[colour]Pointer to s_rgbVal structure
Returns
true on success, false on failure