X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fserial%2Fserial.cpp;h=50f53bd7aff9b77ef4c40c01685d1a946893ebc3;hb=f7ab597d035a053311c1a8c5baa51b090262f045;hp=27667521e1eb07cba7d3ba81545d6f70c847a72f;hpb=2e3ad91af312aaf20b10f1cbe6096cda7e8a97d1;p=r2c2.git diff --git a/source/serial/serial.cpp b/source/serial/serial.cpp index 2766752..50f53bd 100644 --- a/source/serial/serial.cpp +++ b/source/serial/serial.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of the MSP Märklin suite -Copyright © 2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include #include "serial.h" @@ -12,14 +5,13 @@ Distributed under the GPL using namespace std; using namespace Msp; -using namespace Marklin; +using namespace R2C2; -Application::RegApp Serial::reg; - 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 +89,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 +114,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; } }