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 "FreeMemory.h"
#if defined(ARDUINO_ARCH_AVR)
int ramLowWatermark = 32767;
#else
int ramLowWatermark = 256000;
#endif
const uint8_t kIRQmicros = 29;
const uint8_t kNumLocos = 50;
@ -83,14 +87,17 @@ void setup() {
CommManager::registerInterface(new USBInterface(SerialUSB));
while(!SerialUSB) {} // Wait for USB to come online (remove once wifi is implemented)
Wire.begin(); // Needed for EEPROM to work
EEStore::init(&SerialUSB);
#elif defined (ARDUINO_ARCH_SAMC)
CommManager::registerInterface(new SerialInterface(Serial));
Wire.begin(); // Needed for EEPROM to work
EEStore::init(&Serial);
#elif defined(ARDUINO_ARCH_AVR)
CommManager::registerInterface(new SerialInterface(Serial));
EEStore::init(&Serial);
#endif
EEStore::init();
// Set up the string parser to accept commands from the interfaces
DCCEXParser::init(mainTrack, progTrack);
@ -106,6 +113,6 @@ void loop() {
int freeNow=freeMemory();
if (freeNow<ramLowWatermark) {
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/>.
*/
#ifndef COMMANDSTATION_DCC_CONFIG
#define COMMANDSTATION_DCC_CONFIG
#ifndef COMMANDSTATION_DCC_CONFIG_H_
#define COMMANDSTATION_DCC_CONFIG_H_
// 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_ARDUINO_MOTOR_SHIELD
#define CONFIG_ARDUINO_MOTOR_SHIELD
//#define CONFIG_POLOLU_MOTOR_SHIELD
#endif
#endif // COMMANDSTATION_DCC_CONFIG_H_

View File

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