From 54ef92085b892466a4f118699748f62d14a6aa3c Mon Sep 17 00:00:00 2001 From: Asbelos Date: Wed, 27 May 2020 09:40:12 +0100 Subject: [PATCH] Include file ckleaning --- Config.h | 10 ++++++++++ DCC.cpp | 1 + DCC.h | 6 +++++- DCCWaveform.h | 4 +++- DIAG.h | 4 ++++ Hardware.h | 4 +++- JMRIParser.h | 4 +++- JMRITurnout.cpp | 2 +- JMRITurnout.h | 6 +++++- Railcom.h | 5 +++++ StringParser.h | 3 +++ 11 files changed, 43 insertions(+), 6 deletions(-) diff --git a/Config.h b/Config.h index 7426ef3..bfa4225 100644 --- a/Config.h +++ b/Config.h @@ -1,3 +1,6 @@ +#ifndef Config_h +#define Config_h + // This hardware configuration would normally be setup using a bunch of #ifdefs. const byte MAIN_POWER_PIN = 3; @@ -14,3 +17,10 @@ const byte PROG_SENSE_PIN = A1; const byte PROG_BRAKE_PIN = 10; const float PROG_SENSE_FACTOR=1; // analgRead(PROG_SENSE_PIN) * PROG_SENSE_FACTOR = milliamps + +// Allocations with memory implications.. however tiny! +// Base system takes approx 500 bytes + 4 per loco and 3 per turnout. +const byte MAX_LOCOS=50; +const byte MAX_TURNOUTS=50; + +#endif diff --git a/DCC.cpp b/DCC.cpp index 96fa0cb..cd8f635 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -1,6 +1,7 @@ #include "DCC.h" #include "DCCWaveform.h" #include "DIAG.h" + // This module is responsible for converting API calls into // messages to be sent to the waveform generator. // It has no visibility of the hardware, timers, interrupts diff --git a/DCC.h b/DCC.h index 3858eca..8022454 100644 --- a/DCC.h +++ b/DCC.h @@ -1,5 +1,8 @@ +#ifndef DCC_h +#define DCC_h #include -const byte MAX_LOCOS=50; +#include "Config.h" + class DCC { public: @@ -34,3 +37,4 @@ private: static byte cv2(int cv); }; +#endif diff --git a/DCCWaveform.h b/DCCWaveform.h index 6a83741..9cfca89 100644 --- a/DCCWaveform.h +++ b/DCCWaveform.h @@ -1,4 +1,5 @@ - +#ifndef DCCWaveform_h +#define DCCWaveform_h const int POWER_SAMPLE_MAX = 300; @@ -77,3 +78,4 @@ class DCCWaveform { POWERMODE powerMode; unsigned long nextSampleDue; }; +#endif diff --git a/DIAG.h b/DIAG.h index 76526a5..8a75b62 100644 --- a/DIAG.h +++ b/DIAG.h @@ -1,5 +1,9 @@ +#ifndef DIAG_h +#define DIAG_h + #include "StringParser.h" #ifndef DIAG_ENABLED #define DIAG_ENABLED true #endif #define DIAG if (DIAG_ENABLED) StringParser::print +#endif diff --git a/Hardware.h b/Hardware.h index 8709f4e..7b68466 100644 --- a/Hardware.h +++ b/Hardware.h @@ -1,4 +1,5 @@ - +#ifndef Hardware_h +#define Hardware_h // Virtualised hardware Interface class Hardware { public: @@ -11,3 +12,4 @@ class Hardware { static void setSingleCallback(int duration, void (*isr)()); static void resetSingleCallback(int duration); }; +#endif diff --git a/JMRIParser.h b/JMRIParser.h index b1b7dc0..6660d4c 100644 --- a/JMRIParser.h +++ b/JMRIParser.h @@ -1,4 +1,5 @@ - +#ifndef JMRIParser_h +#define JMRIParser_h struct JMRIParser { static void parse(Stream & stream,const char * command); @@ -7,3 +8,4 @@ struct JMRIParser static const int MAX_PARAMS=10; static int p[MAX_PARAMS]; }; +#endif diff --git a/JMRITurnout.cpp b/JMRITurnout.cpp index 5c6514b..f4d6cad 100644 --- a/JMRITurnout.cpp +++ b/JMRITurnout.cpp @@ -91,7 +91,7 @@ void JMRITurnout::parse(Stream & stream, int params, int p[]) { } ///////////////// ALL PRIVATE BELOW HERE ////////////////// - JMRITurnout::TurnoutEntry JMRITurnout::table[JMRITurnout::MAX_TURNOUTS]; + JMRITurnout::TurnoutEntry JMRITurnout::table[MAX_TURNOUTS]; bool JMRITurnout::create(int id, int add, byte subAdd){ if (id<0 || id>=MAX_TURNOUTS || table[id].address!=0) return false; diff --git a/JMRITurnout.h b/JMRITurnout.h index a14ab3a..75847c0 100644 --- a/JMRITurnout.h +++ b/JMRITurnout.h @@ -1,4 +1,8 @@ +#ifndef JMRITurnout_h +#define TMRITurnout_h + #include +#include "Config.h" class JMRITurnout { @@ -21,6 +25,6 @@ class JMRITurnout { byte subAddress; bool thrown; }; - static const int MAX_TURNOUTS=50; static TurnoutEntry table[MAX_TURNOUTS]; }; +#endif diff --git a/Railcom.h b/Railcom.h index aa85c6b..08dafd0 100644 --- a/Railcom.h +++ b/Railcom.h @@ -1,3 +1,6 @@ +#ifndef Railcom_h +#define Railcom_h + #include class Railcom { public: @@ -9,3 +12,5 @@ class Railcom { static const byte MAX_BUFFER=20; static byte buffer[MAX_BUFFER]; }; + +#endif diff --git a/StringParser.h b/StringParser.h index e1ec581..1d11bca 100644 --- a/StringParser.h +++ b/StringParser.h @@ -1,3 +1,5 @@ +#ifndef StringParser_h +#define StringParser_h #include class StringParser { @@ -14,3 +16,4 @@ class StringParser static const byte MAX_BUFFER=100; static char buffer[MAX_BUFFER]; }; +#endif