/********************************************************************** CurrentMonitor.cpp COPYRIGHT (c) 2013-2016 Gregg E. Berman Part of DCC++ BASE STATION for the Arduino **********************************************************************/ #include "DCCpp_Uno.h" #include "CurrentMonitor.h" #include "Comm.h" /////////////////////////////////////////////////////////////////////////////// CurrentMonitor::CurrentMonitor(int pin, char *msg){ this->pin=pin; this->msg=msg; current=0; } // CurrentMonitor::CurrentMonitor boolean CurrentMonitor::checkTime(){ if(millis()-sampleTimeCURRENT_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 } } // CurrentMonitor::check long int CurrentMonitor::sampleTime=0;