Open Lighting Architecture: plugins/usbpro/ArduinoRGBDevice.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
ArduinoRGBDevice.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 * ArduinoRGBDevice.h
17 * The Arduino RGB Mixer device.
18 * Copyright (C) 2010 Simon Newton
19 */
20
21#ifndef PLUGINS_USBPRO_ARDUINORGBDEVICE_H_
22#define PLUGINS_USBPRO_ARDUINORGBDEVICE_H_
23
24#include <string>
25#include "ola/DmxBuffer.h"
26#include "olad/TokenBucket.h"
27#include "plugins/usbpro/ArduinoWidget.h"
28#include "plugins/usbpro/UsbSerialDevice.h"
29
30namespace ola {
31namespace plugin {
32namespace usbpro {
33
34
35/*
36 * An Arduino RGB Mixer Device
37 */
38 class ArduinoRGBDevice: public UsbSerialDevice {
39 public:
40 ArduinoRGBDevice(ola::io::SelectServerInterface *ss,
41 ola::AbstractPlugin *owner,
42 const std::string &name,
43 ArduinoWidget *widget,
44 uint16_t esta_id,
45 uint16_t device_id,
46 uint32_t serial);
47
48 std::string DeviceId() const { return m_device_id; }
49
50 private:
51 std::string m_device_id;
52};
53
54
55/*
56 * A single Output port per device
57 */
58 class ArduinoRGBOutputPort: public BasicOutputPort {
59 public:
60 ArduinoRGBOutputPort(ArduinoRGBDevice *parent,
61 ArduinoWidget *widget,
62 uint32_t serial,
63 const TimeStamp *wake_time,
64 unsigned int initial_count,
65 unsigned int rate);
66
67 std::string Description() const { return m_description; }
68
69 bool WriteDMX(const DmxBuffer &buffer, uint8_t) {
70 if (m_bucket.GetToken(*m_wake_time))
71 return m_widget->SendDMX(buffer);
72 else
73 OLA_INFO << "Port rated limited, dropping frame";
74 return true;
75 }
76
77 void SendRDMRequest(ola::rdm::RDMRequest *request,
78 ola::rdm::RDMCallback *callback) {
79 return m_widget->SendRDMRequest(request, callback);
80 }
81
82 void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback) {
83 m_widget->RunFullDiscovery(callback);
84 }
85
86 void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback) {
87 m_widget->RunIncrementalDiscovery(callback);
88 }
89
90 private:
91 ArduinoWidget *m_widget;
92 TokenBucket m_bucket;
93 const TimeStamp *m_wake_time;
94 std::string m_description;
95};
96} // namespace usbpro
97} // namespace plugin
98} // namespace ola
99#endif // PLUGINS_USBPRO_ARDUINORGBDEVICE_H_
DmxBuffer.h
A class used to hold a single universe of DMX data.
ola::AbstractPlugin
Definition Plugin.h:38
ola::BasicOutputPort::BasicOutputPort
BasicOutputPort(AbstractDevice *parent, unsigned int port_id, bool start_rdm_discovery_on_patch=false, bool supports_rdm=false)
Create a new BasicOutputPort.
Definition Port.cpp:120
ola::DmxBuffer
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
ola::TimeStamp
Definition Clock.h:179
ola::TokenBucket
Definition TokenBucket.h:29
ola::io::SelectServerInterface
The interface for the SelectServer.
Definition SelectServerInterface.h:42
ola::plugin::usbpro::ArduinoRGBDevice
Definition ArduinoRGBDevice.h:38
ola::plugin::usbpro::ArduinoRGBDevice::DeviceId
std::string DeviceId() const
The device ID.
Definition ArduinoRGBDevice.h:48
ola::plugin::usbpro::ArduinoRGBOutputPort::WriteDMX
bool WriteDMX(const DmxBuffer &buffer, uint8_t)
Write DMX data to this port.
Definition ArduinoRGBDevice.h:69
ola::plugin::usbpro::ArduinoRGBOutputPort::RunFullDiscovery
void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
This is a noop for ports that don't support RDM.
Definition ArduinoRGBDevice.h:82
ola::plugin::usbpro::ArduinoRGBOutputPort::RunIncrementalDiscovery
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
This is a noop for ports that don't support RDM.
Definition ArduinoRGBDevice.h:86
ola::plugin::usbpro::ArduinoRGBOutputPort::Description
std::string Description() const
Fetch the string description for a Port.
Definition ArduinoRGBDevice.h:67
ola::plugin::usbpro::ArduinoRGBOutputPort::SendRDMRequest
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *callback)
Handle an RDMRequest, subclasses can implement this to support RDM.
Definition ArduinoRGBDevice.h:77
ola::plugin::usbpro::ArduinoWidget
Definition ArduinoWidget.h:90
ola::rdm::RDMRequest
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition RDMCommand.h:234
OLA_INFO
#define OLA_INFO
Definition Logging.h:81
ola::plugin::usbpro
Code for Enttec USB Pro devices and others using the same protocol.
ola::plugin
Code for supported devices and protocols.
ola::rdm::RDMCallback
ola::BaseCallback1< void, RDMReply * > RDMCallback
The callback run when a RDM request completes.
Definition RDMControllerInterface.h:52
ola::rdm::RDMDiscoveryCallback
ola::BaseCallback1< void, const ola::rdm::UIDSet & > RDMDiscoveryCallback
The callback run when a discovery operation completes.
Definition RDMControllerInterface.h:68
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44