function to get data from sensor and queue results for transfer to ST Cloud
| 142 | |
| 143 | //function to get data from sensor and queue results for transfer to ST Cloud |
| 144 | void PS_PulseCounter::getData() |
| 145 | { |
| 146 | if (m_pCounter) |
| 147 | { |
| 148 | noInterrupts(); |
| 149 | unsigned long tmpCounts = *m_pCounter; |
| 150 | *m_pCounter = 0; |
| 151 | interrupts(); |
| 152 | |
| 153 | m_nSensorValue = long(m_fCnvSlope * tmpCounts + m_fCnvOffset); |
| 154 | |
| 155 | } |
| 156 | else //invalid Pin/Interrupt was requested, therefore we are in an error condition |
| 157 | { |
| 158 | m_nSensorValue = 0; |
| 159 | if (st::PollingSensor::debug) { |
| 160 | Serial.println(F("PS_PulseCounter::Invalid Pin Requested! Must be 21, 20, 19, 18 ")); |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | Everything::sendSmartString(getName() + " " + m_nSensorValue); |
| 165 | } |
| 166 | |
| 167 | void PS_PulseCounter::setPin(byte pin) |
| 168 | { |