LightHub 4.6.0
Open-source smart home controller firmware
Loading...
Searching...
No Matches
statusled.h
Go to the documentation of this file.
1/* Copyright © 2017-2018 Andrey Klimov. All rights reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14
15Homepage: http://lazyhome.ru
16GIT: https://github.com/anklimov/lighthub
17e-mail anklimov@gmail.com
18
19*/
20#pragma once
21#include <Arduino.h>
22
24#define ledRED 1
26#define ledGREEN 2
28#define ledBLUE 4
30#define ledBLINK 8
32#define ledFASTBLINK 16
34#define ledParams (ledRED | ledGREEN | ledBLUE | ledBLINK | ledFASTBLINK)
35
37#define ledFlash 32
39#define ledHidden 64
40
41#if defined(ARDUINO_ARCH_AVR)
42#define pinRED 47
43#define pinGREEN 48
44#define pinBLUE 49
45#else
46// Due: RGB status LED on pins 50-52
47#define pinRED 50
48#define pinGREEN 51
49#define pinBLUE 52
50#endif
51
53#define ledDelayms 1000UL
55#define ledFastDelayms 300UL
56
64class StatusLED {
65public:
70 StatusLED(uint8_t pattern = 0);
75 void set (uint8_t pattern);
80 void show (uint8_t pattern);
84 void poll();
89 void flash(uint8_t pattern);
90private:
92 uint8_t curStat;
94 uint32_t timestamp;
95};
void set(uint8_t pattern)
Sets the steady/blinking LED pattern.
Definition statusled.cpp:45
void poll()
Advances blink/flash timing; call from the main loop.
Definition statusled.cpp:67
void flash(uint8_t pattern)
Shows the given pattern once (single flash).
Definition statusled.cpp:59
StatusLED(uint8_t pattern=0)
Initializes the LED pins and sets the initial pattern.
Definition statusled.cpp:25
void show(uint8_t pattern)
Immediately drives the pins to the given color (no state change).
Definition statusled.cpp:36