-
Notifications
You must be signed in to change notification settings - Fork 0
/
moodlights.h
53 lines (41 loc) · 1.11 KB
/
moodlights.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
/*
* libhausbus: A RS485 Hausbus library
*
* Copyright (c) Ralf Ramsauer, 2016-2018
*
* Authors:
* Ralf Ramsauer <[email protected]>
*
* This work is licensed under the terms of the GNU GPL, version 3. See
* the LICENSE file in the top-level directory.
*/
#pragma once
#include <array>
#include <experimental/optional>
#include <regex>
#define MOODLIGHTS_LAMPS 10
#define MOODLIGHT_DEFAULT_IDENTIFIER 0x10
class Moodlights
{
public:
// Format: R:G:B
using Color = std::array<unsigned char, 3>;
Moodlights(const int fd);
~Moodlights();
static Color rand_color();
static std::experimental::optional<Color> parse_color(const std::string &str);
static std::string color_to_string(const Color &color);
void set(unsigned int no, const Color &c);
void set_all(const Color &c);
const Color &get(unsigned int no) const;
void blank(unsigned int no);
void blank_all();
void rand(const unsigned int no);
void rand_all();
void update() const;
private:
std::array<Color, MOODLIGHTS_LAMPS> _lamps;
const int _fd;
const static unsigned char _gamma_correction[256];
const static std::regex _color_regex;
};