void Controller25::device_loop(Command command){ if (time.elapsed (100)) { // subtract the last reading: total= total - readings[index]; // read from the sensor: readings[index] = readBrdCurrent(A0); // add the reading to the total: total= total + readings[index]; // advance to the next position in the array: index = index + 1; // if we're at the end of the array... if (index >= numReadings) // ...wrap around to the beginning: index = 0; // calculate the average: average = total / numReadings; } if (onesecondtimer.elapsed (1000)){ readTemp(); Serial.print(F("BRDT:")); Serial.print(celsiusTempRead); Serial.print(';'); Serial.print(F("SC1I:")); Serial.print(readCurrent(A3)); Serial.print(';'); Serial.print(F("SC2I:")); Serial.print(readCurrent(A2)); Serial.print(';'); Serial.print(F("SC3I:")); Serial.print(readCurrent(A1)); Serial.print(';'); Serial.print(F("BRDI:")); Serial.print(readBrdCurrent(A0)); Serial.print(';'); Serial.print(F("BT1I:")); Serial.print(readCurrent(A6)); Serial.print(';'); Serial.print(F("BT2I:")); Serial.print(readCurrent(A5)); Serial.print(';'); Serial.print(F("BRDV:")); Serial.print(read20Volts(A4)); Serial.print(';'); Serial.print(F("AVCC:")); Serial.print(readVcc()); Serial.println(';'); } // send voltage and current if (statustime2.elapsed(100)) { capedata::VOUT = read20Volts(A4); capedata::IOUT = readBrdCurrent(A0); capedata::FMEM = freeMemory(); // capedata::ATMP = GetTemp(); capedata::UTIM = millis(); } }
void CControllerBoard::Update( CCommand& commandIn ) { if( time.HasElapsed( 100 ) ) { // subtract the last reading: total = total - readings[index]; // read from the sensor: readings[index] = readBrdCurrent( A0 ); // add the reading to the total: total = total + readings[index]; // advance to the next position in the array: index = index + 1; // if we're at the end of the array... if( index >= numReadings ) // ...wrap around to the beginning: { index = 0; } // calculate the average: average = total / numReadings; } if( onesecondtimer.HasElapsed( 1000 ) ) { readTemp(); Serial.print( F( "BRDT:" ) ); Serial.print( celsiusTempRead ); Serial.print( ';' ); Serial.print( F( "SC1I:" ) ); Serial.print( readCurrent( A3 ) ); Serial.print( ';' ); Serial.print( F( "SC2I:" ) ); Serial.print( readCurrent( A2 ) ); Serial.print( ';' ); Serial.print( F( "SC3I:" ) ); Serial.print( readCurrent( A1 ) ); Serial.print( ';' ); Serial.print( F( "BRDI:" ) ); Serial.print( readBrdCurrent( A0 ) ); Serial.print( ';' ); Serial.print( F( "BT1I:" ) ); Serial.print( readCurrent( A6 ) ); Serial.print( ';' ); Serial.print( F( "BT2I:" ) ); Serial.print( readCurrent( A5 ) ); Serial.print( ';' ); Serial.print( F( "BRDV:" ) ); Serial.print( read20Volts( A4 ) ); Serial.print( ';' ); Serial.print( F( "AVCC:" ) ); Serial.print( readVcc() ); Serial.println( ';' ); } // Update Cape Data voltages and currents if( statustime2.HasElapsed( 100 ) ) { NDataManager::m_capeData.VOUT = read20Volts( A4 ); // #315: deprecated: this is the same thing as BRDI: NDataManager::m_capeData.IOUT = readBrdCurrent( A0 ); // Total current draw from batteries: NDataManager::m_capeData.BTTI = readCurrent( A5 ) + readCurrent( A6 ); NDataManager::m_capeData.FMEM = util::FreeMemory(); NDataManager::m_capeData.UTIM = millis(); } }