Skip to content

Commit

Permalink
Minor (breaking) method name changes in the API, more comments and mo…
Browse files Browse the repository at this point in the history
…re descriptive names in sample code
  • Loading branch information
Atlas-Scientific committed Sep 19, 2019
1 parent 4830ca4 commit 32e1eda
Show file tree
Hide file tree
Showing 9 changed files with 423 additions and 210 deletions.
52 changes: 27 additions & 25 deletions Examples/I2c_read_mulitple_circuits/I2c_read_mulitple_circuits.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,15 @@ void setup() {
Serial.begin(9600); //start the serial communication to the computer
}

void receive_reading(Ezo_board &Sensor) { // function to decode the reading after the read command was issued

Serial.print(Sensor.get_name()); Serial.print(": "); // print the name of the circuit getting the reading

Sensor.receive_read(); //get the response data and put it into the [Sensor].reading variable if successful

switch (Sensor.get_error()) { //switch case based on what the response code is.
case Ezo_board::SUCCESS:
Serial.print(Sensor.get_reading()); //the command was successful, print the reading
break;

case Ezo_board::FAIL:
Serial.print("Failed "); //means the command has failed.
break;

case Ezo_board::NOT_READY:
Serial.print("Pending "); //the command has not yet been finished calculating.
break;

case Ezo_board::NO_DATA:
Serial.print("No Data "); //the sensor has no data to send.
break;
}
}

void loop() {
if (reading_request_phase) { //if were in the phase where we ask for a reading

//send a read command. we use this command instead of PH.send_cmd("R");
//to let the library know to parse the reading
PH.send_read();
EC.send_read();
PH.send_read_cmd();
EC.send_read_cmd();

next_poll_time = millis() + response_delay; //set when the response will arrive
reading_request_phase = false; //switch to the receiving phase
Expand All @@ -62,3 +39,28 @@ void loop() {
}
}
}

void receive_reading(Ezo_board &Sensor) { // function to decode the reading after the read command was issued

Serial.print(Sensor.get_name()); Serial.print(": "); // print the name of the circuit getting the reading

Sensor.receive_read_cmd(); //get the response data and put it into the [Sensor].reading variable if successful

switch (Sensor.get_error()) { //switch case based on what the response code is.
case Ezo_board::SUCCESS:
Serial.print(Sensor.get_last_received_reading()); //the command was successful, print the reading
break;

case Ezo_board::FAIL:
Serial.print("Failed "); //means the command has failed.
break;

case Ezo_board::NOT_READY:
Serial.print("Pending "); //the command has not yet been finished calculating.
break;

case Ezo_board::NO_DATA:
Serial.print("No Data "); //the sensor has no data to send.
break;
}
}
57 changes: 29 additions & 28 deletions Examples/pH_EC_led_indicator/pH_EC_led_indicator.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,14 @@ void setup() {
pinMode(EC_led, OUTPUT); //set pin for EC led as output
}

void receive_reading(Ezo_board &Sensor) { // function to decode the reading after the read command was issued

Serial.print(Sensor.get_name()); Serial.print(": "); // print the name of the circuit getting the reading

Sensor.receive_read(); //get the response data and put it into the [Sensor].reading variable if successful

switch (Sensor.get_error()) { //switch case based on what the response code is.
case Ezo_board::SUCCESS:
Serial.print(Sensor.get_reading()); //the command was successful, print the reading
break;

case Ezo_board::FAIL:
Serial.print("Failed "); //means the command has failed.
break;

case Ezo_board::NOT_READY:
Serial.print("Pending "); //the command has not yet been finished calculating.
break;

case Ezo_board::NO_DATA:
Serial.print("No Data "); //the sensor has no data to send.
break;
}
}

void loop() {
if (reading_request_phase) { //if were in the phase where we ask for a reading

//send a read command. we use this command instead of PH.send_cmd("R");
//to let the library know to parse the reading
PH.send_read();
EC.send_read();
PH.send_read_cmd();
EC.send_read_cmd();

next_poll_time = millis() + response_delay; //set when the response will arrive
reading_request_phase = false; //switch to the receiving phase
Expand All @@ -68,7 +44,7 @@ void loop() {
if (millis() >= next_poll_time) { //and its time to get the response

receive_reading(PH); //get the reading from the PH circuit
if(PH.get_reading() > 10) { //test condition against pH reading
if(PH.get_last_received_reading() > 10) { //test condition against pH reading
digitalWrite(PH_led,HIGH); //if condition true, led on
}
else{
Expand All @@ -77,7 +53,7 @@ void loop() {
Serial.print(" ");

receive_reading(EC); //get the reading from the EC circuit
if (EC.get_reading() > 500.00) { //test condition against EC reading
if (EC.get_last_received_reading() > 500.00) { //test condition against EC reading
digitalWrite(EC_led,HIGH); //if condition true, led on
}
else{
Expand All @@ -90,3 +66,28 @@ void loop() {
}
}

void receive_reading(Ezo_board &Sensor) { // function to decode the reading after the read command was issued

Serial.print(Sensor.get_name()); Serial.print(": "); // print the name of the circuit getting the reading

Sensor.receive_read_cmd(); //get the response data and put it into the [Sensor].reading variable if successful

switch (Sensor.get_error()) { //switch case based on what the response code is.
case Ezo_board::SUCCESS:
Serial.print(Sensor.get_last_received_reading()); //the command was successful, print the reading
break;

case Ezo_board::FAIL:
Serial.print("Failed "); //means the command has failed.
break;

case Ezo_board::NOT_READY:
Serial.print("Pending "); //the command has not yet been finished calculating.
break;

case Ezo_board::NO_DATA:
Serial.print("No Data "); //the sensor has no data to send.
break;
}
}

56 changes: 28 additions & 28 deletions Examples/pH_dosing_pump/pH_dosing_pump.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,12 @@ void setup() {
Serial.begin(9600); //start the serial communication to the computer
}

void receive_reading(Ezo_board &Sensor) { // function to decode the reading after the read command was issued

Serial.print(Sensor.get_name()); Serial.print(": "); // print the name of the circuit getting the reading

Sensor.receive_read(); //get the response data and put it into the [Sensor].reading variable if successful

switch (Sensor.get_error()) { //switch case based on what the response code is.
case Ezo_board::SUCCESS:
Serial.print(Sensor.get_reading()); //the command was successful, print the reading
break;

case Ezo_board::FAIL:
Serial.print("Failed "); //means the command has failed.
break;

case Ezo_board::NOT_READY:
Serial.print("Pending "); //the command has not yet been finished calculating.
break;

case Ezo_board::NO_DATA:
Serial.print("No Data "); //the sensor has no data to send.
break;
}
}

void loop() {
if (reading_request_phase) { //if were in the phase where we ask for a reading

//send a read command. we use this command instead of PH.send_cmd("R");
//to let the library know to parse the reading
PH.send_read();
PH.send_read_cmd();

next_poll_time = millis() + response_delay; //set when the response will arrive
reading_request_phase = false; //switch to the receiving phase
Expand All @@ -66,15 +41,15 @@ void loop() {
Serial.print(" ");


if (PH.get_reading() <= 8) { //test condition against pH reading
if (PH.get_last_received_reading() <= 8) { //test condition against pH reading
Serial.println("PH LEVEL LOW,PMP_UP = ON");
PMP_UP.send_cmd_with_num("d,", 0.5); //if condition is true, send command to turn on pump (called PMP_UP) and dispense pH up solution, in amounts of 0.5ml. Pump turns clockwise.
}
else {
PMP_UP.send_cmd("x"); //if condition is false, send command to turn off pump (called PMP_UP)
}

if (PH.get_reading() >= 8.5) { //test condition against pH reading
if (PH.get_last_received_reading() >= 8.5) { //test condition against pH reading
Serial.println("PH LEVEL HIGH,PMP_DOWN = ON");
PMP_DOWN.send_cmd_with_num("d,", -0.5); //if condition is true, send command to turn on pump (called PMP_DOWN) and dispense pH down solution, in amounts of 0.5ml. Pump turns counter-clockwise.
}
Expand All @@ -87,3 +62,28 @@ void loop() {
}
}
}

void receive_reading(Ezo_board &Sensor) { // function to decode the reading after the read command was issued

Serial.print(Sensor.get_name()); Serial.print(": "); // print the name of the circuit getting the reading

Sensor.receive_read_cmd(); //get the response data and put it into the [Sensor].reading variable if successful

switch (Sensor.get_error()) { //switch case based on what the response code is.
case Ezo_board::SUCCESS:
Serial.print(Sensor.get_last_received_reading()); //the command was successful, print the reading
break;

case Ezo_board::FAIL:
Serial.print("Failed "); //means the command has failed.
break;

case Ezo_board::NOT_READY:
Serial.print("Pending "); //the command has not yet been finished calculating.
break;

case Ezo_board::NO_DATA:
Serial.print("No Data "); //the sensor has no data to send.
break;
}
}
Loading

0 comments on commit 32e1eda

Please sign in to comment.