diff --git a/src/SparkFun_SHTC3.cpp b/src/SparkFun_SHTC3.cpp index faf6bf9..9030aca 100644 --- a/src/SparkFun_SHTC3.cpp +++ b/src/SparkFun_SHTC3.cpp @@ -28,7 +28,7 @@ SHTC3_Status_TypeDef SHTC3::sendCommand(SHTC3_MeasurementModes_TypeDef cmd) return sendCommand((SHTC3_Commands_TypeDef)cmd); } -SHTC3_Status_TypeDef SHTC3::abortUpdate(SHTC3_Status_TypeDef status, char *file, uint16_t line) // Sets the values to a known error state +SHTC3_Status_TypeDef SHTC3::abortUpdate(SHTC3_Status_TypeDef status, const char *file, uint16_t line) // Sets the values to a known error state { passRHcrc = false; passTcrc = false; @@ -41,7 +41,7 @@ SHTC3_Status_TypeDef SHTC3::abortUpdate(SHTC3_Status_TypeDef status, char *file, return exitOp(status, file, line); } -SHTC3_Status_TypeDef SHTC3::exitOp(SHTC3_Status_TypeDef status, char *file, uint16_t line) +SHTC3_Status_TypeDef SHTC3::exitOp(SHTC3_Status_TypeDef status, const char *file, uint16_t line) { lastStatus = status; SHTC3_exitOp_Callback(status, _inProcess, file, line); @@ -403,7 +403,9 @@ SHTC3_Status_TypeDef SHTC3::update() SHTC3_Status_TypeDef SHTC3::checkCRC(uint16_t packet, uint8_t cs) { - uint8_t data[2] = {((packet & 0xFF00) >> 8), ((packet & 0x00FF) >> 0)}; + uint8_t upper = packet >> 8; + uint8_t lower = packet & 0x00FF; + uint8_t data[2] = {upper, lower}; uint8_t crc = 0xFF; uint8_t poly = 0x31; @@ -446,4 +448,4 @@ float SHTC3_raw2Percent(uint16_t RH) return 100 * ((float)RH / 65535); } -void SHTC3_exitOp_Callback(SHTC3_Status_TypeDef status, bool inProcess, char *file, uint16_t line) {} // Empty implementation. You can make your own implementation \ No newline at end of file +void SHTC3_exitOp_Callback(SHTC3_Status_TypeDef status, bool inProcess, const char *file, uint16_t line) {} // Empty implementation. You can make your own implementation \ No newline at end of file diff --git a/src/SparkFun_SHTC3.h b/src/SparkFun_SHTC3.h index aa031fd..ebf66b2 100644 --- a/src/SparkFun_SHTC3.h +++ b/src/SparkFun_SHTC3.h @@ -60,9 +60,9 @@ class SHTC3 bool _isAsleep; // Used to indicate if a wake() command is needed before talking SHTC3_Status_TypeDef sendCommand(SHTC3_Commands_TypeDef cmd); - SHTC3_Status_TypeDef sendCommand(SHTC3_MeasurementModes_TypeDef cmd); // Overloaded version of send command to support the "measurement type" commands - SHTC3_Status_TypeDef abortUpdate(SHTC3_Status_TypeDef status, char *file, uint16_t line); // Used to bail from an update. Sets reading values to known fail state - SHTC3_Status_TypeDef exitOp(SHTC3_Status_TypeDef status, char *file, uint16_t line); // Used to bail from any other operation - puts the sensor back to sleep + SHTC3_Status_TypeDef sendCommand(SHTC3_MeasurementModes_TypeDef cmd); // Overloaded version of send command to support the "measurement type" commands + SHTC3_Status_TypeDef abortUpdate(SHTC3_Status_TypeDef status, const char *file, uint16_t line); // Used to bail from an update. Sets reading values to known fail state + SHTC3_Status_TypeDef exitOp(SHTC3_Status_TypeDef status, const char *file, uint16_t line); // Used to bail from any other operation - puts the sensor back to sleep SHTC3_Status_TypeDef startProcess(void); // Used to wake up the sensor and set the _inProcess variable to true SHTC3_Status_TypeDef endProcess(void); // Used to end processes as the user desires @@ -101,6 +101,6 @@ float SHTC3_raw2DegC(uint16_t T); // Converts SHTC3 T data to deg C float SHTC3_raw2DegF(uint16_t T); // Converts SHTC3 T data to deg F float SHTC3_raw2Percent(uint16_t RH); // Converts SHTC3 RH data to % RH -void SHTC3_exitOp_Callback(SHTC3_Status_TypeDef status, bool inProcess, char *file, uint16_t line) __attribute__((weak)); // Called whenever exitOp is called, which is on most return statements +void SHTC3_exitOp_Callback(SHTC3_Status_TypeDef status, bool inProcess, const char *file, uint16_t line) __attribute__((weak)); // Called whenever exitOp is called, which is on most return statements #endif /* SF_SHTC3 */ \ No newline at end of file