11/* *
2- * @file usermod_BMW68X.h
2+ * @file usermod_BMW68X.cpp
33 * @author Gabriel A. Sieben (GeoGab)
44 * @brief Usermod for WLED to implement the BME680/BME688 sensor
55 * @version 1.0.0
3333
3434/* Debug Print Special Text */
3535#define INFO_COLUMN ESC_CURSOR_COLUMN (60 )
36- #define OK INFO_COLUMN " [" ESC_FGCOLOR_GREEN " OK" ESC_STYLE_RESET " ]"
37- #define FAIL INFO_COLUMN " [" ESC_FGCOLOR_RED " FAIL" ESC_STYLE_RESET " ]"
38- #define WARN INFO_COLUMN " [" ESC_FGCOLOR_YELLOW " WARN" ESC_STYLE_RESET " ]"
39- #define DONE INFO_COLUMN " [" ESC_FGCOLOR_CYAN " DONE" ESC_STYLE_RESET " ]"
36+ #define OK_MSG INFO_COLUMN " [" ESC_FGCOLOR_GREEN " OK" ESC_STYLE_RESET " ]"
37+ #define FAIL_MSG INFO_COLUMN " [" ESC_FGCOLOR_RED " FAIL" ESC_STYLE_RESET " ]"
38+ #define WARN_MSG INFO_COLUMN " [" ESC_FGCOLOR_YELLOW " WARN" ESC_STYLE_RESET " ]"
39+ #define DONE_MSG INFO_COLUMN " [" ESC_FGCOLOR_CYAN " DONE" ESC_STYLE_RESET " ]"
4040
4141#include " bsec.h" // Bosch sensor library
4242#include " wled.h"
@@ -328,7 +328,7 @@ void UsermodBME68X::setup() {
328328 /* Check, if i2c is activated */
329329 if (i2c_scl < 0 || i2c_sda < 0 ) {
330330 settings.enabled = false ; // Disable usermod once i2c is not running
331- DEBUG_PRINTLN (F (UMOD_DEBUG_NAME " I2C is not activated. Please activate I2C first." FAIL ));
331+ DEBUG_PRINTLN (F (UMOD_DEBUG_NAME " I2C is not activated. Please activate I2C first." FAIL_MSG ));
332332 return ;
333333 }
334334
@@ -352,7 +352,7 @@ void UsermodBME68X::setup() {
352352 loadState (); // Load the old calibration data
353353 checkIaqSensorStatus (); // Check the sensor status
354354 // HomeAssistantDiscovery();
355- DEBUG_PRINTLN (F (INFO_COLUMN DONE ));
355+ DEBUG_PRINTLN (F (INFO_COLUMN DONE_MSG ));
356356}
357357
358358/* *
@@ -564,7 +564,7 @@ void UsermodBME68X::HomeAssistantDiscovery() {
564564 MQTT_PublishHASensor (_nameStabStatus, " " , _unitNone, settings.publishSensorState - 1 , 1 );
565565 MQTT_PublishHASensor (_nameRunInStatus, " " , _unitNone, settings.publishSensorState - 1 , 1 );
566566
567- DEBUG_PRINTLN (UMOD_DEBUG_NAME DONE );
567+ DEBUG_PRINTLN (UMOD_DEBUG_NAME DONE_MSG );
568568}
569569
570570/* *
@@ -750,7 +750,7 @@ void UsermodBME68X::addToConfig(JsonObject& root) {
750750 sensors_json[FPSTR (_nameVoc)] = settings.decimals .Voc ;
751751 sensors_json[FPSTR (_nameGasPer)] = settings.decimals .gasPerc ;
752752
753- DEBUG_PRINTLN (F (OK ));
753+ DEBUG_PRINTLN (F (OK_MSG ));
754754}
755755
756756/* *
@@ -831,7 +831,7 @@ bool UsermodBME68X::readFromConfig(JsonObject& root) {
831831 configComplete &= getJsonValue (top[" Sensors" ][FPSTR (_nameVoc)], settings.decimals .Voc , 0 );
832832 configComplete &= getJsonValue (top[" Sensors" ][FPSTR (_nameGasPer)], settings.decimals .gasPerc , 0 );
833833
834- DEBUG_PRINTLN (F (OK ));
834+ DEBUG_PRINTLN (F (OK_MSG ));
835835
836836 /* Set the selected temperature unit */
837837 if (settings.tempScale ) {
@@ -845,10 +845,10 @@ bool UsermodBME68X::readFromConfig(JsonObject& root) {
845845 DEBUG_PRINT (F (UMOD_DEBUG_NAME " Deleting Calibration File" ));
846846 flags.DeleteCaibration = false ;
847847 if (WLED_FS.remove (CALIB_FILE_NAME)) {
848- DEBUG_PRINTLN (F (OK ));
848+ DEBUG_PRINTLN (F (OK_MSG ));
849849 }
850850 else {
851- DEBUG_PRINTLN (F (FAIL ));
851+ DEBUG_PRINTLN (F (FAIL_MSG ));
852852 }
853853 }
854854
@@ -1026,11 +1026,11 @@ void UsermodBME68X::checkIaqSensorStatus() {
10261026 flags.InitSuccessful = false ;
10271027 if (iaqSensor.bsecStatus < BSEC_OK) {
10281028 InfoPageStatusLine += " Error Code : " + String (iaqSensor.bsecStatus );
1029- DEBUG_PRINTLN (FAIL );
1029+ DEBUG_PRINTLN (FAIL_MSG );
10301030 }
10311031 else {
10321032 InfoPageStatusLine += " Warning Code : " + String (iaqSensor.bsecStatus );
1033- DEBUG_PRINTLN (WARN );
1033+ DEBUG_PRINTLN (WARN_MSG );
10341034 }
10351035 }
10361036 else {
@@ -1041,16 +1041,16 @@ void UsermodBME68X::checkIaqSensorStatus() {
10411041 flags.InitSuccessful = false ;
10421042 if (iaqSensor.bme68xStatus < BME68X_OK) {
10431043 InfoPageStatusLine += " error code: " + String (iaqSensor.bme68xStatus );
1044- DEBUG_PRINTLN (FAIL );
1044+ DEBUG_PRINTLN (FAIL_MSG );
10451045 }
10461046 else {
10471047 InfoPageStatusLine += " warning code: " + String (iaqSensor.bme68xStatus );
1048- DEBUG_PRINTLN (WARN );
1048+ DEBUG_PRINTLN (WARN_MSG );
10491049 }
10501050 }
10511051 else {
10521052 InfoPageStatusLine += F (" OK" );
1053- DEBUG_PRINTLN (OK );
1053+ DEBUG_PRINTLN (OK_MSG );
10541054 }
10551055 }
10561056}
@@ -1063,12 +1063,12 @@ void UsermodBME68X::loadState() {
10631063 DEBUG_PRINT (F (UMOD_DEBUG_NAME " Read the calibration file: " ));
10641064 File file = WLED_FS.open (CALIB_FILE_NAME, FILE_READ);
10651065 if (!file) {
1066- DEBUG_PRINTLN (FAIL );
1066+ DEBUG_PRINTLN (FAIL_MSG );
10671067 }
10681068 else {
10691069 file.read (bsecState, BSEC_MAX_STATE_BLOB_SIZE);
10701070 file.close ();
1071- DEBUG_PRINTLN (OK );
1071+ DEBUG_PRINTLN (OK_MSG );
10721072 iaqSensor.setState (bsecState);
10731073 }
10741074 }
@@ -1084,14 +1084,14 @@ void UsermodBME68X::saveState() {
10841084 DEBUG_PRINT (F (UMOD_DEBUG_NAME " Write the calibration file " ));
10851085 File file = WLED_FS.open (CALIB_FILE_NAME, FILE_WRITE);
10861086 if (!file) {
1087- DEBUG_PRINTLN (FAIL );
1087+ DEBUG_PRINTLN (FAIL_MSG );
10881088 }
10891089 else {
10901090 iaqSensor.getState (bsecState);
10911091 file.write (bsecState, BSEC_MAX_STATE_BLOB_SIZE);
10921092 file.close ();
10931093 stateUpdateCounter++;
1094- DEBUG_PRINTF (" (saved %d times)" OK " \n " , stateUpdateCounter);
1094+ DEBUG_PRINTF (" (saved %d times)" OK_MSG " \n " , stateUpdateCounter);
10951095 flags.SaveState = false ; // Clear save state flag
10961096
10971097 char contbuffer[30 ];
0 commit comments