From f24c710af235e2e28c86b1f1646856fac9d10fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Bourdeauducq?= Date: Sun, 19 Jan 2025 19:25:55 +0800 Subject: [PATCH] Kirdy::set_tec_current --- kirdy.cpp | 15 ++++++++++++--- kirdy.hpp | 1 + sndlock.cpp | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/kirdy.cpp b/kirdy.cpp index d05d007..3258ac8 100644 --- a/kirdy.cpp +++ b/kirdy.cpp @@ -29,8 +29,17 @@ Json::Value Kirdy::command(Json::Value &request) float Kirdy::get_laser_temp() { - Json::Value json; - json["device_cmd"] = "GetStatusReport"; - auto reply = command(json); + Json::Value request; + request["device_cmd"] = "GetStatusReport"; + Json::Value reply = command(request); return reply["thermostat"]["temperature"].asFloat(); } + +void Kirdy::set_tec_current(float amps) +{ + Json::Value request; + request["tec_set_i"] = amps; + Json::Value reply = command(request); + if(reply["msg_type"].asString() != "Acknowledge") + std::cerr << "TEC set current failed" << std::endl; +} diff --git a/kirdy.hpp b/kirdy.hpp index 6ecafcb..8d83305 100644 --- a/kirdy.hpp +++ b/kirdy.hpp @@ -10,4 +10,5 @@ class Kirdy { public: Kirdy(asio::string_view host, asio::string_view service); float get_laser_temp(); + void set_tec_current(float amps); }; diff --git a/sndlock.cpp b/sndlock.cpp index f7f7c9b..16cfb89 100644 --- a/sndlock.cpp +++ b/sndlock.cpp @@ -260,6 +260,7 @@ static void servo_thread(int channel) while(!shutdown_threads) { clocker.tick(); laser_temp[channel] = kirdy.get_laser_temp(); + kirdy.set_tec_current(0.01); } }