CreatorCreator
Home
Getting Started
  • 中文简体
  • English
Home
Getting Started
  • 中文简体
  • English
  • Creator

    • Getting Started
  • Stream Dock

    • Plugin SDK
    • Icon Pack

      • Overview
      • Terminology
      • Creating an Icon Pack
      • Icon Specifications
    • Scene Configuration

      • What is a Scenario Configuration?
      • Exporting
      • Use Cases
  • mPanel

    • Plugin SDK
  • Linux StreamDock SDK

    • Cpp SDK

      • Overview
      • Dependency
      • Device Manager
      • StreamDock Base Class
      • StreamDock293
      • Communication transmission
      • Example
      • Source code
    • Python SDK

      • Overview
      • Dependency
      • DeviceManager
      • StreamDock Base Class
      • StreamDock293
      • Example
      • Source Code
  • Windows StreamDock SDK

    • WebSocket SDK

      • Overview
      • Getting Started
      • Events to Send
      • Received Events
    • Cpp SDK

      • Overview
      • Dependency
      • Device manager
      • StreamDock Base Class
      • StreamDock293
      • Transport
      • Example
      • Source Code
  • Support

    • Help and Bug Reporting

Cycle through all connected devices

Here is a complete example that enumerates all connected StreamDock devices and sets the image in turn.

#include <iostream>
#include "hidapi.h"
#include "streamDock.h"
#include "tranSport.h"
#include "streamDock293.h"
#include "DeviceManager.h"
#include <thread>
#include <unistd.h>
#define CMD_RESET 0xAA000000

int main()
{

// Define device management class
DeviceManager *manager = new DeviceManager();
// Traverse the device to get the device list
auto streamDocks = manager->enumerate();
scout << "discover" << streamDocks->size() << "devices" << "\n";
// Listen for new device connections or device disconnections
std::thread t(&DeviceManager::listen, manager);

sleep(10);
std::cout << "discover" << streamDocks->size() << "device" << "\n";
for (auto it = streamDocks->begin(); it != streamDocks->end(); it++)
{
auto s = it->second;
s->open();
// Set brightness
s->setBrightness(100);

std::string path = "1.jpg";
// Set background image
s->setBackgroundImg(path);

sleep(4);
path = "R-C.png";
s->setBackgroundImg(path);
sleep(4);
// Clear all icons
s->clearAllIcon();
// Set icon for key 2
s->setKeyImg("2.jpg", 2);
sleep(4);
// Clear icon for key 2
s->cleaerIcon(2);
}

t.join();
}
Last Updated:
Contributors: Heart
Prev
Communication transmission
Next
Source code