Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 12:7a48b90b493e, committed 2016-06-22
- Comitter:
- mariosimaremare
- Date:
- Wed Jun 22 12:34:37 2016 +0000
- Parent:
- 11:dcaaf1bb21ce
- Child:
- 13:142a142a7ac5
- Commit message:
- Add procedure.
Changed in this revision
--- a/Procedure.cpp Wed Jun 22 00:16:33 2016 +0000
+++ b/Procedure.cpp Wed Jun 22 12:34:37 2016 +0000
@@ -5,24 +5,40 @@
#include "Procedure.h"
Procedure::Procedure(
- Printer &printer
+ Printer &printer,
+ DigitalIn &button
):
- _printer(printer)
+ _printer(printer),
+ _button(button)
{
}
int Procedure::proceed()
{
- int number_of_procedure = 5;
+ int number_of_procedure = 15;
char* procedures[] = {
- "Q1?",
- "Q2?",
- "Q3?",
- "Q4?",
- "Q5?",
+ "01. Check the water tank.",
+ "02. Check salt reservoir.",
+ "03. Check water reservoir.",
+ "04. Check salinity syringe.",
+ "05. Check water syringe",
+ "06. Check salinity valve",
+ "07. Check water valve",
+ "08. Check salinity pipe",
+ "09. Check water pipe",
+ "10. Check temperature sensor",
+ "11. Check salinity sensor",
+ "12. Check proximity sensor",
+ "13. Check thermostat",
+ "14. Check stir station",
+ "15. Check voltages"
};
- for(int counter = 0; counter < number_of_procedure; ++counter){
- _printer.toBoth(procedures[counter]);
+ for(int counter = 0; counter < number_of_procedure;){
+ _printer.toBothln(procedures[counter]);
+ if (_button == 1){
+ counter++;
+ }
+ wait(1);
}
return(1);
--- a/Procedure.h Wed Jun 22 00:16:33 2016 +0000
+++ b/Procedure.h Wed Jun 22 12:34:37 2016 +0000
@@ -12,12 +12,14 @@
{
public:
Procedure(
- Printer &printer
+ Printer &printer,
+ DigitalIn &button
);
int proceed();
private:
Printer &_printer;
+ DigitalIn _button;
};
#endif
\ No newline at end of file
--- a/Tank.cpp Wed Jun 22 00:16:33 2016 +0000
+++ b/Tank.cpp Wed Jun 22 12:34:37 2016 +0000
@@ -46,7 +46,7 @@
"Range in cm: %d",
range
);
- _printer.toBoth(buffer);
+ _printer.toBothln(buffer);
if (range >= 12) {
_printer.toBoth("Proximity ok");
@@ -115,21 +115,28 @@
&& (fmod(this->_added_liquid, PROXIMITY_CHECK_POINT) == 0.0)
) {
is_allowed = is_proximity_ok();
+ if(is_allowed){
+ this->_added_liquid = 0.0;
+ }
}
float added_liquid = 0.0;
if(is_allowed) {
if(salinity < 0.0) {
_strStatus = "Add salt";
+ _printer.toBothln("set salt valve to the tank");
_alarm.flash(2, 0.2, 3.0);
this->add(TYPE_SALT, ADDED_SALT, DIRECTION_PUSH);
+ _printer.toBothln("set salt valve to the reservoir");
_alarm.flash(2, 0.2, 3.0);
this->add(TYPE_SALT, ADDED_SALT, DIRECTION_PULL);
added_liquid = ADDED_SALT;
} else if(salinity > 0.0) {
_strStatus = "Add water";
+ _printer.toBothln("set water valve to the tank");
_alarm.flash(1, 0.2, 3.0);
this->add(TYPE_PURE, ADDED_WATER, DIRECTION_PUSH);
+ _printer.toBothln("set water valve to reservoir");
_alarm.flash(1, 0.2, 3.0);
this->add(TYPE_PURE, ADDED_WATER, DIRECTION_PULL);
added_liquid = ADDED_WATER;
@@ -138,36 +145,36 @@
}
this->_added_liquid += added_liquid;
} else {
- _strStatus = "tank is overflow";
+ _strStatus = "Tank is overflowing";
_alarm.danger_flash();
}
}
void Tank::initialize()
{
+ _printer.toBoth("initializing...");
//initialize
- wait(3); //turn the thing to pulling from reservoir
+ _alarm.flash(1, 0.2, 3.0); //turn the thing to pulling from reservoir
this->add(TYPE_PURE, 20.0, DIRECTION_PULL);//20
- wait(3); //turn the thing to pushing to glass
+ _alarm.flash(1, 0.2, 3.0); //turn the thing to pushing to glass
this->add(TYPE_PURE, 20.0, DIRECTION_PUSH);//19.5
- wait(3); //turn the thing to pulling from reservoir
+ _alarm.flash(1, 0.2, 3.0); //turn the thing to pulling from reservoir
this->add(TYPE_PURE, 20.0, DIRECTION_PULL); //20
- wait(3); //turn the thing to pushing to glass
+ _alarm.flash(1, 0.2, 3.0); //turn the thing to pushing to glass
this->add(TYPE_PURE, 20.0, DIRECTION_PUSH);
- wait(3); //turn the thing to pulling from reservoir
+ _alarm.flash(1, 0.2, 3.0); //turn the thing to pulling from reservoir
this->add(TYPE_PURE, 25.0, DIRECTION_PULL); //20
//done
-
//initialize
- wait(3); //turn the thing to pulling from reservoir
+ _alarm.flash(2, 0.2, 3.0); //turn the thing to pulling from reservoir
this->add(TYPE_SALT, 20.0, DIRECTION_PULL);//20
- wait(3); //turn the thing to pushing to glass
+ _alarm.flash(2, 0.2, 3.0); //turn the thing to pushing to glass
this->add(TYPE_SALT, 20.0, DIRECTION_PUSH);//19.5
- wait(3); //turn the thing to pulling from reservoir
+ _alarm.flash(2, 0.2, 3.0); //turn the thing to pulling from reservoir
this->add(TYPE_SALT, 20.0, DIRECTION_PULL); //20
- wait(3); //turn the thing to pushing to glass
+ _alarm.flash(2, 0.2, 3.0); //turn the thing to pushing to glass
this->add(TYPE_SALT, 20.0, DIRECTION_PUSH);
- wait(3); //turn the thing to pulling from reservoir
+ _alarm.flash(2, 0.2, 3.0); //turn the thing to pulling from reservoir
this->add(TYPE_SALT, 25.0, DIRECTION_PULL); //20
}
\ No newline at end of file
--- a/Thermostat.h Wed Jun 22 00:16:33 2016 +0000
+++ b/Thermostat.h Wed Jun 22 12:34:37 2016 +0000
@@ -25,7 +25,7 @@
private:
Printer &_printer;
- AnalogOut _analog_out;
+ DigitalOut _analog_out;
DigitalOut _led;
int _status;
char* _strStatus;
--- a/Waterplay.cpp Wed Jun 22 00:16:33 2016 +0000
+++ b/Waterplay.cpp Wed Jun 22 12:34:37 2016 +0000
@@ -37,11 +37,11 @@
_temperatureSensor.getTemperature(),
_temperatureSensor.getStrStatus()
);
- _flasher.flash(5);
+ _flasher.flash(2);
if(
- _temperatureSensor.getStatus() != 0.0
- || _salinitySensor.getStatus() != 0.0
+ _temperatureSensor.getStatus() < 0.0
+ || _salinitySensor.getStatus() > 0.0
){
_alarm.danger_flash();
_thermostat.react(
@@ -56,6 +56,7 @@
_tank.getStrStatus(),
_thermostat.getStrStatus()
);
+ _flasher.flash(5);
return(retVal);
}
\ No newline at end of file
--- a/main.cpp Wed Jun 22 00:16:33 2016 +0000
+++ b/main.cpp Wed Jun 22 12:34:37 2016 +0000
@@ -7,6 +7,7 @@
#include "SalinitySensor.h"
#include "TemperatureSensor.h"
#include "Thermostat.h"
+#include "Procedure.h"
#include "Waterplay.h"
#include "TextLCD.h"
#include "Printer.h"
@@ -26,7 +27,7 @@
int keep_running = 1;
Serial serial(USBTX, USBRX);
Flasher led1(LED1);
-Flasher alarm(p20);
+Flasher alarm(p5);
Printer printer(serial, lcd);
SalinitySensor salinitySensor(
@@ -64,11 +65,19 @@
led1,
alarm
);
+
+DigitalIn button(p7);
+
+Procedure procedure(
+ printer,
+ button
+);
int main()
{
printer.display();
led1.flash(1);
+ //procedure.proceed();
//tank.initialize();
while(keep_running) {