99 * @author SparkFun Electronics
1010 * @date 2025
1111 * @copyright Copyright (c) 2025, SparkFun Electronics Inc. This project is released under the MIT License.
12- *
12+ *
1313 * SPDX-License-Identifier: MIT
1414 */
1515
16-
1716#include " sfDevSoilMoisture.h"
1817
1918// Impl for the core driver
2221/* *
2322 * @brief Command to turn off the on-board LED
2423 */
25- # define kCommandLEDOff 0x00
24+ const uint8_t kCommandLEDOff = 0x00 ;
2625
2726/* *
2827 * @brief Command to turn on the on-board LED
2928 */
30- # define kCommandLEDOn 0x01
29+ const uint8_t kCommandLEDOn = 0x01 ;
3130
3231/* *
3332 * @brief Command to change the I2C address of the sensor
3433 */
35- # define kCommandChangeAddress 0x03
34+ const uint8_t kCommandChangeAddress = 0x03 ;
3635
3736/* *
3837 * @brief Command to get the moisture value from the sensor
3938 */
40- # define kCommandGetValue 0x05
39+ const uint8_t kCommandGetValue = 0x05 ;
4140
4241/* *
4342 * @brief Command indicating no new data is available
4443 */
45- # define kCommandNothingNew 0x99
44+ const uint8_t kCommandNothingNew = 0x99 ;
4645
4746// ---------------------------------------------------------------------
4847// Core object implementation
@@ -68,7 +67,7 @@ sfTkError_t sfDevSoilMoisture::LEDOff(void)
6867 return ksfTkErrBusNotInit;
6968
7069 // Send the command to turn the LED off
71- return _theBus->writeByte (kCommandLEDOff );
70+ return _theBus->writeData (kCommandLEDOff );
7271}
7372// ----------------------------------------------------------------------------------------
7473// LED on command
@@ -78,7 +77,7 @@ sfTkError_t sfDevSoilMoisture::LEDOn(void)
7877 return ksfTkErrBusNotInit;
7978
8079 // Send the command to turn the LED on
81- return _theBus->writeByte (kCommandLEDOn );
80+ return _theBus->writeData (kCommandLEDOn );
8281}
8382
8483// ----------------------------------------------------------------------------------------
@@ -89,7 +88,7 @@ uint16_t sfDevSoilMoisture::readMoistureValue(void)
8988 return 0 ;
9089
9190 uint16_t value = 0 ;
92- if (_theBus->readRegisterWord (kCommandGetValue , value) != ksfTkErrOk)
91+ if (_theBus->readRegister (kCommandGetValue , value) != ksfTkErrOk)
9392 return 0 ;
9493
9594 return value;
@@ -128,7 +127,7 @@ sfTkError_t sfDevSoilMoisture::setI2CAddress(uint8_t newAddress)
128127
129128 // Send the command to change the address. NOTE: Because of how the sensor works,
130129 // the following will return an error (since the sensor side resets the bus)
131- (void )_theBus->writeRegisterByte (kCommandChangeAddress , newAddress);
130+ (void )_theBus->writeRegister (kCommandChangeAddress , newAddress);
132131
133132 return ksfTkErrOk;
134133}
0 commit comments