-
Notifications
You must be signed in to change notification settings - Fork 0
/
dcc_rs.h
58 lines (44 loc) · 1.98 KB
/
dcc_rs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*******************************************************************************************************
File: dcc_rs.h
Author: Aiko Pras
History: 2022/06/13 AP Version 1.0
Purpose: Implements the safety decoder specific DCC message reception and the RS-Bus interface
Note that all DCC pins are defined and initialised in the AP_DCC_Decoder_Basic library
Each RS-Bus message contians four bits (a nibble).
The first nibble contains the current state, the second tells which button was pushed.
Note that bit numbering on the LH-100 handheld is 1 higher
nibble 2 nibble 1
+----------------+----------------+
| 7 6 5 4 | 3 2 1 0 |
+----------------+----------------+
button state
Meaning of the various bits:
0: state == LOCAL
1: state == REMOTE
2: state == L_PUSHED
3: state == R_RELAY_OFF
4: Button on PIN_PC4 / Connector 8.1
5: Button on PIN_PC5 / Connector 8.2
6: Button on PIN_PC6 / Connector 8.4
7: Emergency button pushed (PIN_PC7 / Connector 8.4)
******************************************************************************************************/
#pragma once
#include <Arduino.h> // For general definitions
#include <AP_DCC_Decoder_Core.h> // To include all objects, such as dcc, accCmd, etc.
class DccSystem {
public:
void update(); // Called at the end of the Main loop as frequent as possible
bool watchdogMsgReceived(); // We use boolean functions for these two flags, to avoid the
bool resetMsgReceived(); // need to clear the flags from the state machine
bool trainsMoveFlag; // This must remain a flag
private:
bool watchdogReceived;
bool resetReceived;
};
// The RsBus class is inherited from the RSbusConnection class
class RsBus: public RSbusConnection {
public:
uint8_t feedbackData = 0;
};
extern DccSystem dccSystem;
extern RsBus rsBus; // used by the main loop()