Open Lighting Architecture  Latest Git
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
30 namespace ola {
31 namespace plugin {
32 namespace usbpro {
33 
34 
35 /*
36  * An Arduino RGB Mixer Device
37  */
39  public:
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  */
59  public:
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 
78  ola::rdm::RDMCallback *callback) {
79  return m_widget->SendRDMRequest(request, callback);
80  }
81 
83  m_widget->RunFullDiscovery(callback);
84  }
85 
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_
std::string Description() const
Fetch the string description for a Port.
Definition: ArduinoRGBDevice.h:67
Definition: ArduinoRGBDevice.h:58
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start an incremental discovery operation.
Definition: ArduinoWidget.h:113
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *on_complete)
Send a RDM command.
Definition: ArduinoWidget.h:104
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition: RDMCommand.h:234
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
#define OLA_INFO
Definition: Logging.h:83
bool WriteDMX(const DmxBuffer &buffer, uint8_t)
Write DMX data to this port.
Definition: ArduinoRGBDevice.h:69
std::string DeviceId() const
The device ID.
Definition: ArduinoRGBDevice.h:48
A class used to hold a single universe of DMX data.
Definition: TokenBucket.h:29
The interface for the SelectServer.
Definition: SelectServerInterface.h:42
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *callback)
Handle an RDMRequest, subclasses can implement this to support RDM.
Definition: ArduinoRGBDevice.h:77
Definition: ArduinoWidget.h:89
Definition: UsbSerialDevice.h:36
The base class for all 1 argument callbacks.
Definition: Callback.h:982
void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start a full discovery operation.
Definition: ArduinoWidget.h:109
void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
This is a noop for ports that don't support RDM.
Definition: ArduinoRGBDevice.h:82
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
This is a noop for ports that don't support RDM.
Definition: ArduinoRGBDevice.h:86
Definition: ArduinoRGBDevice.h:38
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Represents a point in time with microsecond accuracy.
Definition: Clock.h:183
Definition: Port.h:282
Definition: Plugin.h:38