forked from ryowens84/EL-Escudo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EL_Escudo.cpp
90 lines (73 loc) · 1.92 KB
/
EL_Escudo.cpp
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
/*
EL_Escudo.cpp - EL Escudo library
Written by Ryan Owens for SparkFun Electronics
This library is released under the 'Beer Me' license, so use it however you
with. Just buy me a beer if we ever meet!
***
Re-Written by Andy Durant
for Arduino 1.0+
with variable pulse width
*/
/******************************************************************************
* Includes
******************************************************************************/
#include "Arduino.h"
#include "EL_Escudo.h"
/******************************************************************************
* Definitions
******************************************************************************/
/******************************************************************************
* Constructors
******************************************************************************/
/******************************************************************************
* User API
******************************************************************************/
void EL_EscudoClass::on(int channel)
{
digitalWrite(channel, HIGH);
}
void EL_EscudoClass::off(int channel)
{
digitalWrite(channel, LOW);
}
void EL_EscudoClass::all_on(void)
{
for(int i=A; i<=H; i++){
EL.on(i);
}
}
void EL_EscudoClass::all_off(void)
{
for(int i=A; i<=H; i++){
EL.off(i);
}
}
void EL_EscudoClass::fade_in(int chan, int pW)
{
for(int brightness=0; brightness<=pW; brightness++){
for(int duration=0; duration<5; duration++){
on(chan);
delay(brightness);
off(chan);
delay(pW-brightness);
}
}
EL.on(chan);
}
void EL_EscudoClass::fade_out(int chan, int pW)
{
for(int brightness=pW; brightness>=0; brightness--){
for(int duration=0; duration<5; duration++){
on(chan);
delay(brightness);
off(chan);
delay(pW-brightness);
}
}
}
void EL_EscudoClass::pulse(int chan, int pW)
{
EL.fade_in(chan, pW);
EL.fade_out(chan, pW);
}
EL_EscudoClass EL;