VLCB
Toggle main menu visibility
Loading...
Searching...
No Matches
LED.h
Go to the documentation of this file.
1
// Copyright (C) Sven Rosvall (sven@rosvall.ie)
2
// This file is part of VLCB-Arduino project on https://github.com/SvenRosvall/VLCB-Arduino
3
// Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
4
// The full licence can be found at: http://creativecommons.org/licenses/by-nc-sa/4.0/
5
6
//
7
//
8
//
9
10
#pragma once
11
12
#ifndef DEBUG_SERIAL
13
#define DEBUG_SERIAL Serial
14
#endif
15
16
#include <Arduino.h>
// for definition of byte datatype
17
// #include <Streaming.h>
18
19
namespace
VLCB
20
{
21
22
const
int
BLINK_RATE
= 500;
// flash at 1Hz, 500mS on, 500mS off
23
const
int
PULSE_ON_TIME
= 10;
24
25
//
27
//
28
class
LED
29
{
30
public
:
31
enum
Mode
:
byte
{
32
// Choose values so that lsb indicates if LED is on or off.
33
Off
= 0,
34
On
= 1,
35
Blinking_Off
= 2,
36
Blinking_On
= 3,
37
Pulsing
= 5,
38
39
IsOn
= 0x01,
40
IsBlinking
= 0x02,
41
IsPulsing
= 0x04
42
};
43
LED
();
44
explicit
LED
(
byte
pin,
bool
active = HIGH);
45
void
setPin
(
byte
pin,
bool
active = HIGH);
46
bool
getState
();
47
void
on
();
48
void
off
();
49
void
toggle
();
50
void
blink
(
unsigned
int
rate =
BLINK_RATE
);
51
void
pulse
(
unsigned
int
duration =
PULSE_ON_TIME
);
52
53
void
run
();
54
55
protected
:
56
byte
_pin
;
57
byte
_mode
;
58
bool
_active
;
59
unsigned
int
_interval
;
60
unsigned
long
_timer_start
;
61
62
void
_update
();
63
};
64
65
}
VLCB::LED::toggle
void toggle()
Definition
LED.cpp:53
VLCB::LED::blink
void blink(unsigned int rate=BLINK_RATE)
Definition
LED.cpp:59
VLCB::LED::off
void off()
Definition
LED.cpp:47
VLCB::LED::Mode
Mode
Definition
LED.h:31
VLCB::LED::Off
@ Off
Definition
LED.h:33
VLCB::LED::Pulsing
@ Pulsing
Definition
LED.h:37
VLCB::LED::On
@ On
Definition
LED.h:34
VLCB::LED::Blinking_On
@ Blinking_On
Definition
LED.h:36
VLCB::LED::IsOn
@ IsOn
Definition
LED.h:39
VLCB::LED::IsBlinking
@ IsBlinking
Definition
LED.h:40
VLCB::LED::Blinking_Off
@ Blinking_Off
Definition
LED.h:35
VLCB::LED::IsPulsing
@ IsPulsing
Definition
LED.h:41
VLCB::LED::_timer_start
unsigned long _timer_start
Definition
LED.h:60
VLCB::LED::pulse
void pulse(unsigned int duration=PULSE_ON_TIME)
Definition
LED.cpp:67
VLCB::LED::_update
void _update()
Definition
LED.cpp:112
VLCB::LED::on
void on()
Definition
LED.cpp:41
VLCB::LED::_pin
byte _pin
Definition
LED.h:56
VLCB::LED::LED
LED()
class for individual LED with non-blocking control
Definition
LED.cpp:15
VLCB::LED::setPin
void setPin(byte pin, bool active=HIGH)
Definition
LED.cpp:26
VLCB::LED::_active
bool _active
Definition
LED.h:58
VLCB::LED::_mode
byte _mode
Definition
LED.h:57
VLCB::LED::run
void run()
Definition
LED.cpp:88
VLCB::LED::getState
bool getState()
Definition
LED.cpp:35
VLCB::LED::_interval
unsigned int _interval
Definition
LED.h:59
VLCB
Definition
AbstractEventTeachingService.cpp:13
VLCB::BLINK_RATE
const int BLINK_RATE
Definition
LED.h:22
VLCB::PULSE_ON_TIME
const int PULSE_ON_TIME
Definition
LED.h:23
src
LED.h
Generated by
1.18.0