From 72f932e5d9b3d101c6b8a5044ef855910a9cb65f Mon Sep 17 00:00:00 2001 From: Ryba04 <71170857+Ryba04@users.noreply.github.com> Date: Sun, 16 Aug 2026 21:34:22 +0200 Subject: [PATCH] Add independent dynamic brake support (eg. Vectron) to UART controllers --- utilities/Globals.h | 3 ++- utilities/uart.cpp | 13 +++++++++++++ utilities/uart.h | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/utilities/Globals.h b/utilities/Globals.h index 729b7cbc..fc6b5a7f 100644 --- a/utilities/Globals.h +++ b/utilities/Globals.h @@ -224,7 +224,8 @@ struct global_settings { {"train", &uart_conf.trainenable}, {"local", &uart_conf.localenable}, {"radiovolume", &uart_conf.radiovolumeenable}, - {"radiochannel", &uart_conf.radiochannelenable} + {"radiochannel", &uart_conf.radiochannelenable}, + {"dynamicbrake", &uart_conf.dynamicenable}, }; #endif #ifdef WITH_ZMQ diff --git a/utilities/uart.cpp b/utilities/uart.cpp index caa644aa..cac7a198 100644 --- a/utilities/uart.cpp +++ b/utilities/uart.cpp @@ -506,6 +506,19 @@ void uart_input::poll() 0 ); } + if (true == conf.dynamicenable) + { + // dynamic brake 8 bit + double const position{(float)(buffer[13] - conf.dynamicbrakemin) / (conf.dynamicbrakemax - conf.dynamicbrakemin)}; + + relay.post( + user_command::dynamicbrakecontrollerset, + position, + 0, + GLFW_PRESS, + 0 + ); + } old_packet = buffer; } diff --git a/utilities/uart.h b/utilities/uart.h index a418dc22..1a0f344b 100644 --- a/utilities/uart.h +++ b/utilities/uart.h @@ -53,6 +53,8 @@ public: float lvmax = 150.0f; float lvuart = 65535.0f; float tachoscale = 1.0f; + float dynamicbrakemin = 0.0f; + float dynamicbrakemax = 255.0f; bool mainenable = true; bool scndenable = true; @@ -60,6 +62,7 @@ public: bool localenable = true; bool radiovolumeenable = false; bool radiochannelenable = false; + bool dynamicenable = false; bool debug = false;