Open Lighting Architecture  Latest Git
NanoleafNode.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * NanoleafNode.h
17  * Header file for the NanoleafNode class.
18  * Copyright (C) 2017 Peter Newman
19  */
20 
21 #ifndef PLUGINS_NANOLEAF_NANOLEAFNODE_H_
22 #define PLUGINS_NANOLEAF_NANOLEAFNODE_H_
23 
24 #include <memory>
25 #include <vector>
26 
27 #include "ola/DmxBuffer.h"
28 #include "ola/base/Macro.h"
29 #include "ola/io/OutputStream.h"
30 #include "ola/io/IOQueue.h"
31 #include "ola/io/SelectServerInterface.h"
32 #include "ola/network/Interface.h"
34 #include "ola/network/Socket.h"
35 
36 namespace ola {
37 namespace plugin {
38 namespace nanoleaf {
39 
40 class NanoleafNode {
41  public:
43  std::vector<uint8_t> panels,
44  ola::network::UDPSocketInterface *socket = NULL);
45  virtual ~NanoleafNode();
46 
47  bool Start();
48  bool Stop();
49 
50  // The following apply to Input Ports (those which send data)
51  bool SendDMX(const ola::network::IPV4SocketAddress &target,
52  const ola::DmxBuffer &buffer);
53 
54  private:
55  bool m_running;
57  std::vector<uint8_t> m_panels;
58  ola::io::IOQueue m_output_queue;
59  ola::io::OutputStream m_output_stream;
60  ola::network::Interface m_interface;
61  std::auto_ptr<ola::network::UDPSocketInterface> m_socket;
62 
63  void SocketReady();
64  bool InitNetwork();
65 
66  static const uint8_t NANOLEAF_FRAME_COUNT = 0x01;
67  static const uint8_t NANOLEAF_WHITE_LEVEL = 0x00;
68  static const uint8_t NANOLEAF_TRANSITION_TIME = 0x01;
69  static const uint8_t NANOLEAF_SLOTS_PER_PANEL = 3;
70 
71  DISALLOW_COPY_AND_ASSIGN(NanoleafNode);
72 };
73 } // namespace nanoleaf
74 } // namespace plugin
75 } // namespace ola
76 #endif // PLUGINS_NANOLEAF_NANOLEAFNODE_H_
Represents Socket Addresses.
Definition: NanoleafNode.h:40
The interface for UDPSockets.
Definition: Socket.h:48
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
A class used to hold a single universe of DMX data.
The interface for the SelectServer.
Definition: SelectServerInterface.h:42
Definition: OutputStream.h:54
Definition: Interface.h:35
Definition: IOQueue.h:40
Helper macros.
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
An IPv4 SocketAddress.
Definition: SocketAddress.h:78