From 67bcaac63d27ddd3015e18c19563d619058ba16c Mon Sep 17 00:00:00 2001 From: Niels Wegner Date: Fri, 20 Jan 2017 23:39:52 +0100 Subject: [PATCH 1/4] replaced duplicate code by calling already existing method --- DCCpp_Uno/EEStore.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/DCCpp_Uno/EEStore.cpp b/DCCpp_Uno/EEStore.cpp index a58d431..efbb2ea 100644 --- a/DCCpp_Uno/EEStore.cpp +++ b/DCCpp_Uno/EEStore.cpp @@ -24,11 +24,7 @@ void EEStore::init(){ EEPROM.get(0,eeStore->data); // get eeStore data if(strncmp(eeStore->data.id,EESTORE_ID,sizeof(EESTORE_ID))!=0){ // check to see that eeStore contains valid DCC++ ID - sprintf(eeStore->data.id,EESTORE_ID); // if not, create blank eeStore structure (no turnouts, no sensors) and save it back to EEPROM - eeStore->data.nTurnouts=0; - eeStore->data.nSensors=0; - eeStore->data.nOutputs=0; - EEPROM.put(0,eeStore->data); + clear; } reset(); // set memory pointer to first free EEPROM space From 44ca90cd48da02d6fc78f6eb3d877dedcb573694 Mon Sep 17 00:00:00 2001 From: Niels Wegner Date: Fri, 20 Jan 2017 23:44:03 +0100 Subject: [PATCH 2/4] removed additional spaced after \ at lineend --- DCCpp_Uno/DCCpp_Uno.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DCCpp_Uno/DCCpp_Uno.ino b/DCCpp_Uno/DCCpp_Uno.ino index 9378374..176e094 100644 --- a/DCCpp_Uno/DCCpp_Uno.ino +++ b/DCCpp_Uno/DCCpp_Uno.ino @@ -424,13 +424,13 @@ void setup(){ #define DCC_SIGNAL(R,N) \ if(R.currentBit==R.currentReg->activePacket->nBits){ /* IF no more bits in this DCC Packet */ \ - R.currentBit=0; /* reset current bit pointer and determine which Register and Packet to process next--- */ \ + R.currentBit=0; /* reset current bit pointer and determine which Register and Packet to process next--- */ \ if(R.nRepeat>0 && R.currentReg==R.reg){ /* IF current Register is first Register AND should be repeated */ \ R.nRepeat--; /* decrement repeat count; result is this same Packet will be repeated */ \ } else if(R.nextReg!=NULL){ /* ELSE IF another Register has been updated */ \ R.currentReg=R.nextReg; /* update currentReg to nextReg */ \ R.nextReg=NULL; /* reset nextReg to NULL */ \ - R.tempPacket=R.currentReg->activePacket; /* flip active and update Packets */ \ + R.tempPacket=R.currentReg->activePacket; /* flip active and update Packets */ \ R.currentReg->activePacket=R.currentReg->updatePacket; \ R.currentReg->updatePacket=R.tempPacket; \ } else{ /* ELSE simply move to next Register */ \ @@ -446,8 +446,8 @@ void setup(){ } else{ /* ELSE it is a ZERO */ \ OCR ## N ## A=DCC_ZERO_BIT_TOTAL_DURATION_TIMER ## N; /* set OCRA for timer N to full cycle duration of DCC ZERO bit */ \ OCR ## N ## B=DCC_ZERO_BIT_PULSE_DURATION_TIMER ## N; /* set OCRB for timer N to half cycle duration of DCC ZERO bit */ \ - } /* END-ELSE */ \ - \ + } /* END-ELSE */ \ + \ R.currentBit++; /* point to next bit in current Packet */ /////////////////////////////////////////////////////////////////////////////// From 019a286710938529cd1d47aa02c99b7b95746cc3 Mon Sep 17 00:00:00 2001 From: Niels Wegner Date: Fri, 20 Jan 2017 23:58:59 +0100 Subject: [PATCH 3/4] fixed compiler warning string constant to 'char*' by adding const --- DCCpp_Uno/CurrentMonitor.cpp | 2 +- DCCpp_Uno/CurrentMonitor.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DCCpp_Uno/CurrentMonitor.cpp b/DCCpp_Uno/CurrentMonitor.cpp index 5149d2a..0d75122 100644 --- a/DCCpp_Uno/CurrentMonitor.cpp +++ b/DCCpp_Uno/CurrentMonitor.cpp @@ -13,7 +13,7 @@ Part of DCC++ BASE STATION for the Arduino /////////////////////////////////////////////////////////////////////////////// -CurrentMonitor::CurrentMonitor(int pin, char *msg){ +CurrentMonitor::CurrentMonitor(int pin, const char *msg){ this->pin=pin; this->msg=msg; current=0; diff --git a/DCCpp_Uno/CurrentMonitor.h b/DCCpp_Uno/CurrentMonitor.h index f4c301a..eed6102 100644 --- a/DCCpp_Uno/CurrentMonitor.h +++ b/DCCpp_Uno/CurrentMonitor.h @@ -25,8 +25,8 @@ struct CurrentMonitor{ static long int sampleTime; int pin; float current; - char *msg; - CurrentMonitor(int, char *); + const char *msg; + CurrentMonitor(int, const char*); static boolean checkTime(); void check(); }; From dc4ba20472b5cbc0decdae6f21453d0ece5f1db1 Mon Sep 17 00:00:00 2001 From: Niels Wegner Date: Mon, 23 Jan 2017 22:57:49 +0100 Subject: [PATCH 4/4] fixed comment spacing --- DCCpp_Uno/CurrentMonitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DCCpp_Uno/CurrentMonitor.cpp b/DCCpp_Uno/CurrentMonitor.cpp index 0d75122..150099c 100644 --- a/DCCpp_Uno/CurrentMonitor.cpp +++ b/DCCpp_Uno/CurrentMonitor.cpp @@ -31,7 +31,7 @@ void CurrentMonitor::check(){ if(current>CURRENT_SAMPLE_MAX && digitalRead(SIGNAL_ENABLE_PIN_PROG)==HIGH){ // current overload and Prog Signal is on (or could have checked Main Signal, since both are always on or off together) digitalWrite(SIGNAL_ENABLE_PIN_PROG,LOW); // disable both Motor Shield Channels digitalWrite(SIGNAL_ENABLE_PIN_MAIN,LOW); // regardless of which caused current overload - INTERFACE.print(msg); // print corresponding error message + INTERFACE.print(msg); // print corresponding error message } } // CurrentMonitor::check