the usb mode can be accessible by super classes
This commit is contained in:
parent
55317f7513
commit
6387944c68
|
@ -33,7 +33,7 @@ Widget::Widget()
|
|||
, tx_break_intervals(17) // 181.4 us by default
|
||||
, tx_mab_intervals(10) // 106.7 us by default
|
||||
, tx_rate(40) // 40 packets/s, by default
|
||||
, usb_mode_(USBunknown)
|
||||
, usb_mode(USBunknown)
|
||||
, rx_update_mode_(Pro::RxNotifyAlways)
|
||||
, token_data_changed_(nullptr)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ Widget::Widget()
|
|||
|
||||
Widget::~Widget()
|
||||
{
|
||||
switch (usb_mode_) {
|
||||
switch (usb_mode) {
|
||||
case USBdevice:
|
||||
Widget::halt();
|
||||
break;
|
||||
|
@ -64,7 +64,7 @@ void Widget::init()
|
|||
{
|
||||
{
|
||||
std::scoped_lock lock(mtx_metadata_);
|
||||
usb_mode_ = USBdevice;
|
||||
usb_mode = USBdevice;
|
||||
}
|
||||
setModeBridge();
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ void Widget::init()
|
|||
void Widget::halt()
|
||||
{
|
||||
std::scoped_lock lock(mtx_metadata_);
|
||||
usb_mode_ = USBunknown;
|
||||
usb_mode = USBunknown;
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,7 +93,7 @@ void Widget::open()
|
|||
{
|
||||
{
|
||||
std::scoped_lock lock(mtx_metadata_);
|
||||
usb_mode_ = USBhost; // note connected state
|
||||
usb_mode = USBhost; // note connected state
|
||||
}
|
||||
setModeBridge();
|
||||
getParameters(0, 500); // retrieve widget metadata
|
||||
|
@ -109,7 +109,7 @@ void Widget::open()
|
|||
void Widget::close()
|
||||
{
|
||||
std::scoped_lock lock(mtx_metadata_);
|
||||
usb_mode_ = USBunknown;
|
||||
usb_mode = USBunknown;
|
||||
}
|
||||
|
||||
|
||||
|
@ -309,7 +309,7 @@ void Widget::routeRxMessage(std::shared_ptr<Pro::MessageData> msg)
|
|||
break;
|
||||
case Pro::OpProgramFlashPage:
|
||||
{
|
||||
switch (usb_mode_) {
|
||||
switch (usb_mode) {
|
||||
case USBdevice:
|
||||
{
|
||||
auto data = std::static_pointer_cast<Pro::MsgProgramFlashPageRequest>(msg);
|
||||
|
@ -329,7 +329,7 @@ void Widget::routeRxMessage(std::shared_ptr<Pro::MessageData> msg)
|
|||
break;
|
||||
case Pro::OpGetWidgetParameters:
|
||||
{
|
||||
switch (usb_mode_) {
|
||||
switch (usb_mode) {
|
||||
case USBdevice:
|
||||
{
|
||||
auto data = std::static_pointer_cast<Pro::MsgGetWidgetParametersRequest>(msg);
|
||||
|
@ -385,7 +385,7 @@ void Widget::routeRxMessage(std::shared_ptr<Pro::MessageData> msg)
|
|||
break;
|
||||
case Pro::OpGetWidgetSerial:
|
||||
{
|
||||
switch (usb_mode_) {
|
||||
switch (usb_mode) {
|
||||
case USBdevice:
|
||||
{
|
||||
auto data = std::static_pointer_cast<Pro::MsgGetWidgetSerialRequest>(msg);
|
||||
|
@ -434,7 +434,7 @@ void Widget::sendMessage(std::shared_ptr<Pro::MessageData> msg) const
|
|||
*/
|
||||
void Widget::rebootBootloader()
|
||||
{
|
||||
switch (usb_mode_) {
|
||||
switch (usb_mode) {
|
||||
case USBhost:
|
||||
{
|
||||
auto msg = std::make_shared<Pro::MsgReprogramFirmware>();
|
||||
|
@ -547,7 +547,7 @@ void Widget::sendDmx(bool trimmed) const
|
|||
*/
|
||||
void Widget::rxMsgHello(std::shared_ptr<Pro::MessageData> msg)
|
||||
{
|
||||
switch (usb_mode_) {
|
||||
switch (usb_mode) {
|
||||
case USBdevice:
|
||||
sendMessage(msg); // mirror the message back to the host
|
||||
break;
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
* @brief isConnected
|
||||
* @return
|
||||
*/
|
||||
bool isConnected() const { return usb_mode_ != USBunknown; }
|
||||
bool isConnected() const { return usb_mode != USBunknown; }
|
||||
|
||||
virtual void setModeController();
|
||||
virtual void setModeBridge(Pro::DMX_RX_MODE = Pro::RxNotifyAlways);
|
||||
|
@ -74,6 +74,13 @@ public:
|
|||
|
||||
bool writeFirmware(const uint8_t *, const size_t);
|
||||
|
||||
/// @brief The OperatingMode enum
|
||||
enum OperatingMode {
|
||||
USBunknown,
|
||||
USBhost,
|
||||
USBdevice
|
||||
};
|
||||
|
||||
protected:
|
||||
void routeRxMessage(std::shared_ptr<Pro::MessageData>);
|
||||
|
||||
|
@ -99,6 +106,7 @@ protected:
|
|||
uint8_t tx_mab_intervals; //!< DMX_MAB_INTERVAL count of the DMX MARK AFTER BREAK
|
||||
uint8_t tx_rate; //!< DMX packet transmit Rate
|
||||
std::vector<uint8_t> user_configuration; //!< User defined configuration data.
|
||||
OperatingMode usb_mode; //!< The side of the USB the widget is acting on.
|
||||
|
||||
private:
|
||||
void rxMsgHello(std::shared_ptr<Pro::MessageData>);
|
||||
|
@ -117,11 +125,6 @@ private:
|
|||
void rxMsgGetWidgetSerialReply(std::shared_ptr<Pro::MsgGetWidgetSerialReply>);
|
||||
void rxMsgSendRDMDiscovery(std::shared_ptr<Pro::MsgSendRDMDiscovery>);
|
||||
|
||||
enum OperatingModes {
|
||||
USBunknown,
|
||||
USBhost,
|
||||
USBdevice
|
||||
} usb_mode_;
|
||||
Pro::DMX_RX_MODE rx_update_mode_;
|
||||
|
||||
mutable std::mutex mtx_metadata_;
|
||||
|
|
Loading…
Reference in New Issue