X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Flocomotive.cpp;h=5fe5ca5f863d07ca489cdea2bae773eb46ba9d8e;hb=02c9a9779954d993cb73fe5f7a72b0847e87f633;hp=c7d6227cddb938e5d3acfbbb6cc2c8f564ca771f;hpb=38fb8d56efde037a71c46a58bda314655e68ab6c;p=r2c2.git diff --git a/source/libmarklin/locomotive.cpp b/source/libmarklin/locomotive.cpp index c7d6227..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; @@ -56,6 +59,7 @@ void Locomotive::set_reverse(bool rev) { reverse = rev; send_command(false); + signal_reverse_changed.emit(reverse); } } @@ -102,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<