Skip to content

Commit 7a1d718

Browse files
authored
Merge pull request #1 from sparkfun/feature/tk-name-change
fix issues related to name change
2 parents 84e937d + ba85f56 commit 7a1d718

File tree

3 files changed

+59
-59
lines changed

3 files changed

+59
-59
lines changed

src/SparkFun_Soil_Moisture_Sensor.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121

2222
// To make the Arduino machine happy, include the toolkit header before the core implementation for this device
2323
#include <SparkFun_Toolkit.h>
24-
#include "sfeTk/sfeDevSoilMoisture.h"
24+
#include "sfTk/sfDevSoilMoisture.h"
2525

2626

2727
// Note:
28-
// The core of the implementation for this device library is in the SparkFun Toolkit object sfeDevSoilMoisture,
29-
// contained in the directory sfeTk. This object implements all functionality independent of the bus type, I2C or SPI.
28+
// The core of the implementation for this device library is in the SparkFun Toolkit object sfDevSoilMoisture,
29+
// contained in the directory sfTk. This object implements all functionality independent of the bus type, I2C or SPI.
3030
// The SparkFunSoilMoistureSensorI2C and SparkFunSoilMoistureSensorSPI classes below are the Arduino-specific,
3131
// bus-specific implementations that inherit from the core toolkit class.
3232
//
3333
//-----------------------------------------------------------------------------------------------
3434
// Define our Arduino Object - I2C version
35-
class SparkFunSoilMoistureSensorI2C : public sfeDevSoilMoisture
35+
class SparkFunSoilMoistureSensorI2C : public sfDevSoilMoisture
3636
{
3737
public:
3838
/**
@@ -45,13 +45,13 @@ class SparkFunSoilMoistureSensorI2C : public sfeDevSoilMoisture
4545
* @param wirePort Wire port to use for I2C communication (default is Wire)
4646
* @return true if successful, false otherwise
4747
*/
48-
bool begin(const uint8_t address = SFE_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS, TwoWire &wirePort = Wire)
48+
bool begin(const uint8_t address = SF_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS, TwoWire &wirePort = Wire)
4949
{
5050
// Setup Arduino I2C bus
5151
_theI2CBus.init(wirePort, address);
5252

5353
// Begin the sensor and make sure it's connected.
54-
return sfeDevSoilMoisture::begin(&_theI2CBus) == kSTkErrOk ? isConnected() : false;
54+
return sfDevSoilMoisture::begin(&_theI2CBus) == ksfTkErrOk ? isConnected() : false;
5555
}
5656

5757
/**
@@ -64,16 +64,16 @@ class SparkFunSoilMoistureSensorI2C : public sfeDevSoilMoisture
6464
*/
6565
bool isConnected()
6666
{
67-
return _theI2CBus.ping() == kSTkErrOk;
67+
return _theI2CBus.ping() == ksfTkErrOk;
6868
}
6969

7070
private:
71-
sfeTkArdI2C _theI2CBus;
71+
sfTkArdI2C _theI2CBus;
7272
};
7373

7474
//-----------------------------------------------------------------------------------------------
7575
// Define our Arduino Object - SPI version
76-
class SparkFunSoilMoistureSensorSPI : public sfeDevSoilMoisture
76+
class SparkFunSoilMoistureSensorSPI : public sfDevSoilMoisture
7777
{
7878
public:
7979
/**
@@ -96,9 +96,9 @@ class SparkFunSoilMoistureSensorSPI : public sfeDevSoilMoisture
9696
_theSPIBus.init(spiPort, spiSettings, csPin, true);
9797

9898
// Begin the sensor with the SPI bus connection
99-
return (sfeDevSoilMoisture::begin(&_theSPIBus) == kSTkErrOk);
99+
return (sfDevSoilMoisture::begin(&_theSPIBus) == ksfTkErrOk);
100100
}
101101

102102
private:
103-
sfeTkArdSPI _theSPIBus;
103+
sfTkArdSPI _theSPIBus;
104104
};

src/sfeTk/sfeDevSoilMoisture.cpp renamed to src/sfTk/sfDevSoilMoisture.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file sfeDevSoilMoisture.cpp
2+
* @file sfDevSoilMoisture.cpp
33
* @brief Implementation file for the soil moisture sensor class
44
*
55
* This file contains the implementation of the soil moisture sensor class, including
@@ -14,7 +14,7 @@
1414
*/
1515

1616

17-
#include "sfeDevSoilMoisture.h"
17+
#include "sfDevSoilMoisture.h"
1818

1919
// Impl for the core driver
2020

@@ -48,102 +48,102 @@
4848
// Core object implementation
4949
//---------------------------------------------------------------------
5050
// start up the sensor
51-
sfeTkError_t sfeDevSoilMoisture::begin(sfeTkIBus *theBus)
51+
sfTkError_t sfDevSoilMoisture::begin(sfTkIBus *theBus)
5252
{
5353
// Nullptr check
5454
if (theBus == nullptr)
55-
return kSTkErrBusNotInit;
55+
return ksfTkErrBusNotInit;
5656

5757
// Set bus pointer
5858
_theBus = theBus;
5959

60-
return kSTkErrOk;
60+
return ksfTkErrOk;
6161
}
6262

6363
//----------------------------------------------------------------------------------------
6464
// LED off command
65-
sfeTkError_t sfeDevSoilMoisture::LEDOff(void)
65+
sfTkError_t sfDevSoilMoisture::LEDOff(void)
6666
{
6767
if (_theBus == nullptr)
68-
return kSTkErrBusNotInit;
68+
return ksfTkErrBusNotInit;
6969

7070
// Send the command to turn the LED off
7171
return _theBus->writeByte(kCommandLEDOff);
7272
}
7373
//----------------------------------------------------------------------------------------
7474
// LED on command
75-
sfeTkError_t sfeDevSoilMoisture::LEDOn(void)
75+
sfTkError_t sfDevSoilMoisture::LEDOn(void)
7676
{
7777
if (_theBus == nullptr)
78-
return kSTkErrBusNotInit;
78+
return ksfTkErrBusNotInit;
7979

8080
// Send the command to turn the LED on
8181
return _theBus->writeByte(kCommandLEDOn);
8282
}
8383

8484
//----------------------------------------------------------------------------------------
8585
// Read the moisture value from the sensor - returns a resistance reading between 0 and 1023
86-
uint16_t sfeDevSoilMoisture::readMoistureValue(void)
86+
uint16_t sfDevSoilMoisture::readMoistureValue(void)
8787
{
8888
if (_theBus == nullptr)
8989
return 0;
9090

9191
uint16_t value = 0;
92-
if (_theBus->readRegisterWord(kCommandGetValue, value) != kSTkErrOk)
92+
if (_theBus->readRegisterWord(kCommandGetValue, value) != ksfTkErrOk)
9393
return 0;
9494

9595
return value;
9696
}
9797

9898
//----------------------------------------------------------------------------------------
9999
// Returns the moisture ratio from the sensor (0 - 1.0)
100-
float sfeDevSoilMoisture::readMoistureRatio(void)
100+
float sfDevSoilMoisture::readMoistureRatio(void)
101101
{
102102
if (_theBus == nullptr)
103103
return 0.0;
104104

105-
return (((float)SFE_SOIL_MOISTURE_MAX_VALUE - (float)readMoistureValue()) / (float)SFE_SOIL_MOISTURE_MAX_VALUE);
105+
return (((float)SF_SOIL_MOISTURE_MAX_VALUE - (float)readMoistureValue()) / (float)SF_SOIL_MOISTURE_MAX_VALUE);
106106
}
107107

108108
//----------------------------------------------------------------------------------------
109109
// Returns the moisture percentage from the sensor (0 - 100%)
110-
float sfeDevSoilMoisture::readMoisturePercentage(void)
110+
float sfDevSoilMoisture::readMoisturePercentage(void)
111111
{
112112
return readMoistureRatio() * 100.0;
113113
}
114114
//----------------------------------------------------------------------------------------
115115
// Change the I2C address of the sensor
116-
sfeTkError_t sfeDevSoilMoisture::setI2CAddress(uint8_t newAddress)
116+
sfTkError_t sfDevSoilMoisture::setI2CAddress(uint8_t newAddress)
117117
{
118118
if (_theBus == nullptr)
119-
return kSTkErrBusNotInit;
119+
return ksfTkErrBusNotInit;
120120

121121
// Validate the new address
122122
if (newAddress < 0x07 || newAddress > 0x78)
123-
return kSTkErrFail;
123+
return ksfTkErrFail;
124124

125125
// If in I2C mode, is the address the same as the current address?
126-
if (_theBus->type() == kBusTypeI2C && ((sfeTkII2C *)_theBus)->address() == newAddress)
127-
return kSTkErrOk;
126+
if (_theBus->type() == ksfTkBusTypeI2C && ((sfTkII2C *)_theBus)->address() == newAddress)
127+
return ksfTkErrOk;
128128

129129
// Send the command to change the address. NOTE: Because of how the sensor works,
130130
// the following will return an error (since the sensor side resets the bus)
131131
(void)_theBus->writeRegisterByte(kCommandChangeAddress, newAddress);
132132

133-
return kSTkErrOk;
133+
return ksfTkErrOk;
134134
}
135135
//----------------------------------------------------------------------------------------
136136
// Return the address of the sensor bus. For I2C this is the address of the sensor, for
137137
// SPI this is the CS pin
138-
uint8_t sfeDevSoilMoisture::address(void)
138+
uint8_t sfDevSoilMoisture::address(void)
139139
{
140140
if (_theBus == nullptr)
141141
return 0;
142142

143-
if (_theBus->type() == kBusTypeSPI)
144-
return ((sfeTkISPI *)_theBus)->cs();
145-
else if (_theBus->type() == kBusTypeI2C)
146-
return ((sfeTkII2C *)_theBus)->address();
143+
if (_theBus->type() == ksfTkBusTypeSPI)
144+
return ((sfTkISPI *)_theBus)->cs();
145+
else if (_theBus->type() == ksfTkBusTypeI2C)
146+
return ((sfTkII2C *)_theBus)->address();
147147

148148
return 0;
149149
}

src/sfeTk/sfeDevSoilMoisture.h renamed to src/sfTk/sfDevSoilMoisture.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file sfeDevSoilMoisture.h
2+
* @file sfDevSoilMoisture.h
33
* @brief Header file for the soil moisture sensor class
44
*
55
* This file contains the class definition for the soil moisture sensor, including
@@ -20,39 +20,39 @@
2020
#include <stdint.h>
2121

2222
// include the sparkfun toolkit headers
23-
#include <sfeTk/sfeToolkit.h>
23+
#include <sfTk/sfToolkit.h>
2424

2525
// Bus interfaces
26-
#include <sfeTk/sfeTkII2C.h>
27-
#include <sfeTk/sfeTkISPI.h>
26+
#include <sfTk/sfTkII2C.h>
27+
#include <sfTk/sfTkISPI.h>
2828

2929
/**
3030
* @brief Default I2C address for the soil moisture sensor
3131
*
3232
* This macro defines the default I2C address (0x28) used by the soil moisture sensor.
3333
*/
34-
#define SFE_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS 0x28
34+
#define SF_SOIL_MOISTURE_DEFAULT_I2C_ADDRESS 0x28
3535

3636
/**
3737
* @brief Maximum value for the soil moisture sensor
3838
*
3939
* This macro defines the maximum value (1023) for the soil moisture sensor,
4040
* which corresponds to the highest reading from the 10-bit ADC. 2^10 = 1024-1
4141
*/
42-
#define SFE_SOIL_MOISTURE_MAX_VALUE 1023
42+
#define SF_SOIL_MOISTURE_MAX_VALUE 1023
4343

4444
/**
4545
* @brief Class representing the soil moisture sensor
4646
*
4747
* This class provides an interface to the soil moisture sensor, allowing for
4848
* initialization, reading moisture values and controlling the on-board LED.
4949
*/
50-
class sfeDevSoilMoisture
50+
class sfDevSoilMoisture
5151
{
5252

5353
public:
5454
// ctor
55-
sfeDevSoilMoisture() : _theBus{nullptr}
55+
sfDevSoilMoisture() : _theBus{nullptr}
5656
{
5757
}
5858

@@ -63,36 +63,36 @@ class sfeDevSoilMoisture
6363
* communication with the sensor using the provided I2C bus interface.
6464
*
6565
* @param theBus Pointer to an I2C toolkit object. If nullptr, uses previously set bus
66-
* @return kSTkErrOk if initialization succeeds
67-
* @return kSTkErrBusNotInit if no valid bus interface is provided
66+
* @return ksfTkErrOk if initialization succeeds
67+
* @return ksfTkErrBusNotInit if no valid bus interface is provided
6868
*/
69-
sfeTkError_t begin(sfeTkIBus *theBus = nullptr);
69+
sfTkError_t begin(sfTkIBus *theBus = nullptr);
7070

7171
/**
7272
* @brief Turns off the on-board LED
7373
*
7474
* Disables the sensor's built-in LED
7575
*
76-
* @return kSTkErrOk if LED was successfully turned off
77-
* @return kSTkErrBusNotInit if no bus interface is configured
78-
* @return kSTkErrFail if sensor doesn't respond or a communication error occurs
76+
* @return ksfTkErrOk if LED was successfully turned off
77+
* @return ksfTkErrBusNotInit if no bus interface is configured
78+
* @return ksfTkErrFail if sensor doesn't respond or a communication error occurs
7979
*
8080
* @see LEDOn()
8181
*/
82-
sfeTkError_t LEDOff(void);
82+
sfTkError_t LEDOff(void);
8383

8484
/**
8585
* @brief Turns on the on-board LED
8686
*
8787
* Enables the sensor's built-in LED by sending the appropriate command
8888
*
89-
* @return kSTkErrOk if LED was successfully turned on
90-
* @return kSTkErrBusNotInit if no bus interface is configured
91-
* @return kSTkErrFail if sensor doesn't respond or a communication error occurs
89+
* @return ksfTkErrOk if LED was successfully turned on
90+
* @return ksfTkErrBusNotInit if no bus interface is configured
91+
* @return ksfTkErrFail if sensor doesn't respond or a communication error occurs
9292
*
9393
* @see LEDOff()
9494
*/
95-
sfeTkError_t LEDOn(void);
95+
sfTkError_t LEDOn(void);
9696

9797
/**
9898
* @brief Reads the moisture value from the sensor
@@ -134,10 +134,10 @@ class sfeDevSoilMoisture
134134
* for all future I2C communication with the sensor. This value is persistent
135135
*
136136
* @param newAddress The new I2C address to assign to the sensor
137-
* @return kSTkErrOk if successful, otherwise an error code
137+
* @return ksfTkErrOk if successful, otherwise an error code
138138
* @note If communicating via I2C, the provided address is used for future I2C communication
139139
*/
140-
sfeTkError_t setI2CAddress(uint8_t newAddress);
140+
sfTkError_t setI2CAddress(uint8_t newAddress);
141141

142142
/**
143143
* @brief Returns the current address of the sensor
@@ -156,6 +156,6 @@ class sfeDevSoilMoisture
156156
* This member variable holds a pointer to the bus interface (I2C or SPI) used
157157
* for communication with the soil moisture sensor.
158158
*/
159-
sfeTkIBus *_theBus;
159+
sfTkIBus *_theBus;
160160

161-
}; // class sfeDevSoilMoisture
161+
}; // class sfDevSoilMoisture

0 commit comments

Comments
 (0)