Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic HID devices (Arduino for example) output suuport #83

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/devices/arduino-homecockpit/ArduinoHomeCockpit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "core/Logger.h"

#define WRITE_BUFFER_SIZE 64
#define READ_BUFFER_SIZE 9
#define READ_BUFFER_SIZE 64

std::filesystem::path get_plugin_path();

Expand All @@ -31,8 +31,10 @@ ArduinoHomeCockpit::ArduinoHomeCockpit(DeviceConfiguration& config) :UsbHidDevic
return;
}

register_selectors(arduino_buttons);
register_buttons(arduino_buttons);
register_displays(arduino_displays);
register_lights(arduino_lights);

for (auto &config_display : config.generic_displays)
{
Expand Down Expand Up @@ -137,14 +139,20 @@ int ArduinoHomeCockpit::read_board_configuration(std::string file_name, unsigned
continue;
}

if (std::regex_match(line.c_str(), m, std::regex(TOKEN_LIGHT)))
{
unsigned int bit_index = stoi(m[2]);
arduino_lights.push_back(PanelLight(register_index * 8 + bit_index, m[1]));

Logger(TLogLevel::logDEBUG) << "board config: add light: " << m[1] << " [" << register_index << "," << bit_index << "]" << std::endl;
continue;
}

Logger(TLogLevel::logERROR) << "board config: invalid config line (" << current_line_nr << "): " << line << std::endl;
exit_status = EXIT_FAILURE;
}

input_file.close();

register_selectors(arduino_buttons);

return exit_status;
}

Expand Down
3 changes: 3 additions & 0 deletions src/devices/arduino-homecockpit/ArduinoHomeCockpit.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ArduinoHomeCockpit :public UsbHidDevice
private:
std::vector<PanelButton> arduino_buttons;
std::vector<PanelDisplay> arduino_displays;
std::vector<PanelLight> arduino_lights;

int read_board_configuration(std::string file_name, unsigned int expected_vid, unsigned int expected_pid);

unsigned int register_index;
Expand All @@ -22,6 +24,7 @@ class ArduinoHomeCockpit :public UsbHidDevice
const std::string TOKEN_REGISTER = "\\[register:adr=([0-9]+)\\]";
const std::string TOKEN_BUTTON = "button:id=\"([a-zA-Z0-9_-]+)\",bit=([0-9]+)";
const std::string TOKEN_DISPLAY = "display:id=\"([a-zA-Z0-9_-]+)\",width=([0-9]+)";
const std::string TOKEN_LIGHT = "light:id=\"([a-zA-Z0-9_-]+)\",bit=([0-9]+)";
public:
ArduinoHomeCockpit(DeviceConfiguration& config);
int connect();
Expand Down
Loading