-/* $Id$
-
-This file is part of the MSP Märklin suite
-Copyright © 2010 Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
#include <msp/net/resolve.h>
#include "serial.h"
using namespace std;
using namespace Msp;
-using namespace Marklin;
+using namespace R2C2;
-Application::RegApp<Serial> 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");
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();
}
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;
}
}