-
Notifications
You must be signed in to change notification settings - Fork 2
/
LED.h
100 lines (79 loc) · 2.79 KB
/
LED.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* LED.h
*
* Copyright (c) 2011
* Remco Magielse & Serge Offermans
* Intelligent Lighting Institute (ILI), TU/e.
*
* All rights reserved. LAST UPDATE: 13-08-2012
*/
#ifndef LED_h
#define LED_h
/* The following code makes the Library compatible with Arduino 1.0 */
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#include "cppfix.h"
#endif
/* */
#ifndef DEFAULT_DURATION
#define DEFAULT_DURATION 1000
#endif
#include "Animation.h"
/* Animation constants
static const uint8_t LINEAR = 0;
static const uint8_t QUADRATIC = 1;
static const uint8_t EXPONENTIAL = 2;
static const uint8_t CIRCULAR = 3;
static const uint8_t SINUS = 4;
*/
static const uint8_t PARAM_INTENSITY = 0;
static const uint8_t PARAM_CCT = 1;
static const uint8_t PARAM_HUE = 2;
static const uint8_t PARAM_SATURATION = 3;
/*! \mainpage The Arduino LED Library
* This Arduino Library is used to manage and control LEDs from the Arduino environment. It allows animation and actuation of single channel LEDs
as well as RGB and CCT (color temperature) LEDs. <br /><br />
<a href="functions_func.html">All available functions are documented here</a>
*/
/** \brief The LED class is the main class which is used to manage LEDs and contains all functionality for for single channel LEDs **/
/** The LED class is the main class which is used to manage LEDs and contains all functionality for for single channel LEDs **/
class LED
{
public:
LED();
LED( uint16_t channel, bool autoWrite = true );
LED( uint16_t channel, bool autoWrite, uint16_t x, uint16_t y );
~LED();
void update();
void setBrightness( int intensity, bool stopAnimation = true );
void setIntensity( int intensity, bool stopAnimation = true );
void setX( uint16_t x );
void setY( uint16_t y );
void setPosition( uint16_t x, uint16_t y );
void setChannel( uint16_t channel );
void setAnimationType( uint8_t animType = LINEAR, bool easeIn = true, bool easeOut = true );
void toggle();
void setToggle( bool toggle );
void intensityTo( int to, uint32_t duration = DEFAULT_DURATION );
void intensityFromTo( int from, int to, uint32_t duration = DEFAULT_DURATION );
void moveTo( uint16_t newX, uint16_t newY, uint32_t duration = DEFAULT_DURATION );
bool isOn();
bool isOff();
bool isAnimating();
bool hasNewValue();
uint8_t getChannel();
uint8_t getIntensity();
uint8_t getTargetIntensity();
uint16_t getX();
uint16_t getY();
/** The animation objects that is used to animate the LED **/
Animation * intensityAnim;
protected:
bool _on, _autoWrite, _hasNewValue;
uint16_t _channel;
uint16_t _x, _y;
uint8_t _intensity;
};
#endif