mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
d7b2cf3d76
* LCN * Prevent deprecated compiler warning * Implement huge function numbers * new commands <! [cab]> forget locos. <9> ESTOP ALL. <D RESET> reboot arduino * Waveform accuracy msg * Drop post-write verify * UNUSED_PIN current measure and callback -2 for cv actions. * Correct diags * ESTOP a forget loco * ESTOP loco on forget * Avoid compiler warning * current sensor offset * Restore <1 JOIN> after prog track operation * <!> ESTOP <-> FORGET * Auto current offset detection * manage current offset and diagnostics * neater msg at startup * Add startup message to LCN master * DCC::setJoinRelayPin Co-authored-by: Asbelos <asbelos@btinternet.com>
60 lines
1.9 KiB
C++
60 lines
1.9 KiB
C++
/*
|
|
* © 2020, Chris Harlow. All rights reserved.
|
|
*
|
|
* This file is part of Asbelos DCC API
|
|
*
|
|
* This is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* It is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef Turnouts_h
|
|
#define Turnouts_h
|
|
|
|
#include <Arduino.h>
|
|
#include "DCC.h"
|
|
#include "LCN.h"
|
|
|
|
const byte STATUS_ACTIVE=0x80; // Flag as activated
|
|
const byte STATUS_PWM=0x40; // Flag as a PWM turnout
|
|
const byte STATUS_PWMPIN=0x3F; // PWM pin 0-63
|
|
const int LCN_TURNOUT_ADDRESS=-1; // spoof dcc address -1 indicates a LCN turnout
|
|
struct TurnoutData {
|
|
int id;
|
|
uint8_t tStatus; // has STATUS_ACTIVE, STATUS_PWM, STATUS_PWMPIN
|
|
union {uint8_t subAddress; char moveAngle;}; //DCC sub addrerss or PWM difference from inactiveAngle
|
|
union {int address; int inactiveAngle;}; // DCC address or PWM servo angle
|
|
};
|
|
|
|
class Turnout {
|
|
public:
|
|
static Turnout *firstTurnout;
|
|
static int turnoutlistHash;
|
|
TurnoutData data;
|
|
Turnout *nextTurnout;
|
|
static bool activate(int n, bool state);
|
|
static Turnout* get(int);
|
|
static bool remove(int);
|
|
static bool isActive(int);
|
|
static void load();
|
|
static void store();
|
|
static Turnout *create(int id , int address , int subAddress);
|
|
static Turnout *create(int id , byte pin , int activeAngle, int inactiveAngle);
|
|
static Turnout *create(int id);
|
|
void activate(bool state);
|
|
static void printAll(Print *);
|
|
#ifdef EESTOREDEBUG
|
|
void print(Turnout *tt);
|
|
#endif
|
|
}; // Turnout
|
|
|
|
#endif
|