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

Take turns to operate all connected devices

Below is a complete example, which is used to traverse all the connected StreamDock devices and set up pictures in turn.

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

void fun(streamDock* s){
    while (1){
        unsigned char* buf = s->read();
        std::cout << buf << "  " << buf + 5 << " ";
        std::cout << (int)buf[9] << " ";
        std::cout << (int)buf[10] << "\n";
    }
}

int main() {
    DeviceManager *manager=new DeviceManager();
    auto streamDocks=manager->enumerate();
    std::cout<<"find"<<streamDocks->size()<<"device"<<"\n";
    std::thread t(&DeviceManager::listen,manager);
   
    for (auto it=streamDocks->begin();it!=streamDocks->end();it++){
       auto it1=streamDocks->begin();
       auto s=it1->second;
       s->open();
       s->wakeScreen();
       std::thread t1(fun,s);
       s->setBrightness(100);
       std::string path="hy.png";
       s->setBackgroundImg(path);
       Sleep(4000);
       s->setKeyImg("2.jpg",2);

       Sleep(4000);
       s->clearAllIcon();
       t1.join();
    }
    t.join();
}
Last Updated:
Contributors: Heart
Prev
Transport
Next
Source Code