-
Notifications
You must be signed in to change notification settings - Fork 6
/
EL_Escudo.cpp
86 lines (72 loc) · 1.98 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
/*
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!
*/
/******************************************************************************
* Includes
******************************************************************************/
#include "WConstants.h"
#include "EL_Escudo.h"
/******************************************************************************
* Definitions
******************************************************************************/
/******************************************************************************
* Constructors
******************************************************************************/
/******************************************************************************
* User API
******************************************************************************/
void EL_EscudoClass::on(char channel)
{
pinMode(channel, OUTPUT);
digitalWrite(channel, LOW);
}
void EL_EscudoClass::off(char channel)
{
pinMode(channel, INPUT);
}
void EL_EscudoClass::all_on(void)
{
for(int i=0; i<4; i++){
EL.on(i*2+A);
EL.on(i*2+1+A);
delayMicroseconds(20);
EL.off(i*2+A);
EL.off(i*2+1+A);
}
}
void EL_EscudoClass::all_off(void)
{
for(int i=A; i<10; i++)EL.off(i);
}
void EL_EscudoClass::fade_in(char channel)
{
for(int brightness=0; brightness<=pulse_width; brightness++){
for(int duration=0; duration<5; duration++){
EL.on(channel);
delay(brightness);
EL.off(channel);
delay(pulse_width-brightness);
}
}
EL.on(channel);
}
void EL_EscudoClass::fade_out(char channel)
{
for(int brightness=pulse_width; brightness>=0; brightness--){
for(int duration=0; duration<5; duration++){
EL.on(channel);
delay(brightness);
EL.off(channel);
delay(pulse_width-brightness);
}
}
}
void EL_EscudoClass::pulse(char channel)
{
EL.fade_in(channel);
EL.fade_out(channel);
}
EL_EscudoClass EL;