Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
GenericUsbProWidget.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 * GenericUsbProWidget.h
17 * This class implements a generic Usb Pro style widget, which can send and
18 * receive DMX as well and get/set widget parameters.
19 * Copyright (C) 2011 Simon Newton
20 */
21
22#ifndef PLUGINS_USBPRO_GENERICUSBPROWIDGET_H_
23#define PLUGINS_USBPRO_GENERICUSBPROWIDGET_H_
24
25#include <deque>
26#include <string>
27#include "ola/Callback.h"
28#include "ola/DmxBuffer.h"
29#include "ola/thread/SchedulerInterface.h"
30#include "plugins/usbpro/BaseUsbProWidget.h"
31
32namespace ola {
33namespace plugin {
34namespace usbpro {
35
36typedef struct {
37 uint8_t firmware;
38 uint8_t firmware_high;
39 uint8_t break_time;
40 uint8_t mab_time;
41 uint8_t rate;
43
46
47
48/*
49 * An Generic DMX USB PRO Widget. This just handles the base functionality,
50 * other features like RDM, multi-universe support etc. can be layered on top
51 * of this.
52 */
54 public:
57
59 void GenericStop();
60
61 virtual bool SendDMX(const DmxBuffer &buffer);
62 bool ChangeToReceiveMode(bool change_only);
63 const DmxBuffer &FetchDMX() const;
64
66 bool SetParameters(uint8_t break_time,
67 uint8_t mab_time,
68 uint8_t rate);
69
70 static const uint8_t RECEIVED_DMX_LABEL = 5;
71
72 protected:
73 // child classes can intercept this.
74 virtual void HandleMessage(uint8_t label,
75 const uint8_t *data,
76 unsigned int length);
77 void HandleDMX(const uint8_t *data, unsigned int length);
78
79 private:
80 bool m_active;
81 DmxBuffer m_input_buffer;
82 ola::Callback0<void> *m_dmx_callback;
83 std::deque<usb_pro_params_callback*> m_outstanding_param_callbacks;
84
85 void HandleParameters(const uint8_t *data, unsigned int length);
86 void HandleDMXDiff(const uint8_t *data, unsigned int length);
87
88 static const uint8_t REPROGRAM_FIRMWARE_LABEL = 2;
89 static const uint8_t PARAMETERS_LABEL = 3;
90 static const uint8_t SET_PARAMETERS_LABEL = 4;
91 static const uint8_t DMX_RX_MODE_LABEL = 8;
92 static const uint8_t DMX_CHANGED_LABEL = 9;
93};
94} // namespace usbpro
95} // namespace plugin
96} // namespace ola
97#endif // PLUGINS_USBPRO_GENERICUSBPROWIDGET_H_
A class used to hold a single universe of DMX data.
A 0 argument callback which can be called multiple times.
Definition Callback.h:129
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
A 2 argument callback which deletes itself after it's run.
Definition Callback.h:1907
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition Descriptor.h:283
Definition BaseUsbProWidget.h:40
Definition GenericUsbProWidget.h:53
void SetDMXCallback(ola::Callback0< void > *callback)
Definition GenericUsbProWidget.cpp:56
void GetParameters(usb_pro_params_callback *callback)
Definition GenericUsbProWidget.cpp:128
void GenericStop()
Definition GenericUsbProWidget.cpp:67
const DmxBuffer & FetchDMX() const
Definition GenericUsbProWidget.cpp:119
bool SetParameters(uint8_t break_time, uint8_t mab_time, uint8_t rate)
Definition GenericUsbProWidget.cpp:149
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
Definition GenericUsbProWidget.h:36