42 lines
886 B
C++
42 lines
886 B
C++
#pragma once
|
|
|
|
#include "item.h"
|
|
|
|
class Train: public Item
|
|
{
|
|
private:
|
|
uint8_t _function = 0;
|
|
uint8_t _functionmask;
|
|
uint8_t _speed = 0;
|
|
uint8_t _quirks = 0;
|
|
bool _direction = false;
|
|
|
|
uint16_t packetAddSpeed();
|
|
uint16_t packetAddDirection();
|
|
uint16_t packetAddFunction(const uint8_t function);
|
|
uint16_t assembleSpeedPacket();
|
|
|
|
public:
|
|
|
|
Train(const uint8_t address, uint8_t functionmask = 0, uint8_t quirks = 0);
|
|
|
|
void sendData(bool single = false);
|
|
|
|
void reverse();
|
|
void stop();
|
|
|
|
bool isActive() {return getSpeed() || getFunctions();}
|
|
uint16_t getLastPacket();
|
|
|
|
void setSpeed(int8_t speed);
|
|
int8_t getSpeed();
|
|
|
|
void setFunctionMask(uint8_t functionmask) {_functionmask = functionmask;}
|
|
uint8_t getFunctions();
|
|
uint8_t getFunctionMask();
|
|
void sendFunction(const uint8_t function, bool enable = true);
|
|
|
|
uint8_t getQuirks();
|
|
void setQuirks(uint8_t quirks);
|
|
};
|