X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Flocomotive.cpp;h=5fe5ca5f863d07ca489cdea2bae773eb46ba9d8e;hb=bc8ac89bbe774bb133b758416182aa18e5e0a5a5;hp=3088d4655ba3d100b2c64d2c704782e4e3c04e57;hpb=f9254f57b736927a57a2fd793ee18f6c9766dd43;p=r2c2.git diff --git a/source/libmarklin/locomotive.cpp b/source/libmarklin/locomotive.cpp index 3088d46..5fe5ca5 100644 --- a/source/libmarklin/locomotive.cpp +++ b/source/libmarklin/locomotive.cpp @@ -11,6 +11,7 @@ Distributed under the GPL #include "constants.h" #include "control.h" #include "locomotive.h" +#include "locotype.h" #include "reply.h" using namespace std; @@ -34,6 +35,8 @@ Locomotive::Locomotive(const LocoType &t, Control &c, unsigned a): void Locomotive::set_speed(unsigned spd) { spd = min(spd, 14U); + if(spd==speed) + return; signal_speed_changing.emit(spd); speed = spd; @@ -103,6 +106,18 @@ void Locomotive::send_command(bool setf) data[3] |= (1<4) + { + if(!++data[0]) + ++data[1]; + data[2] = 0; + data[3] = 0xA0; + for(unsigned i=0; i<4; ++i) + if((funcs>>i)&32) + data[3] |= (1<