1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-26 17:46:14 +01:00

Move to new commmanager scheme

This commit is contained in:
David Cutting 2020-07-30 18:27:04 -06:00
parent 3b29bc002c
commit 170c9ab1ea
3 changed files with 17 additions and 10 deletions

View File

@ -24,7 +24,11 @@
#include "Config.h" #include "Config.h"
#include "FreeMemory.h" #include "FreeMemory.h"
#if defined(ARDUINO_ARCH_AVR)
int ramLowWatermark = 32767;
#else
int ramLowWatermark = 256000; int ramLowWatermark = 256000;
#endif
const uint8_t kIRQmicros = 29; const uint8_t kIRQmicros = 29;
const uint8_t kNumLocos = 50; const uint8_t kNumLocos = 50;
@ -83,14 +87,17 @@ void setup() {
CommManager::registerInterface(new USBInterface(SerialUSB)); CommManager::registerInterface(new USBInterface(SerialUSB));
while(!SerialUSB) {} // Wait for USB to come online (remove once wifi is implemented) while(!SerialUSB) {} // Wait for USB to come online (remove once wifi is implemented)
Wire.begin(); // Needed for EEPROM to work Wire.begin(); // Needed for EEPROM to work
EEStore::init(&SerialUSB);
#elif defined (ARDUINO_ARCH_SAMC) #elif defined (ARDUINO_ARCH_SAMC)
CommManager::registerInterface(new SerialInterface(Serial)); CommManager::registerInterface(new SerialInterface(Serial));
Wire.begin(); // Needed for EEPROM to work Wire.begin(); // Needed for EEPROM to work
EEStore::init(&Serial);
#elif defined(ARDUINO_ARCH_AVR) #elif defined(ARDUINO_ARCH_AVR)
CommManager::registerInterface(new SerialInterface(Serial)); CommManager::registerInterface(new SerialInterface(Serial));
EEStore::init(&Serial);
#endif #endif
EEStore::init();
// Set up the string parser to accept commands from the interfaces // Set up the string parser to accept commands from the interfaces
DCCEXParser::init(mainTrack, progTrack); DCCEXParser::init(mainTrack, progTrack);
@ -106,6 +113,6 @@ void loop() {
int freeNow=freeMemory(); int freeNow=freeMemory();
if (freeNow<ramLowWatermark) { if (freeNow<ramLowWatermark) {
ramLowWatermark=freeNow; ramLowWatermark=freeNow;
CommManager::printf(F("\nFree RAM=%d\n"),ramLowWatermark); CommManager::broadcast(F("\nFree RAM=%d\n"),ramLowWatermark);
} }
} }

View File

@ -17,14 +17,14 @@
* along with CommandStation-DCC. If not, see <https://www.gnu.org/licenses/>. * along with CommandStation-DCC. If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifndef COMMANDSTATION_DCC_CONFIG #ifndef COMMANDSTATION_DCC_CONFIG_H_
#define COMMANDSTATION_DCC_CONFIG #define COMMANDSTATION_DCC_CONFIG_H_
// Choose the motor shield that you want to use. // Choose the motor shield that you want to use.
#define CONFIG_WSM_FIREBOX_MK1 //#define CONFIG_WSM_FIREBOX_MK1
//#define CONFIG_WSM_FIREBOX_MK1S //#define CONFIG_WSM_FIREBOX_MK1S
//#define CONFIG_ARDUINO_MOTOR_SHIELD #define CONFIG_ARDUINO_MOTOR_SHIELD
//#define CONFIG_POLOLU_MOTOR_SHIELD //#define CONFIG_POLOLU_MOTOR_SHIELD
#endif #endif // COMMANDSTATION_DCC_CONFIG_H_

View File

@ -1,5 +1,5 @@
#ifndef freeMemory_h #ifndef COMMANDSTATION_DCC_FREEMEMORY_H_
#define freeMemory_h #define COMMANDSTATION_DCC_FREEMEMORY_H_
// thanks go to https://github.com/mpflaga/Arduino-MemoryFree // thanks go to https://github.com/mpflaga/Arduino-MemoryFree
#ifdef __arm__ #ifdef __arm__
@ -17,4 +17,4 @@ int freeMemory() {
return __brkval ? &top - __brkval : &top - __malloc_heap_start; return __brkval ? &top - __brkval : &top - __malloc_heap_start;
#endif // __arm__ #endif // __arm__
} }
#endif #endif // COMMANDSTATION_DCC_FREEMEMORY_H_