1st comit
Dependencies: lib_Transmission SEN0169 DS1820
Revision 0:851e1c7a4454, committed 2022-01-11
- Comitter:
- jsanchez
- Date:
- Tue Jan 11 15:04:26 2022 +0000
- Commit message:
- 1st commit :)
Changed in this revision
diff -r 000000000000 -r 851e1c7a4454 DS1820.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DS1820.lib Tue Jan 11 15:04:26 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/jsanchez/code/DS1820/#12178901f65d
diff -r 000000000000 -r 851e1c7a4454 SEN0169.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SEN0169.lib Tue Jan 11 15:04:26 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/jsanchez/code/SEN0169/#f17189a32558
diff -r 000000000000 -r 851e1c7a4454 lib_Transmission.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib_Transmission.lib Tue Jan 11 15:04:26 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/YSI/code/lib_Transmission/#0d321d298d37
diff -r 000000000000 -r 851e1c7a4454 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jan 11 15:04:26 2022 +0000 @@ -0,0 +1,54 @@ +#include "main.h" + +int main(void) +{ + if (T_anode.begin()&&T_cathode.begin()) { + transmission.send(processing("*IDN?"),com); + while(1) { + T_anode.startConversion(); + T_cathode.startConversion(); + ThisThread::sleep_for(1s); + T_anode.read(temperature_anode); + T_cathode.read(temperature_cathode); + ph_anode = PH_anode.read_ph(); + ph_cathode = PH_cathode.read_ph(); + } + } +} + +string processing(string cmd) +{ + ostringstream ssend; + ssend << fixed; + ssend.precision(2); + if(cmd.empty()); + else if(cmd == "*IDN?") { + ssend << MBED_PROJECT << ", Mbed OS " << MBED_VERSION << ", Version dated, " << __DATE__ << ", " << __TIME__; + } else if(cmd == "MESURES?") { + ssend << temperature_anode << " ; " << temperature_cathode << " ; " << ph_anode << " ; " << ph_cathode; + + } else if(cmd == "ANODE:INFOS?") { + float* parameters = PH_anode.get_parameters(); + ssend << parameters[0] << " ; " << parameters[1] << " ; " << parameters[2] << " ; " << parameters[3] << " ; " << parameters[4]; + + } else if(cmd == "CATHODE:INFOS?") { + float* parameters = PH_anode.get_parameters(); + ssend << parameters[0] << " ; " << parameters[1] << " ; " << parameters[2] << " ; " << parameters[3] << " ; " << parameters[4]; + + } else if(cmd.find("ANODE:CALIB: ") != string::npos) { + stringstream param(cmd.substr(cmd.find(' ')+1)); + int tampon; + param >> tampon; + PH_anode.calibration(tampon); + + } else if(cmd.find("CATHODE:CALIB: ") != string::npos) { + stringstream param(cmd.substr(cmd.find(' ')+1)); + int tampon; + param >> tampon; + PH_cathode.calibration(tampon); + + } else if(cmd[cmd.size()-1] == '?') + ssend << "incorrect requeste [" << cmd << "]"; + + return ssend.str(); +} \ No newline at end of file
diff -r 000000000000 -r 851e1c7a4454 main.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.h Tue Jan 11 15:04:26 2022 +0000 @@ -0,0 +1,31 @@ +#ifndef MAIN_H +#define MAIN_H +#define MBED_PROJECT "2022_TICE_Electrolyse" +#define com Transmission::enum_trans_delivery::SERIAL_DELIVERY + +#include "mbed.h" + +#include "lib_Transmission.h" +#include "lib_SEN0169.h" +#include "DS1820.h" + +UnbufferedSerial pc(USBTX, USBRX, 230400); + +SEN0169 PH_anode(A0); +DS1820 T_anode(A1); +SEN0169 PH_cathode(A2); +DS1820 T_cathode(A3); + +string processing(string); +Transmission transmission(&pc, &processing); + +// Prototypes __________________________________________________________________ + +void initialisations(void); +string processing(string); + +// Variables ___________________________________________________________________ + +float temperature_anode = 0.0f, temperature_cathode = 0.0f; +float ph_anode = 0.0f, ph_cathode = 0.0f; +#endif \ No newline at end of file
diff -r 000000000000 -r 851e1c7a4454 mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Tue Jan 11 15:04:26 2022 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#2eb06e76208588afc6cb7580a8dd64c5429a10ce
diff -r 000000000000 -r 851e1c7a4454 mbed_app.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_app.json Tue Jan 11 15:04:26 2022 +0000 @@ -0,0 +1,10 @@ +{ + "target_overrides": { + "*": { + "target.c_lib": "std", + "target.printf_lib": "std", + "storage.storage_type":"TDB_INTERNAL", + "platform.callback-nontrivial": true + } + } +} \ No newline at end of file