64 lines
1.2 KiB
C++
64 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "writepin.h"
|
|
#include <util/delay.h>
|
|
#include <stdint.h>
|
|
#include <avr/io.h>
|
|
|
|
class Train
|
|
{
|
|
public:
|
|
static const uint8_t M_DELTA = 0;
|
|
static const uint8_t M_DIGITAL = 1;
|
|
|
|
static const uint8_t HIGH = 2;
|
|
static const uint8_t LOW = 1;
|
|
static const uint8_t OFF = 0;
|
|
|
|
private:
|
|
uint8_t _address;
|
|
|
|
static const unsigned char _pinHighA = PD5;
|
|
static const unsigned char _pinLowA = PD4;
|
|
static const unsigned char _pinHighB = PD2;
|
|
static const unsigned char _pinLowB = PD3;
|
|
|
|
static const uint8_t SEND_COUNT = 4;
|
|
|
|
uint8_t _protocol = M_DIGITAL;
|
|
|
|
uint16_t lastdatapacket = 0;
|
|
|
|
inline static void off();
|
|
void sendBit(const bool bit);
|
|
void sendAddress();
|
|
|
|
public:
|
|
|
|
static void setOutput(const uint8_t state);
|
|
|
|
Train(const uint8_t address);
|
|
Train();
|
|
|
|
void resendSpeed();
|
|
|
|
void reverse();
|
|
|
|
uint8_t getAddress();
|
|
|
|
uint8_t getSpeed();
|
|
|
|
uint8_t getProtocol();
|
|
|
|
void setSpeed(uint8_t speed);
|
|
|
|
void setProtocol(const uint8_t protocol);
|
|
|
|
void setAddress(const uint8_t address);
|
|
|
|
void sendFunction(const uint16_t function);
|
|
|
|
void sendRaw(const uint16_t data);
|
|
|
|
};
|