diff --git a/Globals.cpp b/Globals.cpp index 87fd7eaf..f7815e83 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -686,6 +686,10 @@ global_settings::ConfigParse(cParser &Parser) { >> uart_conf.currentmax >> uart_conf.currentuart; } + else if ( token == "uarttachoscale" ) { + Parser.getTokens( 1 ); + Parser >> uart_conf.tachoscale; + } else if( token == "uartfeature" ) { Parser.getTokens( 4 ); Parser diff --git a/uart.cpp b/uart.cpp index a654cb61..81116ccb 100644 --- a/uart.cpp +++ b/uart.cpp @@ -234,7 +234,7 @@ void uart_input::poll() // TODO: ugly! move it into structure like input_bits auto const trainstate = t->get_state(); - uint8_t tacho = Global.iPause ? 0 : trainstate.velocity; + uint16_t tacho = Global.iPause ? 0 : (trainstate.velocity * conf.tachoscale); uint16_t tank_press = (uint16_t)std::min(conf.tankuart, trainstate.reservoir_pressure * 0.1f / conf.tankmax * conf.tankuart); uint16_t pipe_press = (uint16_t)std::min(conf.pipeuart, trainstate.pipe_pressure * 0.1f / conf.pipemax * conf.pipeuart); uint16_t brake_press = (uint16_t)std::min(conf.brakeuart, trainstate.brake_pressure * 0.1f / conf.brakemax * conf.brakeuart); @@ -244,10 +244,8 @@ void uart_input::poll() uint16_t current3 = (uint16_t)std::min(conf.currentuart, trainstate.hv_current[2] / conf.currentmax * conf.currentuart); std::array buffer { - //byte 0 - tacho, - //byte 1 - 0, + //byte 0-1 + SPLIT_INT16(tacho), //byte 2 (uint8_t)( trainstate.ventilator_overload << 1 diff --git a/uart.h b/uart.h index b6e1dd6b..2519d0b8 100644 --- a/uart.h +++ b/uart.h @@ -27,6 +27,7 @@ public: float hvuart = 65535.0f; float currentmax = 10000.0f; float currentuart = 65535.0f; + float tachoscale = 1.0f; bool mainenable = true; bool scndenable = true;