X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fserial%2Fserial.cpp;h=e812a9931a5ea42f934c3df56e803328a045cf9c;hb=34f8bf04e4bdffefeceea59b186386b51c542b9d;hp=27667521e1eb07cba7d3ba81545d6f70c847a72f;hpb=2e3ad91af312aaf20b10f1cbe6096cda7e8a97d1;p=r2c2.git diff --git a/source/serial/serial.cpp b/source/serial/serial.cpp index 2766752..e812a99 100644 --- a/source/serial/serial.cpp +++ b/source/serial/serial.cpp @@ -1,6 +1,6 @@ /* $Id$ -This file is part of the MSP Märklin suite +This file is part of R²C² Copyright © 2010 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ @@ -12,7 +12,7 @@ Distributed under the GPL using namespace std; using namespace Msp; -using namespace Marklin; +using namespace R2C2; Application::RegApp Serial::reg; @@ -20,6 +20,7 @@ Serial::Serial(int, char **argv): client(catalogue), serial_port(argv[2]), train(0), + reverse(false), rx_fill(0) { DataFile::load(catalogue, "locos.dat"); @@ -97,7 +98,8 @@ void Serial::data_available() else if(c=='R') { IO::print("Reverse\n"); - train->set_reverse(!train->get_reverse()); + reverse = !reverse; + train->set_control("speed", 0); } else if(c=='N') next_train(); @@ -121,9 +123,10 @@ void Serial::data_available() } else if(rx_buf[0]=='S' && rx_fill==3) { - unsigned speed = (rx_buf[1]-'0')*10+(rx_buf[2]-'0'); - IO::print("Set speed %d\n", speed); - train->set_speed(speed); + // XXX The firmware is still coded for speed step based control + float speed = ((rx_buf[1]-'0')*10+(rx_buf[2]-'0'))*10/3.6*catalogue.get_scale(); + IO::print("Set speed %g\n", speed); + train->set_control("speed", speed); rx_fill = 0; } }