Salinity and temperature sensors are implemented in classes.

Dependencies:   mbed

Revision:
3:7c648d1d8802
Parent:
2:ed17e258da0d
Child:
5:4cbe44452889
--- a/main.cpp	Tue Jun 14 09:14:24 2016 +0000
+++ b/main.cpp	Thu Jun 16 11:28:59 2016 +0000
@@ -7,15 +7,24 @@
 #include "SalinitySensor.h"
 #include "TemperatureSensor.h"
 #include "Thermostat.h"
+#include "Waterplay.h"
 #include "DRV8825.h"
+#include "TextLCD.h"
+#include "Printer.h"
 #define MAX_SPEED 8000
 #define MICROSTEPS_PER_STEP 16
-DRV8825 stpr_mtr(p21, p22, p23, p24, p25, p26);
-
+DRV8825 stpr_mtr(
+    p21, p22, p23, p24, p25, p26
+);
+TextLCD lcd(
+    p19, p20, p21, p22, p23, p24
+);
+char buffer[128];
 char program_name[128] = "G3: WATERPLAY";
 int keep_running = 1;
 Serial serial(USBTX, USBRX);
 Flasher led1(LED1);
+Printer printer(serial, lcd);
 
 double salinity_voltage = 3.3;
 double salinity_converter = 1.6667; // 5.0/3.0
@@ -32,7 +41,7 @@
 double temperature_upper_boundary = 32.0;
 
 SalinitySensor salinitySensor(
-    serial,
+    printer,
     p16,
     salinity_voltage,
     salinity_converter,
@@ -42,7 +51,7 @@
 );
 
 TemperatureSensor temperatureSensor(
-    serial,
+    printer,
     p15,
     temperature_voltage,
     temperature_converter,
@@ -59,33 +68,22 @@
     LED4
 );
 
+Waterplay tempController(
+    printer,
+    temperatureSensor,
+    salinitySensor,
+    thermostat,
+    led1
+);
+
 double salinity_value = 0.0;
 double temperature_value = 0.0;
 int main()
 {
-    serial.printf("\n\r%s\n\r", program_name);
+    printer.display();
+    led1.flash(1);
 
     while(keep_running) {
-        salinitySensor.reload();
-        temperatureSensor.reload();
-
-        // in waiting for objects to be ready, make some delay.
-        // a single flashing is 0.2 second.
-        led1.flash(5);
-
-        serial.printf(
-            "salinity: %3.2F | %3.2F | %3.2F :: temperature: %3.2F | %3.2F | %3.2F\n\r",
-            salinitySensor.getReading(),
-            salinitySensor.getSalinity(),
-            salinitySensor.getStatus(),
-            temperatureSensor.getReading(),
-            temperatureSensor.getTemperature(),
-            temperatureSensor.getStatus()
-        );
-
-        thermostat.react(temperatureSensor.getStatus());
-        //or (int i = 500; i < MAX_SPEED; i+=5) {
-         //   stpr_mtr.settings(1/MICROSTEPS_PER_STEP, 1, i);
-        //}
+        tempController.control();
     }
 }
\ No newline at end of file