Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
ArduinoWidget.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 * ArduinoWidget.h
17 * The Arduino RGB Mixer widget.
18 * Copyright (C) 2011 Simon Newton
19 */
20
21#ifndef PLUGINS_USBPRO_ARDUINOWIDGET_H_
22#define PLUGINS_USBPRO_ARDUINOWIDGET_H_
23
24#include <memory>
25#include "ola/DmxBuffer.h"
26#include "ola/rdm/UID.h"
27#include "ola/rdm/UIDSet.h"
30#include "plugins/usbpro/BaseUsbProWidget.h"
31
32namespace ola {
33namespace plugin {
34namespace usbpro {
35
36
37/*
38 * A Arduino Widget implementation. We separate the Widget from the
39 * implementation so we can leverage the QueueingRDMController.
40 */
43 public:
45 uint16_t esta_id,
46 uint32_t serial);
48
49 void Stop();
50
52 ola::rdm::RDMCallback *on_complete);
53
55 GetUidSet(callback);
56 }
57
59 GetUidSet(callback);
60 }
61
62 private:
63 uint8_t m_transaction_id;
64 ola::rdm::UID m_uid;
65 std::auto_ptr<const ola::rdm::RDMRequest> m_pending_request;
66 ola::rdm::RDMCallback *m_rdm_request_callback;
67
68 void HandleMessage(uint8_t label,
69 const uint8_t *data,
70 unsigned int length);
71 void HandleRDMResponse(const uint8_t *data, unsigned int length);
72 void GetUidSet(ola::rdm::RDMDiscoveryCallback *callback);
73
74 static const uint8_t RDM_REQUEST_LABEL;
75
76 // the first byte is the response code
77 static const uint8_t RESPONSE_OK;
78 static const uint8_t RESPONSE_WAS_BROADCAST;
79 static const uint8_t RESPONSE_FAILED;
80 static const uint8_t RESPONSE_FAILED_CHECKSUM;
81 static const uint8_t RESPONSE_INVALID_DESTINATION;
82 static const uint8_t RESPONSE_INVALID_COMMAND;
83};
84
85
86/*
87 * A Arduino Widget. This mostly just wraps the implementation.
88 */
91 public:
93 uint16_t esta_id,
94 uint32_t serial,
95 unsigned int queue_size = 20);
97
98 void Stop() { m_impl->Stop(); }
99
100 bool SendDMX(const DmxBuffer &buffer) {
101 return m_impl->SendDMX(buffer);
102 }
103
105 ola::rdm::RDMCallback *on_complete) {
106 m_controller->SendRDMRequest(request, on_complete);
107 }
108
110 m_impl->RunFullDiscovery(callback);
111 }
112
116
117 ola::io::ConnectedDescriptor *GetDescriptor() const {
118 return m_impl->GetDescriptor();
119 }
120
121 private:
122 // we need to control the order of construction & destruction here so these
123 // are pointers.
124 ArduinoWidgetImpl *m_impl;
126};
127} // namespace usbpro
128} // namespace plugin
129} // namespace ola
130#endif // PLUGINS_USBPRO_ARDUINOWIDGET_H_
A class used to hold a single universe of DMX data.
An RDM Controller that queues messages and only sends a single message at a time.
Definitions and Interfaces to implement an RDMController that sends a single message at a time.
A RDM unique identifier (UID).
A set of UIDs.
The base class for all 1 argument callbacks.
Definition Callback.h:982
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition Descriptor.h:283
Definition ArduinoWidget.h:90
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *on_complete)
Send a RDM command.
Definition ArduinoWidget.h:104
ArduinoWidget(ola::io::ConnectedDescriptor *descriptor, uint16_t esta_id, uint32_t serial, unsigned int queue_size=20)
Definition ArduinoWidget.cpp:231
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start an incremental discovery operation.
Definition ArduinoWidget.h:113
void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start a full discovery operation.
Definition ArduinoWidget.h:109
Definition ArduinoWidget.h:42
void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start a full discovery operation.
Definition ArduinoWidget.h:54
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *on_complete)
Definition ArduinoWidget.cpp:100
~ArduinoWidgetImpl()
Definition ArduinoWidget.cpp:78
void Stop()
Definition ArduinoWidget.cpp:87
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start an incremental discovery operation.
Definition ArduinoWidget.h:58
Definition BaseUsbProWidget.h:40
Definition SerialWidgetInterface.h:38
Definition QueueingRDMController.h:88
The interface that can send RDM commands, as well as perform discovery operations.
Definition RDMControllerInterface.h:104
void SendRDMRequest(RDMRequest *request, RDMCallback *on_complete)
Definition QueueingRDMController.cpp:96
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition RDMCommand.h:234
Represents a RDM UID.
Definition UID.h:57
The namespace containing all OLA symbols.
Definition Credentials.cpp:44