]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/intellibox.h
Make LCD output selectable at runtime through an extra I/O pin
[r2c2.git] / source / libmarklin / intellibox.h
index 565d3cbd1e23f9bb249f9a9289c389282a31f443..6d061a6076bb6a07b04cc843c257a1df95680ada 100644 (file)
@@ -14,6 +14,16 @@ Distributed under the GPL
 
 namespace Marklin {
 
+/**
+Driver for Uhlenbrock Intellibox.  Uses the P50X binary protocol over RS232.
+
+Motorola decoders with 27 speed steps are supported by manually generating the
+commands necessary to reach the "half-steps".  However, sending a rapid stream
+of speed changes to the same locomotive seems to cause excessive lag, so we
+cheat a bit; instead of sending the half-step command immediately, we send it
+with a 500ms delay, but only if no new set_loco_speed calls have occurred.  As
+a downside from this accelerations and decelerations are still jerky.
+*/
 class Intellibox: public Driver
 {
 private:
@@ -61,12 +71,20 @@ private:
                ERR_LOK_POWER_OFF,
        };
 
+       enum Protocol
+       {
+               MM,
+               MM_27
+       };
+
        struct Locomotive
        {
-               std::string protocol;
+               Protocol protocol;
                unsigned speed;
                bool reverse;
                unsigned funcs;
+               int pending_half_step;
+               Msp::Time::TimeStamp half_step_delay;
 
                Locomotive();
        };
@@ -135,6 +153,7 @@ public:
        virtual void flush();
 
 private:
+       Protocol map_protocol(const std::string &) const;
        void command(Command);
        void command(Command, const unsigned char *, unsigned);
        void command(Command, unsigned, const unsigned char *, unsigned);