-
Notifications
You must be signed in to change notification settings - Fork 0
/
Powerled.h
75 lines (62 loc) · 1.92 KB
/
Powerled.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
/*
* PowerLed - Led with fading effect controller (for Arduino)
*
* File: powerled.h
* Created on: 09/08/2016
* Author: Vagner Panarello (vpanarello@gmail.com)
*
*
*
* This library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser
* General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser
* General Public License along with this library; if not,
* write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef POWERLED_H_
#define POWERLED_H_
#include "Arduino.h"
#define LED_OFF 0
#define LED_ON 1
#define LED_BLINKING 2
#define LED_CYCLE_256MS 1
#define LED_CYCLE_512MS 2
#define LED_CYCLE_768MS 3
#define LED_CYCLE_1S 4
#define LED_CYCLE_2S 8
#define READ_STATE_PIN(pin) (PINB >> pin) & 0x01
#define SET_OUTPUT_PIN(pin) DDRB |= (1 << pin)
#define SET_INPUT_PIN(pin) DDRB &= ~(1 << pin)
#define SET_TO_HIGH_PIN(pin) PORTB |= (1 << pin)
#define SET_TO_LOW_PIN(pin) PORTB &= ~(1 << pin)
#define SET_PULLUP_RESISTOR(pin) PORTB |= (1 << pin)
#define TOGGLE_OUTPUT_PIN(pin) PORTB ^= (1 << pin)
class Powerled {
private:
uint8_t intensity;
uint8_t ledPin;
uint8_t frequency;
uint8_t state;
bool increment;
long nextClock;
public:
Powerled (uint8_t);
Powerled ();
virtual ~Powerled();
void setState(uint8_t state);
void setFrequency(uint8_t frequency);
void thread();
};
#endif /* POWERLED_H_ */