-
-
Notifications
You must be signed in to change notification settings - Fork 100
3. Constructor, Destructor, SDI12.begin(), and SDI12.end()
The constructor requires a single parameter: the pin to be used for the data line. When the constructor is called it resets the buffer overflow status to FALSE and assigns the pin number "dataPin" to the private variable "_dataPin".
SDI12::SDI12(uint8_t dataPin){ _bufferOverflow = false; _dataPin = dataPin; }
When the destructor is called, it's main task is to disable any interrupts that had been previously assigned to the pin, so that the pin will behave as expected when used for other purposes. This is achieved by putting the SDI-12 object in the DISABLED state.
SDI12::~SDI12(){ setState(DISABLED); }
This is called to begin the functionality of the SDI-12 object. It has no parameters as the SDI-12 protocol is fully specified (e.g. the baud rate is set). It sets the object as the active object (if multiple SDI-12 instances are being used simultaneously).
void SDI12::begin() { setState(HOLDING); setActive(); }
This can be called to temporarily cease all functionality of the SDI-12 object. It is not as harsh as destroying the object with the destructor, as it will maintain the memory buffer.
void SDI12::end() { setState(DISABLED); }