From 281096749adee3428b0d69b19baf7aad6e85bcd4 Mon Sep 17 00:00:00 2001 From: Sebastien Robitaille Date: Mon, 25 Nov 2024 14:47:21 -0800 Subject: [PATCH 1/3] Update DFRobot_PH.cpp --- DFRobot_PH.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/DFRobot_PH.cpp b/DFRobot_PH.cpp index 8ee3166..cc5a9f8 100644 --- a/DFRobot_PH.cpp +++ b/DFRobot_PH.cpp @@ -51,19 +51,22 @@ DFRobot_PH::~DFRobot_PH() void DFRobot_PH::begin() { + EEPROM.begin(512); EEPROM_read(PHVALUEADDR, this->_neutralVoltage); //load the neutral (pH = 7.0)voltage of the pH board from the EEPROM - //Serial.print("_neutralVoltage:"); - //Serial.println(this->_neutralVoltage); + Serial.print("_neutralVoltage:"); + Serial.println(this->_neutralVoltage); if(EEPROM.read(PHVALUEADDR)==0xFF && EEPROM.read(PHVALUEADDR+1)==0xFF && EEPROM.read(PHVALUEADDR+2)==0xFF && EEPROM.read(PHVALUEADDR+3)==0xFF){ this->_neutralVoltage = 1500.0; // new EEPROM, write typical voltage EEPROM_write(PHVALUEADDR, this->_neutralVoltage); + EEPROM.commit(); } EEPROM_read(PHVALUEADDR+4, this->_acidVoltage);//load the acid (pH = 4.0) voltage of the pH board from the EEPROM - //Serial.print("_acidVoltage:"); - //Serial.println(this->_acidVoltage); + Serial.print("_acidVoltage:"); + Serial.println(this->_acidVoltage); if(EEPROM.read(PHVALUEADDR+4)==0xFF && EEPROM.read(PHVALUEADDR+5)==0xFF && EEPROM.read(PHVALUEADDR+6)==0xFF && EEPROM.read(PHVALUEADDR+7)==0xFF){ this->_acidVoltage = 2032.44; // new EEPROM, write typical voltage EEPROM_write(PHVALUEADDR+4, this->_acidVoltage); + EEPROM.commit(); } } @@ -200,9 +203,12 @@ void DFRobot_PH::phCalibration(byte mode) if((this->_voltage>1322)&&(this->_voltage<1678)){ EEPROM_write(PHVALUEADDR, this->_neutralVoltage); + Serial.print(">>>Buffer Solution:7.0,Calibration Successful: " + String(this->_neutralVoltage)); }else if((this->_voltage>1854)&&(this->_voltage<2210)){ EEPROM_write(PHVALUEADDR+4, this->_acidVoltage); + Serial.print(F(">>>Buffer Solution:4.0,Calibration Successful")); } + EEPROM.commit(); Serial.print(F(">>>Calibration Successful")); }else{ Serial.print(F(">>>Calibration Failed")); From a9921659677edd3a33b480d86b1dafcb6800acd3 Mon Sep 17 00:00:00 2001 From: Kayleb814 Date: Mon, 13 Jan 2025 16:51:09 -0800 Subject: [PATCH 2/3] Added place holders for new Mqtt calibrate methods at bottom of .cpp file, commented out --- DFRobot_PH.cpp | 204 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 178 insertions(+), 26 deletions(-) diff --git a/DFRobot_PH.cpp b/DFRobot_PH.cpp index cc5a9f8..f1c84f8 100644 --- a/DFRobot_PH.cpp +++ b/DFRobot_PH.cpp @@ -25,10 +25,12 @@ #define PHVALUEADDR 0x00 //the start address of the pH calibration parameters stored in the EEPROM -char* DFRobot_PH::strupr(char* str) { +char* DFRobot_PH::strupr(char* str) +{ if (str == NULL) return NULL; char *ptr = str; - while (*ptr != ' ') { + while (*ptr != ' ') + { *ptr = toupper((unsigned char)*ptr); ptr++; } @@ -55,7 +57,8 @@ void DFRobot_PH::begin() EEPROM_read(PHVALUEADDR, this->_neutralVoltage); //load the neutral (pH = 7.0)voltage of the pH board from the EEPROM Serial.print("_neutralVoltage:"); Serial.println(this->_neutralVoltage); - if(EEPROM.read(PHVALUEADDR)==0xFF && EEPROM.read(PHVALUEADDR+1)==0xFF && EEPROM.read(PHVALUEADDR+2)==0xFF && EEPROM.read(PHVALUEADDR+3)==0xFF){ + if(EEPROM.read(PHVALUEADDR)==0xFF && EEPROM.read(PHVALUEADDR+1)==0xFF && EEPROM.read(PHVALUEADDR+2)==0xFF && EEPROM.read(PHVALUEADDR+3)==0xFF) + { this->_neutralVoltage = 1500.0; // new EEPROM, write typical voltage EEPROM_write(PHVALUEADDR, this->_neutralVoltage); EEPROM.commit(); @@ -63,7 +66,8 @@ void DFRobot_PH::begin() EEPROM_read(PHVALUEADDR+4, this->_acidVoltage);//load the acid (pH = 4.0) voltage of the pH board from the EEPROM Serial.print("_acidVoltage:"); Serial.println(this->_acidVoltage); - if(EEPROM.read(PHVALUEADDR+4)==0xFF && EEPROM.read(PHVALUEADDR+5)==0xFF && EEPROM.read(PHVALUEADDR+6)==0xFF && EEPROM.read(PHVALUEADDR+7)==0xFF){ + if(EEPROM.read(PHVALUEADDR+4)==0xFF && EEPROM.read(PHVALUEADDR+5)==0xFF && EEPROM.read(PHVALUEADDR+6)==0xFF && EEPROM.read(PHVALUEADDR+7)==0xFF) + { this->_acidVoltage = 2032.44; // new EEPROM, write typical voltage EEPROM_write(PHVALUEADDR+4, this->_acidVoltage); EEPROM.commit(); @@ -96,7 +100,8 @@ void DFRobot_PH::calibration(float voltage, float temperature) { this->_voltage = voltage; this->_temperature = temperature; - if(cmdSerialDataAvailable() > 0){ + if(cmdSerialDataAvailable() > 0) + { phCalibration(cmdParse()); // if received Serial CMD from the serial monitor, enter into the calibration mode } } @@ -105,18 +110,23 @@ boolean DFRobot_PH::cmdSerialDataAvailable() { char cmdReceivedChar; static unsigned long cmdReceivedTimeOut = millis(); - while(Serial.available()>0){ - if(millis() - cmdReceivedTimeOut > 500U){ + while(Serial.available()>0) + { + if(millis() - cmdReceivedTimeOut > 500U) + { this->_cmdReceivedBufferIndex = 0; memset(this->_cmdReceivedBuffer,0,(ReceivedBufferLength)); } cmdReceivedTimeOut = millis(); cmdReceivedChar = Serial.read(); - if (cmdReceivedChar == '\n' || this->_cmdReceivedBufferIndex==ReceivedBufferLength-1){ + if (cmdReceivedChar == '\n' || this->_cmdReceivedBufferIndex==ReceivedBufferLength-1) + { this->_cmdReceivedBufferIndex = 0; strupr(this->_cmdReceivedBuffer); return true; - }else{ + } + else + { this->_cmdReceivedBuffer[this->_cmdReceivedBufferIndex] = cmdReceivedChar; this->_cmdReceivedBufferIndex++; } @@ -127,11 +137,16 @@ boolean DFRobot_PH::cmdSerialDataAvailable() byte DFRobot_PH::cmdParse(const char* cmd) { byte modeIndex = 0; - if(strstr(cmd, "ENTERPH") != NULL){ + if(strstr(cmd, "ENTERPH") != NULL) + { modeIndex = 1; - }else if(strstr(cmd, "EXITPH") != NULL){ + } + else if(strstr(cmd, "EXITPH") != NULL) + { modeIndex = 3; - }else if(strstr(cmd, "CALPH") != NULL){ + } + else if(strstr(cmd, "CALPH") != NULL) + { modeIndex = 2; } return modeIndex; @@ -140,11 +155,16 @@ byte DFRobot_PH::cmdParse(const char* cmd) byte DFRobot_PH::cmdParse() { byte modeIndex = 0; - if(strstr(this->_cmdReceivedBuffer, "ENTERPH") != NULL){ + if(strstr(this->_cmdReceivedBuffer, "ENTERPH") != NULL) + { modeIndex = 1; - }else if(strstr(this->_cmdReceivedBuffer, "EXITPH") != NULL){ + } + else if(strstr(this->_cmdReceivedBuffer, "EXITPH") != NULL) + { modeIndex = 3; - }else if(strstr(this->_cmdReceivedBuffer, "CALPH") != NULL){ + } + else if(strstr(this->_cmdReceivedBuffer, "CALPH") != NULL) + { modeIndex = 2; } return modeIndex; @@ -155,9 +175,127 @@ void DFRobot_PH::phCalibration(byte mode) char *receivedBufferPtr; static boolean phCalibrationFinish = 0; static boolean enterCalibrationFlag = 0; - switch(mode){ + switch(mode) + { + case 0: + if(enterCalibrationFlag) + { + Serial.println(F(">>>Command Error<<<")); + } + break; + + case 1: + enterCalibrationFlag = 1; + phCalibrationFinish = 0; + Serial.println(); + Serial.println(F(">>>Enter PH Calibration Mode<<<")); + Serial.println(F(">>>Please put the probe into the 4.0 or 7.0 standard buffer solution<<<")); + Serial.println(); + break; + + case 2: + if(enterCalibrationFlag) + { + if((this->_voltage>1322)&&(this->_voltage<1678)) + { // buffer solution:7.0{ + Serial.println(); + Serial.print(F(">>>Buffer Solution:7.0")); + this->_neutralVoltage = this->_voltage; + Serial.println(F(",Send EXITPH to Save and Exit<<<")); + Serial.println(); + phCalibrationFinish = 1; + }else if((this->_voltage>1854)&&(this->_voltage<2210)) + { //buffer solution:4.0 + Serial.println(); + Serial.print(F(">>>Buffer Solution:4.0")); + this->_acidVoltage = this->_voltage; + Serial.println(F(",Send EXITPH to Save and Exit<<<")); + Serial.println(); + phCalibrationFinish = 1; + } + else + { + Serial.println(); + Serial.print(F(">>>Buffer Solution Error Try Again<<<")); + Serial.println(); // not buffer solution or faulty operation + phCalibrationFinish = 0; + } + } + break; + + case 3: + if(enterCalibrationFlag) + { + Serial.println(); + if(phCalibrationFinish) + { + if((this->_voltage>1322)&&(this->_voltage<1678)) + { + + EEPROM_write(PHVALUEADDR, this->_neutralVoltage); + Serial.print(">>>Buffer Solution:7.0,Calibration Successful: " + String(this->_neutralVoltage)); + } + else if((this->_voltage>1854)&&(this->_voltage<2210)) + { + EEPROM_write(PHVALUEADDR+4, this->_acidVoltage); + Serial.print(F(">>>Buffer Solution:4.0,Calibration Successful")); + } + EEPROM.commit(); + Serial.print(F(">>>Calibration Successful")); + } + else + { + Serial.print(F(">>>Calibration Failed")); + } + Serial.println(F(",Exit PH Calibration Mode<<<")); + Serial.println(); + phCalibrationFinish = 0; + enterCalibrationFlag = 0; + } + break; + } +} + +/* +boolean DFRobot_PH::MQTTCalibrateMessageReceived() +//boolean DFRobot_PH::cmdSerialDataAvailable() +{ + char cmdReceivedChar; + static unsigned long cmdReceivedTimeOut = millis(); + while(Serial.available()>0) + { + if(millis() - cmdReceivedTimeOut > 500U) + { + this->_cmdReceivedBufferIndex = 0; + memset(this->_cmdReceivedBuffer,0,(ReceivedBufferLength)); + } + cmdReceivedTimeOut = millis(); + cmdReceivedChar = Serial.read(); + if (cmdReceivedChar == '\n' || this->_cmdReceivedBufferIndex==ReceivedBufferLength-1) + { + this->_cmdReceivedBufferIndex = 0; + strupr(this->_cmdReceivedBuffer); + return true; + } + else + { + this->_cmdReceivedBuffer[this->_cmdReceivedBufferIndex] = cmdReceivedChar; + this->_cmdReceivedBufferIndex++; + } + } + return false; +} + + void DFRobot_PH::MQTTphCalibration(byte mode) +{ + char *receivedBufferPtr; + static boolean phCalibrationFinish = 0; + static boolean enterCalibrationFlag = 0; + switch(mode) + { case 0: - if(enterCalibrationFlag){ + if(enterCalibrationFlag) + { Serial.println(F(">>>Command Error<<<")); } break; @@ -172,22 +310,28 @@ void DFRobot_PH::phCalibration(byte mode) break; case 2: - if(enterCalibrationFlag){ - if((this->_voltage>1322)&&(this->_voltage<1678)){ // buffer solution:7.0{ + if(enterCalibrationFlag) + { + if((this->_voltage>1322)&&(this->_voltage<1678)) + { // buffer solution:7.0{ Serial.println(); Serial.print(F(">>>Buffer Solution:7.0")); this->_neutralVoltage = this->_voltage; Serial.println(F(",Send EXITPH to Save and Exit<<<")); Serial.println(); phCalibrationFinish = 1; - }else if((this->_voltage>1854)&&(this->_voltage<2210)){ //buffer solution:4.0 + } + else if((this->_voltage>1854)&&(this->_voltage<2210)) + { //buffer solution:4.0 Serial.println(); Serial.print(F(">>>Buffer Solution:4.0")); this->_acidVoltage = this->_voltage; Serial.println(F(",Send EXITPH to Save and Exit<<<")); Serial.println(); phCalibrationFinish = 1; - }else{ + } + else + { Serial.println(); Serial.print(F(">>>Buffer Solution Error Try Again<<<")); Serial.println(); // not buffer solution or faulty operation @@ -197,20 +341,27 @@ void DFRobot_PH::phCalibration(byte mode) break; case 3: - if(enterCalibrationFlag){ + if(enterCalibrationFlag) + { Serial.println(); - if(phCalibrationFinish){ - if((this->_voltage>1322)&&(this->_voltage<1678)){ + if(phCalibrationFinish) + { + if((this->_voltage>1322)&&(this->_voltage<1678)) + { EEPROM_write(PHVALUEADDR, this->_neutralVoltage); Serial.print(">>>Buffer Solution:7.0,Calibration Successful: " + String(this->_neutralVoltage)); - }else if((this->_voltage>1854)&&(this->_voltage<2210)){ + } + else if((this->_voltage>1854)&&(this->_voltage<2210)) + { EEPROM_write(PHVALUEADDR+4, this->_acidVoltage); Serial.print(F(">>>Buffer Solution:4.0,Calibration Successful")); } EEPROM.commit(); Serial.print(F(">>>Calibration Successful")); - }else{ + } + else + { Serial.print(F(">>>Calibration Failed")); } Serial.println(F(",Exit PH Calibration Mode<<<")); @@ -221,3 +372,4 @@ void DFRobot_PH::phCalibration(byte mode) break; } } +*/ From 30db1bb212451f6f419820f583691c48658953cb Mon Sep 17 00:00:00 2001 From: Kayleb814 Date: Tue, 14 Jan 2025 10:20:52 -0800 Subject: [PATCH 3/3] Restored to original --- DFRobot_PH.cpp | 218 +++++++------------------------------------------ 1 file changed, 30 insertions(+), 188 deletions(-) diff --git a/DFRobot_PH.cpp b/DFRobot_PH.cpp index f1c84f8..8ee3166 100644 --- a/DFRobot_PH.cpp +++ b/DFRobot_PH.cpp @@ -25,12 +25,10 @@ #define PHVALUEADDR 0x00 //the start address of the pH calibration parameters stored in the EEPROM -char* DFRobot_PH::strupr(char* str) -{ +char* DFRobot_PH::strupr(char* str) { if (str == NULL) return NULL; char *ptr = str; - while (*ptr != ' ') - { + while (*ptr != ' ') { *ptr = toupper((unsigned char)*ptr); ptr++; } @@ -53,24 +51,19 @@ DFRobot_PH::~DFRobot_PH() void DFRobot_PH::begin() { - EEPROM.begin(512); EEPROM_read(PHVALUEADDR, this->_neutralVoltage); //load the neutral (pH = 7.0)voltage of the pH board from the EEPROM - Serial.print("_neutralVoltage:"); - Serial.println(this->_neutralVoltage); - if(EEPROM.read(PHVALUEADDR)==0xFF && EEPROM.read(PHVALUEADDR+1)==0xFF && EEPROM.read(PHVALUEADDR+2)==0xFF && EEPROM.read(PHVALUEADDR+3)==0xFF) - { + //Serial.print("_neutralVoltage:"); + //Serial.println(this->_neutralVoltage); + if(EEPROM.read(PHVALUEADDR)==0xFF && EEPROM.read(PHVALUEADDR+1)==0xFF && EEPROM.read(PHVALUEADDR+2)==0xFF && EEPROM.read(PHVALUEADDR+3)==0xFF){ this->_neutralVoltage = 1500.0; // new EEPROM, write typical voltage EEPROM_write(PHVALUEADDR, this->_neutralVoltage); - EEPROM.commit(); } EEPROM_read(PHVALUEADDR+4, this->_acidVoltage);//load the acid (pH = 4.0) voltage of the pH board from the EEPROM - Serial.print("_acidVoltage:"); - Serial.println(this->_acidVoltage); - if(EEPROM.read(PHVALUEADDR+4)==0xFF && EEPROM.read(PHVALUEADDR+5)==0xFF && EEPROM.read(PHVALUEADDR+6)==0xFF && EEPROM.read(PHVALUEADDR+7)==0xFF) - { + //Serial.print("_acidVoltage:"); + //Serial.println(this->_acidVoltage); + if(EEPROM.read(PHVALUEADDR+4)==0xFF && EEPROM.read(PHVALUEADDR+5)==0xFF && EEPROM.read(PHVALUEADDR+6)==0xFF && EEPROM.read(PHVALUEADDR+7)==0xFF){ this->_acidVoltage = 2032.44; // new EEPROM, write typical voltage EEPROM_write(PHVALUEADDR+4, this->_acidVoltage); - EEPROM.commit(); } } @@ -100,8 +93,7 @@ void DFRobot_PH::calibration(float voltage, float temperature) { this->_voltage = voltage; this->_temperature = temperature; - if(cmdSerialDataAvailable() > 0) - { + if(cmdSerialDataAvailable() > 0){ phCalibration(cmdParse()); // if received Serial CMD from the serial monitor, enter into the calibration mode } } @@ -110,23 +102,18 @@ boolean DFRobot_PH::cmdSerialDataAvailable() { char cmdReceivedChar; static unsigned long cmdReceivedTimeOut = millis(); - while(Serial.available()>0) - { - if(millis() - cmdReceivedTimeOut > 500U) - { + while(Serial.available()>0){ + if(millis() - cmdReceivedTimeOut > 500U){ this->_cmdReceivedBufferIndex = 0; memset(this->_cmdReceivedBuffer,0,(ReceivedBufferLength)); } cmdReceivedTimeOut = millis(); cmdReceivedChar = Serial.read(); - if (cmdReceivedChar == '\n' || this->_cmdReceivedBufferIndex==ReceivedBufferLength-1) - { + if (cmdReceivedChar == '\n' || this->_cmdReceivedBufferIndex==ReceivedBufferLength-1){ this->_cmdReceivedBufferIndex = 0; strupr(this->_cmdReceivedBuffer); return true; - } - else - { + }else{ this->_cmdReceivedBuffer[this->_cmdReceivedBufferIndex] = cmdReceivedChar; this->_cmdReceivedBufferIndex++; } @@ -137,16 +124,11 @@ boolean DFRobot_PH::cmdSerialDataAvailable() byte DFRobot_PH::cmdParse(const char* cmd) { byte modeIndex = 0; - if(strstr(cmd, "ENTERPH") != NULL) - { + if(strstr(cmd, "ENTERPH") != NULL){ modeIndex = 1; - } - else if(strstr(cmd, "EXITPH") != NULL) - { + }else if(strstr(cmd, "EXITPH") != NULL){ modeIndex = 3; - } - else if(strstr(cmd, "CALPH") != NULL) - { + }else if(strstr(cmd, "CALPH") != NULL){ modeIndex = 2; } return modeIndex; @@ -155,16 +137,11 @@ byte DFRobot_PH::cmdParse(const char* cmd) byte DFRobot_PH::cmdParse() { byte modeIndex = 0; - if(strstr(this->_cmdReceivedBuffer, "ENTERPH") != NULL) - { + if(strstr(this->_cmdReceivedBuffer, "ENTERPH") != NULL){ modeIndex = 1; - } - else if(strstr(this->_cmdReceivedBuffer, "EXITPH") != NULL) - { + }else if(strstr(this->_cmdReceivedBuffer, "EXITPH") != NULL){ modeIndex = 3; - } - else if(strstr(this->_cmdReceivedBuffer, "CALPH") != NULL) - { + }else if(strstr(this->_cmdReceivedBuffer, "CALPH") != NULL){ modeIndex = 2; } return modeIndex; @@ -175,11 +152,9 @@ void DFRobot_PH::phCalibration(byte mode) char *receivedBufferPtr; static boolean phCalibrationFinish = 0; static boolean enterCalibrationFlag = 0; - switch(mode) - { + switch(mode){ case 0: - if(enterCalibrationFlag) - { + if(enterCalibrationFlag){ Serial.println(F(">>>Command Error<<<")); } break; @@ -194,27 +169,22 @@ void DFRobot_PH::phCalibration(byte mode) break; case 2: - if(enterCalibrationFlag) - { - if((this->_voltage>1322)&&(this->_voltage<1678)) - { // buffer solution:7.0{ + if(enterCalibrationFlag){ + if((this->_voltage>1322)&&(this->_voltage<1678)){ // buffer solution:7.0{ Serial.println(); Serial.print(F(">>>Buffer Solution:7.0")); this->_neutralVoltage = this->_voltage; Serial.println(F(",Send EXITPH to Save and Exit<<<")); Serial.println(); phCalibrationFinish = 1; - }else if((this->_voltage>1854)&&(this->_voltage<2210)) - { //buffer solution:4.0 + }else if((this->_voltage>1854)&&(this->_voltage<2210)){ //buffer solution:4.0 Serial.println(); Serial.print(F(">>>Buffer Solution:4.0")); this->_acidVoltage = this->_voltage; Serial.println(F(",Send EXITPH to Save and Exit<<<")); Serial.println(); phCalibrationFinish = 1; - } - else - { + }else{ Serial.println(); Serial.print(F(">>>Buffer Solution Error Try Again<<<")); Serial.println(); // not buffer solution or faulty operation @@ -224,144 +194,17 @@ void DFRobot_PH::phCalibration(byte mode) break; case 3: - if(enterCalibrationFlag) - { + if(enterCalibrationFlag){ Serial.println(); - if(phCalibrationFinish) - { - if((this->_voltage>1322)&&(this->_voltage<1678)) - { + if(phCalibrationFinish){ + if((this->_voltage>1322)&&(this->_voltage<1678)){ EEPROM_write(PHVALUEADDR, this->_neutralVoltage); - Serial.print(">>>Buffer Solution:7.0,Calibration Successful: " + String(this->_neutralVoltage)); - } - else if((this->_voltage>1854)&&(this->_voltage<2210)) - { + }else if((this->_voltage>1854)&&(this->_voltage<2210)){ EEPROM_write(PHVALUEADDR+4, this->_acidVoltage); - Serial.print(F(">>>Buffer Solution:4.0,Calibration Successful")); } - EEPROM.commit(); Serial.print(F(">>>Calibration Successful")); - } - else - { - Serial.print(F(">>>Calibration Failed")); - } - Serial.println(F(",Exit PH Calibration Mode<<<")); - Serial.println(); - phCalibrationFinish = 0; - enterCalibrationFlag = 0; - } - break; - } -} - -/* -boolean DFRobot_PH::MQTTCalibrateMessageReceived() -//boolean DFRobot_PH::cmdSerialDataAvailable() -{ - char cmdReceivedChar; - static unsigned long cmdReceivedTimeOut = millis(); - while(Serial.available()>0) - { - if(millis() - cmdReceivedTimeOut > 500U) - { - this->_cmdReceivedBufferIndex = 0; - memset(this->_cmdReceivedBuffer,0,(ReceivedBufferLength)); - } - cmdReceivedTimeOut = millis(); - cmdReceivedChar = Serial.read(); - if (cmdReceivedChar == '\n' || this->_cmdReceivedBufferIndex==ReceivedBufferLength-1) - { - this->_cmdReceivedBufferIndex = 0; - strupr(this->_cmdReceivedBuffer); - return true; - } - else - { - this->_cmdReceivedBuffer[this->_cmdReceivedBufferIndex] = cmdReceivedChar; - this->_cmdReceivedBufferIndex++; - } - } - return false; -} - - void DFRobot_PH::MQTTphCalibration(byte mode) -{ - char *receivedBufferPtr; - static boolean phCalibrationFinish = 0; - static boolean enterCalibrationFlag = 0; - switch(mode) - { - case 0: - if(enterCalibrationFlag) - { - Serial.println(F(">>>Command Error<<<")); - } - break; - - case 1: - enterCalibrationFlag = 1; - phCalibrationFinish = 0; - Serial.println(); - Serial.println(F(">>>Enter PH Calibration Mode<<<")); - Serial.println(F(">>>Please put the probe into the 4.0 or 7.0 standard buffer solution<<<")); - Serial.println(); - break; - - case 2: - if(enterCalibrationFlag) - { - if((this->_voltage>1322)&&(this->_voltage<1678)) - { // buffer solution:7.0{ - Serial.println(); - Serial.print(F(">>>Buffer Solution:7.0")); - this->_neutralVoltage = this->_voltage; - Serial.println(F(",Send EXITPH to Save and Exit<<<")); - Serial.println(); - phCalibrationFinish = 1; - } - else if((this->_voltage>1854)&&(this->_voltage<2210)) - { //buffer solution:4.0 - Serial.println(); - Serial.print(F(">>>Buffer Solution:4.0")); - this->_acidVoltage = this->_voltage; - Serial.println(F(",Send EXITPH to Save and Exit<<<")); - Serial.println(); - phCalibrationFinish = 1; - } - else - { - Serial.println(); - Serial.print(F(">>>Buffer Solution Error Try Again<<<")); - Serial.println(); // not buffer solution or faulty operation - phCalibrationFinish = 0; - } - } - break; - - case 3: - if(enterCalibrationFlag) - { - Serial.println(); - if(phCalibrationFinish) - { - if((this->_voltage>1322)&&(this->_voltage<1678)) - { - - EEPROM_write(PHVALUEADDR, this->_neutralVoltage); - Serial.print(">>>Buffer Solution:7.0,Calibration Successful: " + String(this->_neutralVoltage)); - } - else if((this->_voltage>1854)&&(this->_voltage<2210)) - { - EEPROM_write(PHVALUEADDR+4, this->_acidVoltage); - Serial.print(F(">>>Buffer Solution:4.0,Calibration Successful")); - } - EEPROM.commit(); - Serial.print(F(">>>Calibration Successful")); - } - else - { + }else{ Serial.print(F(">>>Calibration Failed")); } Serial.println(F(",Exit PH Calibration Mode<<<")); @@ -372,4 +215,3 @@ boolean DFRobot_PH::MQTTCalibrateMessageReceived() break; } } -*/