12 #ifdef ARDUINO_ARCH_AVR 14 #include "DCCpp_Uno.h" 15 #include "CurrentMonitor.h" 20 void CurrentMonitor::begin(
int pin,
const char *msg,
float inSampleMax)
25 this->currentSampleMax = inSampleMax;
28 boolean CurrentMonitor::checkTime()
30 if(millis( ) - sampleTime < CURRENT_SAMPLE_TIME)
32 sampleTime = millis();
36 void CurrentMonitor::check()
38 if (this->pin == UNDEFINED_PIN)
41 this->current = (float)(analogRead(this->pin) * CURRENT_SAMPLE_SMOOTHING + this->current * (1.0 - CURRENT_SAMPLE_SMOOTHING));
43 int signalPin = DCCppConfig::SignalEnablePinProg;
44 if (signalPin == UNDEFINED_PIN)
45 signalPin = DCCppConfig::SignalEnablePinMain;
48 if (this->current > this->currentSampleMax && digitalRead(signalPin) == HIGH)
51 DCCPP_INTERFACE.print(this->msg);
52 #if !defined(USE_ETHERNET) 53 DCCPP_INTERFACE.println(
"");
58 long int CurrentMonitor::sampleTime=0;
static void powerOff(bool inMain = true, bool inProg = true)