AVR USB RGB LED Controller  1.1
 All Classes Namespaces Files Functions Variables Typedefs Properties Macros Pages
rgbledctrl.h
Go to the documentation of this file.
1 /*
2  * Project: AVR USB RGB LED Controller
3  * Author: Zak Kemble, contact@zakkemble.co.uk
4  * Copyright: (C) 2013 by Zak Kemble
5  * License: GNU GPL v3 (see License.txt)
6  * Web: http://blog.zakkemble.co.uk/avr-usb-rgb-led-controller/
7  */
8 
9 #ifndef RGBLEDCTRL_H_
10 #define RGBLEDCTRL_H_
11 
12 #ifdef _WIN32
13 #include <lusb0_usb.h>
14 #else
15 #include <usb.h>
16 #endif
17 #include <stdbool.h>
18 #include <stdint.h>
19 
23 #define RGBLED_IDLETIME_DISABLE 0
24 
25 typedef unsigned char byte;
26 typedef unsigned int uint;
27 typedef uint16_t eepAddr_t;
32 typedef struct{
36 }s_rgbVal;
37 
41 typedef struct{
44 
49 typedef struct{
50  usb_dev_handle* handle;
51  byte version[2];
56 
57 #if defined(__cplusplus)
58 extern "C" {
59 #endif
60 
66 void rgbledctrl_init(void);
67 
73 uint rgbledctrl_find(void);
74 
82 bool rgbledctrl_sameDevice(usb_dev_handle* handle1, usb_dev_handle* handle2);
83 
90 
98 
107 
114 void rgbledctrl_close(s_rgbled_device* device);
115 
123 bool rgbledctrl_poke(s_rgbled_device* device);
124 
131 bool rgbledctrl_reset(s_rgbled_device* device);
132 
140 bool rgbledctrl_setIdleTime(s_rgbled_device* device, byte time);
141 
149 bool rgbledctrl_setRGB(s_rgbled_device* device, s_rgbVal* colour);
150 
158 bool rgbledctrl_setR(s_rgbled_device* device, byte value);
159 
167 bool rgbledctrl_setG(s_rgbled_device* device, byte value);
168 
176 bool rgbledctrl_setB(s_rgbled_device* device, byte value);
177 
186 bool rgbledctrl_eeprom_write(s_rgbled_device* device, byte data, eepAddr_t address);
187 
196 bool rgbledctrl_eeprom_read(s_rgbled_device* device, byte* data, eepAddr_t address);
197 
198 #if defined(__cplusplus)
199 }
200 #endif
201 
202 #if defined(__cplusplus) || defined(DOXYGEN)
203 
207 {
208 public:
214  static void init();
215 
221  static uint find();
222 
230  static bool sameDevice(usb_dev_handle* handle1, usb_dev_handle* handle2);
231 
235  rgbledctrl();
236 
240  ~rgbledctrl();
241 
247  bool open();
248 
255  bool open(uint idx);
256 
264  bool open(byte value, eepAddr_t address);
265 
271  void close();
272 
278  bool poke();
279 
285  bool reset();
286 
293  bool setIdleTime(byte time);
294 
301  bool setRGB(s_rgbVal& colour);
302 
309  bool setR(byte value);
310 
317  bool setG(byte value);
318 
325  bool setB(byte value);
326 
334  bool eeprom_write(byte data, eepAddr_t address);
335 
343  bool eeprom_read(byte& data, eepAddr_t address);
344 
350  void getVersion(byte (&version)[2]);
351 
356 
362  void getColour(s_rgbVal& colour);
363 
367  byte getIdleTime();
368 
372  usb_dev_handle* getHandle();
373 
374 private:
375  s_rgbled_device* device;
376 };
377 #endif
378 
379 #endif /* RGBLEDCTRL_H_ */
void getVersion(byte(&version)[2])
bool reset()
bool rgbledctrl_sameDevice(usb_dev_handle *handle1, usb_dev_handle *handle2)
byte blue
Definition: rgbledctrl.h:35
bool open()
s_rgbled_device * rgbledctrl_open(void)
usb_dev_handle * handle
Definition: rgbledctrl.h:50
uint16_t eepAddr_t
Definition: rgbledctrl.h:27
byte getIdleTime()
bool eeprom_read(byte &data, eepAddr_t address)
bool setB(byte value)
bool rgbledctrl_setRGB(s_rgbled_device *device, s_rgbVal *colour)
bool eeprom_write(byte data, eepAddr_t address)
static bool sameDevice(usb_dev_handle *handle1, usb_dev_handle *handle2)
s_rgbled_deviceSettings settings
Definition: rgbledctrl.h:54
bool rgbledctrl_setG(s_rgbled_device *device, byte value)
unsigned char byte
Definition: rgbledctrl.h:25
void close()
bool setIdleTime(byte time)
static uint find()
s_rgbled_device * rgbledctrl_open_byEEPROM(byte value, eepAddr_t address)
C++ Wrapper class for C library.
Definition: rgbledctrl.h:206
s_rgbled_device * rgbledctrl_open_byIndex(uint idx)
byte green
Definition: rgbledctrl.h:34
bool rgbledctrl_reset(s_rgbled_device *device)
s_rgbVal rgb
Definition: rgbledctrl.h:53
static void init()
bool poke()
bool setR(byte value)
RGB LED Device.
Definition: rgbledctrl.h:49
General device settings.
Definition: rgbledctrl.h:41
uint rgbledctrl_find(void)
void rgbledctrl_close(s_rgbled_device *device)
bool rgbledctrl_eeprom_write(s_rgbled_device *device, byte data, eepAddr_t address)
eepAddr_t getEepromSize()
byte red
Definition: rgbledctrl.h:33
bool rgbledctrl_setB(s_rgbled_device *device, byte value)
void getColour(s_rgbVal &colour)
bool rgbledctrl_eeprom_read(s_rgbled_device *device, byte *data, eepAddr_t address)
unsigned int uint
Definition: rgbledctrl.h:26
void rgbledctrl_init(void)
bool setG(byte value)
bool rgbledctrl_setR(s_rgbled_device *device, byte value)
byte idleTime
Definition: rgbledctrl.h:42
Structure for RGB values.
Definition: rgbledctrl.h:32
eepAddr_t eepromSize
Definition: rgbledctrl.h:52
bool setRGB(s_rgbVal &colour)
usb_dev_handle * getHandle()
bool rgbledctrl_setIdleTime(s_rgbled_device *device, byte time)
bool rgbledctrl_poke(s_rgbled_device *device)