Simple pH class.

Dependents:   Full-Project

Files at this revision

API Documentation at this revision

Comitter:
ptcrews
Date:
Mon Dec 07 00:05:54 2015 +0000
Parent:
1:1314058dbadb
Commit message:
Added comments.

Changed in this revision

pH_Sensor.cpp Show annotated file Show diff for this revision Revisions of this file
pH_Sensor.h Show annotated file Show diff for this revision Revisions of this file
diff -r 1314058dbadb -r 767f53c397ad pH_Sensor.cpp
--- a/pH_Sensor.cpp	Sat Dec 05 07:31:02 2015 +0000
+++ b/pH_Sensor.cpp	Mon Dec 07 00:05:54 2015 +0000
@@ -1,5 +1,10 @@
 #include "pH_Sensor.h"
 
+/* Function: disableContinuousMode
+ * -------------------------------
+ * The pH sensor initially reads continuously. Changes
+ * to single reading format.
+ */
 void pH_Sensor::disableContinuousMode() {
     printf("pH sensor will NOT run in continous mode.\n");
     if(pH_Serial.writeable() <= 0) printf("Not writable\n");
@@ -10,12 +15,20 @@
     wait(5);
 }
 
+/* Function: setup
+ * ---------------
+ * Initially sets up the pH sensor by setting the baud
+ * rate and disabling the continous mode.
+ */
 void pH_Sensor::setup() {
-    pH_Serial.baud(9600);
+    pH_Serial.baud(PH_BAUD);
     disableContinuousMode();
 }
 
-// Send default message to pH sensor, asking for data.
+/* Function: request
+ * -----------------
+ * Sends a request to the pH sensor asking for a reading.
+ */
 void pH_Sensor::request() {
     printf("Sending pH request...\n");
     if(pH_Serial.writeable() <= 0) printf("Not writable\n");
@@ -24,6 +37,11 @@
     pH_Serial.printf("%c", '\r');
 }
 
+/* Function: read
+ * --------------
+ * Requests a reading and parses the recieved data
+ * to construct and return a float.
+ */
 float pH_Sensor::read() {
     float pH = 0.0;
     request();
diff -r 1314058dbadb -r 767f53c397ad pH_Sensor.h
--- a/pH_Sensor.h	Sat Dec 05 07:31:02 2015 +0000
+++ b/pH_Sensor.h	Mon Dec 07 00:05:54 2015 +0000
@@ -1,9 +1,15 @@
 #include <string>
 #include "main.h"
 
+#define PH_BAUD 9600    // pH sensor baud rate
+
 #ifndef _PH_SENSOR_CLASS
 #define _PH_SENSOR_CLASS
 
+/* Class: pH_Sensor
+ * ----------------
+ * Entire pH sensor class implementation.
+ */
 class pH_Sensor {
  public:
     pH_Sensor() : pH_Serial(PH_TX, PH_RX){}