21 lines
554 B
C++
21 lines
554 B
C++
#include "Dcc.h"
|
|
#include <Arduino.h>
|
|
|
|
void Dcc::begin(int dirPin, int pwmPin) {
|
|
DCCpp::begin();
|
|
DCCpp::beginMain(UNDEFINED_PIN, dirPin, pwmPin, UNDEFINED_PIN);
|
|
DCCpp::powerOn(true, false);
|
|
}
|
|
|
|
void Dcc::sendAccessory(uint16_t linearAddress, bool activate) {
|
|
if (linearAddress == 0) {
|
|
Serial.println("Adresse DCC invalide");
|
|
return;
|
|
}
|
|
|
|
int boardAddress = ((linearAddress - 1) / 4) + 1;
|
|
int subAddress = (linearAddress - 1) % 4;
|
|
byte activateByte = activate ? 1 : 0;
|
|
DCCpp::setAccessory(boardAddress, subAddress, activateByte);
|
|
}
|