Skip to content

Commit c561f58

Browse files
committed
Changed WIRE address range from [1-120] to [0-119]
* DCC++ MASTER = WIRE Address 0 * DCC++ BOOSTER = WIRE Address 1-119
1 parent aa50f6e commit c561f58

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

DCCpp/DCCpp.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ DCC++ BASE STATION is configured through the Config.h file that contains all use
177177
#include "EEStore.h"
178178
#include "Config.h"
179179
#include "Comm.h"
180+
#include "DccServer.h"
180181

181182
void showConfiguration();
182183

@@ -246,6 +247,11 @@ void setup(){
246247
Serial.print(__TIME__);
247248
Serial.print(">");
248249

250+
Serial.print("<J");
251+
Serial.print(DccServer::serverID);
252+
Serial.print(">");
253+
DccServer::setServer(DccServer::serverID);
254+
249255
#if COMM_TYPE == 1
250256
#ifdef IP_ADDRESS
251257
Ethernet.begin(mac,IP_ADDRESS); // Start networking using STATIC IP Address

DCCpp/DccServer.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ COPYRIGHT (c) 2013-2016 Gregg E. Berman
55
66
Part of DCC++ BASE STATION for the Arduino
77
8+
**********************************************************************/
9+
/**********************************************************************
10+
11+
DCC++ BASE STATION supports the use of multiple Arduinos communicating
12+
via the Arduino's built-in TWI/I2C Interface, utilizing Arduino's WIRE library.
13+
Each Arduino requiures a unique WIRE address from 0 through 119. This address
14+
is set interactively with the <J ID> command, and saved to EEPROM when
15+
the <E> command is issued.
16+
17+
When multiple Arduinos are used, one acts as the DCC++ MASTER and all others
18+
are DCC++ BOOSTERS.
19+
20+
* The DCC++ MASTER must have a WIRE address of 0.
21+
* DCC++ BOOSTERS must have a unique WIRE address from 1 through 119
22+
823
**********************************************************************/
924

1025
#include "DCCpp.h"
@@ -28,8 +43,8 @@ void DccServer::parse(char *c){
2843

2944
switch(sscanf(c,"%d",&n)){
3045

31-
case 1: // argument is serverID (1-120)
32-
if(n>=1 && n<=120){
46+
case 1: // argument is serverID (0=DCC++ MASTER, 1-119=DCC++ BOOSTER)
47+
if(n>=0 && n<=119){
3348
INTERFACE.print("<O>");
3449
setServer(n);
3550
} else {
@@ -64,15 +79,15 @@ void DccServer::setServer(int id){
6479

6580
Wire.end();
6681
Wire.onReceive(receiveWire);
67-
Wire.begin(serverID+7); // set as SERVER with ID+7 (yielding address between 8 and 127
82+
Wire.begin(serverID+8); // set as WIRE SERVER with ID+8 (yielding address between 8 and 127)
6883
}
6984

7085
///////////////////////////////////////////////////////////////////////////////
7186

7287
void DccServer::setMaster(){
7388

7489
Wire.end();
75-
Wire.begin(); // set as MASTER
90+
Wire.begin(); // set as WIRE MASTER
7691
}
7792

7893
///////////////////////////////////////////////////////////////////////////////

DCCpp/EEStore.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void EEStore::init(){
2929
eeStore->data.nTurnouts=0;
3030
eeStore->data.nSensors=0;
3131
eeStore->data.nOutputs=0;
32-
eeStore->data.serverID=1;
32+
eeStore->data.serverID=0;
3333
EEPROM.put(0,eeStore->data);
3434
}
3535

@@ -48,7 +48,7 @@ void EEStore::clear(){
4848
eeStore->data.nTurnouts=0;
4949
eeStore->data.nSensors=0;
5050
eeStore->data.nOutputs=0;
51-
eeStore->data.serverID=1;
51+
eeStore->data.serverID=0;
5252
EEPROM.put(0,eeStore->data);
5353

5454
}

DCCpp/SerialCommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void SerialCommand::parse(char *com){
232232
*
233233
* returns: <J ID>
234234
*
235-
* ID: the WIRE address for this board (1-120)
235+
* ID: the WIRE address for this board (0=DCC++ MASTER, 1-119=DCC++ BOOSTER)
236236
*
237237
*/
238238

0 commit comments

Comments
 (0)