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();
}