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;