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.
experiments.cpp
00001 #include <time.h> 00002 #include "cisme.h" 00003 #include "lcd.h" 00004 #include "debug.h" 00005 #include "light.h" 00006 #include "pump.h" 00007 #include "buzzer.h" 00008 #include "presens.h" 00009 #include "keys.h" 00010 #include "debug.h" 00011 #include "wifi_events.h" 00012 #include "experiments.h" 00013 #include "battery.h" 00014 00015 #define PRINT_RESULT_TO_FILE(_modeStepNo, _deltaTime, _02Float, _uMolO2, _phase, _amplitude)\ 00016 fprintf(currentFile,"%d,%2.6f,%c,%2.2f,%2.2f,%2.6f,%2.6f,%c,%2.6f,%2.6f,%2.2f,%2.2f,%d\n",\ 00017 _modeStepNo, _deltaTime / 60, ' ', _02Float, _uMolO2, pHCorrected, PHTEMP, ' ', pH, pHT, batteryGet(), _phase, _amplitude); 00018 00019 /* Variables neede in other modules: (mostly lcd_events.h)*/ 00020 FILE* currentFile = NULL; 00021 char FileName[FILE_NAME_LENGTH] = {0}; 00022 char FilePrefix[FILE_PREFIX_LENGTH] = {0}; 00023 int StartTime = 0; 00024 int SwitchMode = 0; 00025 float pgm[MAX_STEPS_NO][20]; 00026 00027 /* Local variables for module. */ 00028 /* Variables for user program. */ 00029 static int stepIx; 00030 static double phold; 00031 static float O2old; 00032 00033 /* Varibles for defined programs. */ 00034 static int mode = 0; 00035 static int minEXPER = 0; 00036 static int minMODE = 0; 00037 static int minTOTAL = 0; 00038 static bool isModeSwitched = false; 00039 00040 static void getFileName(void) 00041 { 00042 const char* months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; 00043 00044 struct tm *tim; 00045 time_t now; 00046 int numSymb = 0; 00047 int numSymbToPrint; 00048 00049 /* get time to make filename */ 00050 now = time(NULL); 00051 tim = localtime(&now); 00052 00053 /* 00054 * Make filename from date and time 00055 * format will be: C1_Mdd_hhmm.csv 00056 * M - 3 letters representing month 00057 * dd - day of month, 00058 * hh - hour, 00059 * mm - minutes. 00060 */ 00061 00062 // Set the Cisme unit name 00063 if (FilePrefix[0] == 0) { 00064 /* Prefix is not set. sprintf is used here to receive number of printed symbols. */ 00065 numSymb = sprintf(&FileName[0], "%s", instrumentId); 00066 } else { 00067 numSymb = snprintf(&FileName[0], FILE_NAME_LENGTH, "%s_", FilePrefix); 00068 } 00069 00070 numSymbToPrint = ((FILE_NAME_LENGTH - numSymb) < 0)? 0 : FILE_NAME_LENGTH - numSymb; 00071 numSymb += snprintf( &FileName[numSymb], numSymbToPrint, months[tim->tm_mon]); 00072 numSymbToPrint = ((FILE_NAME_LENGTH - numSymb) < 0)? 0 : FILE_NAME_LENGTH - numSymb; 00073 numSymb += strftime(&FileName[numSymb], numSymbToPrint, "%d", tim); 00074 numSymbToPrint = ((FILE_NAME_LENGTH - numSymb) < 0)? 0 : FILE_NAME_LENGTH - numSymb; 00075 numSymb += snprintf( &FileName[numSymb], numSymbToPrint, "_"); 00076 numSymbToPrint = ((FILE_NAME_LENGTH - numSymb) < 0)? 0 : FILE_NAME_LENGTH - numSymb; 00077 numSymb += strftime(&FileName[numSymb], numSymbToPrint, "%H%M", tim); 00078 numSymbToPrint = ((FILE_NAME_LENGTH - numSymb) < 0)? 0 : FILE_NAME_LENGTH - numSymb; 00079 00080 if (numSymbToPrint < 5) { 00081 snprintf(&FileName[FILE_NAME_LENGTH - 5], 5, ".csv"); 00082 } else { 00083 snprintf(&FileName[numSymb], numSymbToPrint, ".csv"); 00084 } 00085 } 00086 00087 static float getO2InMicromole(float O2Float) 00088 { 00089 const float A0 = 5.80871; 00090 const float A1 = 3.20291; 00091 const float A2 = 4.17887; 00092 const float A3 = 5.10006; 00093 const float A4 = -9.86643e-2; 00094 const float A5 = 3.80369; 00095 const float B0 = -7.01577e-3; 00096 const float B1 = -7.70028e-3; 00097 const float B2 = -1.13864e-2; 00098 const float B3 = -9.51519e-3; 00099 const float C0 = -2.75915e-7; 00100 float scaledT; 00101 float uMolO2; 00102 double salinDouble = double(Salinity); 00103 00104 // Calculate O2 in micromole per kilogram 00105 scaledT = 298.15 - PHTEMP; 00106 scaledT /= (273.15 + PHTEMP); 00107 scaledT = log(scaledT); 00108 uMolO2 = (A0 + (A1 * scaledT) + ((A2 * scaledT * scaledT) + (A3 * scaledT * scaledT * scaledT) + (A4 * scaledT * scaledT * scaledT * scaledT) + 00109 (A5 * scaledT * scaledT * scaledT * scaledT * scaledT) + ((Salinity * (B0 + (B1 * scaledT) + (B2 * scaledT * scaledT) + 00110 (B3 * scaledT * scaledT * scaledT))))+(C0 * salinDouble * salinDouble))); 00111 uMolO2 = exp(uMolO2); 00112 uMolO2 *= O2Float / 100; 00113 00114 return uMolO2; 00115 } 00116 00117 static float getDeltaTime(void) 00118 { 00119 struct tm *TimeNow; 00120 time_t now; 00121 float currentTime; 00122 float deltaTime; 00123 00124 time(&now); 00125 TimeNow = localtime(&now); 00126 // Calculate the current time to seconds 00127 currentTime = TimeNow->tm_sec + ((TimeNow->tm_min) * 60) + ((TimeNow->tm_hour) * 3600); 00128 00129 // Calculate the delta time from the start of the experiment or mode 00130 deltaTime = currentTime - StartTime; 00131 00132 return deltaTime; 00133 } 00134 00135 static void calculateStartTime(void) 00136 { 00137 struct tm *TimeNow; 00138 time_t now; 00139 00140 time(&now); 00141 TimeNow = localtime(&now); 00142 StartTime = (TimeNow->tm_sec) + ((TimeNow->tm_min) * 60) + ((TimeNow->tm_hour) * 3600); 00143 } 00144 00145 #ifdef USE_LCD 00146 void readUserPrograms(void) 00147 { 00148 FILE *programFile; 00149 00150 // Read predefined programs. 00151 programFile = fopen("/" FSNAME "/program.sys", "r"); 00152 00153 if (programFile == NULL) { 00154 lcdClear(); 00155 lcdWrite(5, 0, JUSTIFICATION_CENTER, "Program File Missing"); 00156 } 00157 00158 fscanf(programFile, "%d", &numberofprograms); 00159 DEBUG1("numberofprograms=%d", numberofprograms); 00160 00161 for (int progamIx = 0; progamIx < numberofprograms; ++progamIx) { 00162 DEBUG1("progamIx=%d", progamIx); 00163 00164 for (int paramIx = 0; paramIx < 5; ++paramIx) { 00165 fscanf(programFile, "%f", &pgm[progamIx][paramIx]); 00166 DEBUG1("paramIx=%d programParameter=%f", paramIx, pgm[progamIx][paramIx]); 00167 } 00168 00169 /* Saving number of seconds. */ 00170 pgm[progamIx][2] *= 60; 00171 } 00172 00173 fclose(programFile); 00174 } 00175 #endif 00176 00177 void experimentPrepareDefinedProgram(void) 00178 { 00179 static char dataname[PATH_TO_FILE_LEN]; 00180 00181 DEBUG1("Salinity = %d", Salinity); 00182 00183 calculateStartTime(); 00184 #ifdef USE_WIFI 00185 pumpSetRpm(MeasurementFlow); 00186 #else 00187 pumpSet(MeasurementFlow); 00188 #endif 00189 // create the filename to write 00190 getFileName(); 00191 DEBUG1("create name"); 00192 00193 if (MeasurementTypeVal == R) { 00194 MeasurementLight = 0; 00195 } 00196 00197 sprintf(dataname, "%s%s", "/" FSNAME "/Data/", FileName); 00198 00199 DEBUG1("datename %s", dataname); 00200 00201 currentFile = fopen(dataname, "w"); 00202 00203 switch (MeasurementTypeVal) { 00204 case R: 00205 lightSet(LIGHT_OFF_INTENSITY); 00206 fprintf(currentFile, "Respiration Time: %d\n", minRESP); 00207 minEXPER = minRESP; 00208 minTOTAL = minEXPER; 00209 minMODE = minEXPER; 00210 mode = R; 00211 isModeSwitched = true; 00212 SwitchMode = 0; 00213 break; 00214 case P: 00215 lightSet(MeasurementLight); // turn on light 00216 fprintf(currentFile, "Photosynthesis Time: %d\n", minPHOTO); 00217 minEXPER = minPHOTO; 00218 minTOTAL = minEXPER; 00219 minMODE = minEXPER; 00220 mode = P; 00221 isModeSwitched = true; 00222 SwitchMode = 0; 00223 break; 00224 case RP: 00225 lightSet(LIGHT_OFF_INTENSITY); 00226 fprintf(currentFile, "Respiration Time: %d\n", minRESP); 00227 fprintf(currentFile, "Photosynthesis Time: %d\n", minPHOTO); 00228 minEXPER = minRESP + minPHOTO; 00229 minTOTAL = minEXPER; 00230 minMODE = minRESP; 00231 mode = R; 00232 isModeSwitched = false; 00233 SwitchMode = 0; 00234 lcdWrite(6, 0, JUSTIFICATION_ABSOLUTE, "3 - Change Mode"); 00235 break; 00236 case PR: 00237 lightSet(MeasurementLight);// turn on light 00238 fprintf(currentFile, "Respiration Time: %d\n", minRESP); 00239 fprintf(currentFile, "Photosynthesis Time: %d\n", minPHOTO); 00240 minEXPER = minRESP + minPHOTO; 00241 minTOTAL = minEXPER; 00242 minMODE = minPHOTO; 00243 mode = P; 00244 isModeSwitched = false; 00245 SwitchMode = 0; 00246 lcdWrite(6, 0, JUSTIFICATION_ABSOLUTE, "3 - Change Mode"); 00247 00248 minEXPER = minRESP + minPHOTO; 00249 break; 00250 00251 default: 00252 ERROR("Unknown experiment type=%d", MeasurementTypeVal); 00253 return; 00254 } 00255 00256 // write file header 00257 fprintf(currentFile, "Filename:%s\n", dataname); 00258 fprintf(currentFile, "Type: %d\n", MeasurementTypeVal + 1); 00259 fprintf(currentFile, "Flow Rate: %d\n", MeasurementFlow); 00260 fprintf(currentFile, "Light Level: %d\n", MeasurementLight); 00261 fprintf(currentFile, "Salinity: %d\n", Salinity); 00262 fprintf(currentFile, "Total Time: %d\n", minEXPER); 00263 00264 fprintf(currentFile, "O2 0 Phase: %2.2f\n", PhaseCal1); 00265 fprintf(currentFile, "O2 0 Temp: %2.2f\n", TempCal1); 00266 fprintf(currentFile, "O2 100 Phase: %2.2f\n", PhaseCal2); 00267 fprintf(currentFile, "O2 100 Temp: %2.2f\n", TempCal2); 00268 fprintf(currentFile, "O2 LED Current: %3.0f\n", LEDCurrent); 00269 fprintf(currentFile, "O2 Pressure Cal: %3.2f\n", PresCal); 00270 fprintf(currentFile, "Mode 0 = Light Off, Mode 1 = Light On \n"); 00271 fprintf(currentFile, "Mode, Time(m), Per. Sat. 02, O2 in uMol/kg, ISFET pH, ISFET Temp,, pH Sensor Voltage, ISFET Temp Sensor Voltage, Battery, Phase 02, Amplitude O2\n"); 00272 00273 lcdWrite(7, 0, JUSTIFICATION_ABSOLUTE, "4 - Stop"); 00274 } 00275 00276 bool experimentRunDefinedProgram(void) 00277 { 00278 static const char* expType[4] = {"R", "P", "R+P", "P+R"}; 00279 00280 float deltaTime; 00281 float TotalTimeRemaining = 0; 00282 int tremmin; 00283 int tremsec; 00284 int mremmin; 00285 int mremsec; 00286 float presensData[PRESENS_RES_LENGTH]; 00287 00288 float uMolO2 = 0; 00289 float PHASE; 00290 int Amplitude; 00291 float O2Float; 00292 00293 DEBUG1("Running experiment MeasurementTypeVal=%d, minRESP=%d, minPHOTO=%d", 00294 MeasurementTypeVal, minRESP, minPHOTO); 00295 00296 presensGetData(presensData); 00297 00298 Amplitude = presensData[0]; 00299 PHASE = presensData[1]; 00300 O2Float = presensData[2]; 00301 00302 // get amplitude and phase to store 00303 lcdWrite(0, 0, JUSTIFICATION_ABSOLUTE, "Run Exp"); 00304 lcdWrite(0, 11, JUSTIFICATION_ABSOLUTE, "Bat=%3.1f", batteryGet()); // Battery Voltage 00305 lcdWrite(1, 0, JUSTIFICATION_ABSOLUTE, "Type_%-3s", expType[MeasurementTypeVal]); 00306 lcdWrite(1, 11, JUSTIFICATION_ABSOLUTE, "pH_%3.2f", pHCorrected); 00307 00308 /* get time to make filename */ 00309 deltaTime = getDeltaTime(); 00310 uMolO2 = getO2InMicromole(O2Float); 00311 00312 TotalTimeRemaining = minTOTAL * 60 - deltaTime; // Total time remaining 00313 mtimeRemaining = minMODE * 60 - deltaTime; // Mode time remaining 00314 00315 /* Switch mode for R+P or P+R experiemnts type. */ 00316 if (isModeSwitched == false && 00317 (SwitchMode == 1 || mtimeRemaining <= 0)) { 00318 isModeSwitched = true; 00319 SwitchMode = 1; 00320 mode = (mode == R) ? P : R; 00321 minTOTAL = mode == P ? minPHOTO : minRESP; 00322 minMODE = minTOTAL; 00323 /* Reset start time, since we switched to next step. */ 00324 calculateStartTime(); 00325 00326 deltaTime = 0; 00327 TotalTimeRemaining = minTOTAL * 60 - deltaTime; 00328 mtimeRemaining = minMODE * 60 - deltaTime; 00329 00330 lightSet(mode == R ? LIGHT_OFF_INTENSITY : MeasurementLight); // turn on light 00331 // clean line with instruction for mode changing 00332 lcdClearLine(6); 00333 INFO("Mode switched: minRESP=%d deltaTime=%f. New mode %s", minRESP, deltaTime, expType[mode]); 00334 lcdWrite(7, 0, JUSTIFICATION_ABSOLUTE, "4 - Stop"); 00335 } 00336 00337 tremmin = TotalTimeRemaining / 60; 00338 tremsec = TotalTimeRemaining - tremmin * 60; 00339 mremmin = mtimeRemaining / 60; 00340 mremsec = mtimeRemaining - mremmin * 60; 00341 00342 lcdWrite(2, 0, JUSTIFICATION_ABSOLUTE, "Mode_%-3s", expType[mode]); 00343 lcdWrite(2, 11, JUSTIFICATION_ABSOLUTE, "Temp_%2.1f", (float)PHTEMP); 00344 lcdWrite(3, 0, JUSTIFICATION_ABSOLUTE, "T Time_%2d", minEXPER); 00345 lcdWrite(3, 11, JUSTIFICATION_ABSOLUTE, "%%O2_%3.2f", O2Float); 00346 lcdWrite(4, 0, JUSTIFICATION_ABSOLUTE, "T Rem_%2d:%-.2d", tremmin, tremsec); 00347 lcdWrite(4, 11, JUSTIFICATION_ABSOLUTE, "F_%3d", MeasurementFlow); 00348 lcdWrite(5, 0, JUSTIFICATION_ABSOLUTE, "M Rem_%2d:%-.2d", mremmin, mremsec); 00349 lcdWrite(5, 11, JUSTIFICATION_ABSOLUTE, "L_%3d", (mode == R? 0 : MeasurementLight)); 00350 00351 PRINT_RESULT_TO_FILE(mode, deltaTime, O2Float, uMolO2, PHASE, Amplitude); 00352 00353 NVIC_EnableIRQ(UART1_IRQn); 00354 00355 // this is where we switch to shut down 00356 if (TotalTimeRemaining <= 0) { 00357 return true; 00358 } 00359 00360 return false; 00361 } 00362 00363 void experimentPrepareUserProgram(void) 00364 { 00365 static char resultsFileName[PATH_TO_FILE_LEN] = {0}; 00366 00367 float presensData[PRESENS_RES_LENGTH]; 00368 float O2Float; 00369 00370 lightSet(LIGHT_OFF_INTENSITY); 00371 pumpSet(PUMP_OFF_INTENSITY); 00372 00373 // Create the filename to write 00374 getFileName(); 00375 00376 sprintf(resultsFileName, "%s%s", "/" FSNAME "/Data/", FileName); 00377 00378 DEBUG1("datename %s", resultsFileName); 00379 00380 currentFile = fopen(resultsFileName,"w"); 00381 // Write the header file if this is the first time this program is run 00382 fprintf(currentFile, "DeviceId:%s\r\n", instrumentId); 00383 fprintf(currentFile, "Filename:%s\r\n", resultsFileName); 00384 fprintf(currentFile, "pH Slope(m): %1.5f\n", MSINGLEPT); 00385 fprintf(currentFile, "pH Eo (b): %1.5f\n", EOSINGLEPT); 00386 fprintf(currentFile, "cal. Buffer pH: %1.5f\n", PHBUFFERF); 00387 fprintf(currentFile, "cal. Buffer temp. %1.5f\n", PHTEMPF); 00388 fprintf(currentFile, "Salinity: %d\n", Salinity); 00389 fprintf(currentFile, "O2 0 Phase: %1.5f\n", PhaseCal1); 00390 fprintf(currentFile, "O2 0 Temp: %1.5f\n", TempCal1); 00391 fprintf(currentFile, "O2 100 Phase: %1.5f\n", PhaseCal2); 00392 fprintf(currentFile, "O2 100 Temp: %1.5f\n", TempCal2); 00393 fprintf(currentFile, "O2 LED Current: %1.5f\n", LEDCurrent); 00394 fprintf(currentFile, "O2 Pressure Cal: %1.5f\n", PresCal); 00395 fprintf(currentFile, "Total number of steps: %d\n", numberofprograms); 00396 wait (0.3); 00397 00398 stepIx = 0; 00399 00400 calculateStartTime(); 00401 00402 presensGetData(presensData); 00403 O2Float = presensData[2]; 00404 00405 O2old = O2Float; 00406 phold = 1; /* In the old version it was 1 in the beggining. Probably this is error. */ 00407 00408 SwitchMode = 0; // instead of isGoToNextProgram 00409 00410 lightSet(pgm[stepIx][1]); 00411 #ifdef USE_WIFI 00412 pumpSetRpm(pgm[stepIx][0]); 00413 #else 00414 pumpSet(pgm[stepIx][0]); 00415 #endif 00416 00417 buzzerBeep(0.1); 00418 wait(0.2); 00419 buzzerBeep(0.1); 00420 wait(0.2); 00421 buzzerBeep(0.1); 00422 00423 fprintf(currentFile, "Step Number: %d\n", stepIx + 1); 00424 fprintf(currentFile, "Time Threshold: %3.0f\n",pgm[stepIx][2]); 00425 fprintf(currentFile, "O2 Threshold: %3.0f\n", pgm[stepIx][4]); 00426 fprintf(currentFile, "pH Threshold: %2.3f\n", pgm[stepIx][3]); 00427 fprintf(currentFile, "Flow Rate: %f\n", pgm[stepIx][0]); 00428 fprintf(currentFile, "Light Level: %f\n", pgm[stepIx][1]); 00429 fprintf(currentFile, "Step No., Time(m), Total T(m), O2 percent Sat., O2 (umol/kg), ISFET pH, ISFET Temp,, pH raw (V), ISFET Temp raw (V), Battery (V), Phase O2, Amplitude O2\n"); 00430 } 00431 00432 bool experimentRunUserProgram(void) 00433 { 00434 int TotalTimeRemaining; 00435 int AmplitudeInt; 00436 int tremmin; 00437 int tremsec; 00438 00439 float deltaTime; 00440 float O2Float; 00441 float O2thres; 00442 double phthres; 00443 float PHASEFloat; 00444 float presensData[PRESENS_RES_LENGTH]; 00445 float uMolO2; 00446 00447 deltaTime = getDeltaTime(); 00448 00449 TotalTimeRemaining = pgm[stepIx][2] - deltaTime; 00450 00451 DEBUG1("total time remaining %d", TotalTimeRemaining); 00452 presensGetData(presensData); 00453 00454 phthres = (pHCorrected - pgm[stepIx][3]) * (phold - pgm[stepIx][3]); 00455 phold = pHCorrected; 00456 00457 AmplitudeInt = presensData[0]; 00458 PHASEFloat = presensData[1]; 00459 O2Float = presensData[2]; 00460 DEBUG1("amp %d phase float %2.2f", AmplitudeInt, PHASEFloat); 00461 00462 O2thres = (O2Float - pgm[stepIx][4]) * (O2old - pgm[stepIx][4]); 00463 O2old = O2Float; 00464 00465 tremmin = TotalTimeRemaining / 60; 00466 tremsec = TotalTimeRemaining - tremmin * 60; 00467 00468 if (SwitchMode == 1 || /* switching because user push button. */ 00469 TotalTimeRemaining <= 0 || phthres < 0 || O2thres < 0) { /* legacy switch conditions. */ 00470 lcdClear(); 00471 00472 DEBUG1("Switching step: SwitchMode=%d TotalTimeRemaining=%4.0f phthres=%f O2thres=%f" 00473 "switch in cases: SwitchMode==1 time<=0 phthres<0, O2thres<0", 00474 SwitchMode, TotalTimeRemaining, phthres, O2thres); 00475 stepIx++; 00476 SwitchMode = 0; 00477 00478 if (stepIx >= numberofprograms) { 00479 /* The last step was finished. */ 00480 return true; 00481 } 00482 00483 INFO("going to step stepIx=%d", stepIx); 00484 00485 calculateStartTime(); 00486 deltaTime = 0; 00487 TotalTimeRemaining = pgm[stepIx][2] - deltaTime; 00488 00489 tremmin = TotalTimeRemaining / 60; 00490 tremsec = TotalTimeRemaining - tremmin * 60; 00491 00492 lightSet(pgm[stepIx][1]); 00493 #ifdef USE_WIFI 00494 pumpSetRpm(pgm[stepIx][0]); 00495 #else 00496 pumpSet(pgm[stepIx][0]); 00497 #endif 00498 00499 buzzerBeep(0.1); 00500 wait(0.2); 00501 buzzerBeep(0.1); 00502 wait(0.2); 00503 buzzerBeep(0.1); 00504 00505 fprintf(currentFile, "Step Number: %d\n", stepIx + 1); 00506 fprintf(currentFile, "Time Threshold: %3.0f\n",pgm[stepIx][2]); 00507 fprintf(currentFile, "O2 Threshold: %3.0f\n", pgm[stepIx][4]); 00508 fprintf(currentFile, "pH Threshold: %2.3f\n", pgm[stepIx][3]); 00509 fprintf(currentFile, "Flow Rate: %f\n", pgm[stepIx][0]); 00510 fprintf(currentFile, "Light Level: %f\n", pgm[stepIx][1]); 00511 fprintf(currentFile, "Step No., Time(m), Total T(m), 02 percent sat., O2 umol/kg, ISFET pH, ISFET Temp,, pH raw (V), ISFET raw Temp (V), Ext. Battery (V), Phase O2, Amplitude O2\n"); 00512 } 00513 00514 lcdWrite(0, 0, JUSTIFICATION_ABSOLUTE, "Step# %2d Bat_%3.1f", stepIx + 1, batteryGet()); 00515 lcdWrite(1, 0, JUSTIFICATION_ABSOLUTE, "T Rem _ %2d:%-.2d %2.0f:00", tremmin, tremsec, pgm[stepIx][2] / 60); 00516 lcdWrite(2, 0, JUSTIFICATION_ABSOLUTE, "%%a.s O2_%3.2f %2.2f", O2Float, pgm[stepIx][4]); 00517 lcdWrite(3, 0, JUSTIFICATION_ABSOLUTE, "pH_%3.3f %2.3f", pHCorrected, pgm[stepIx][3]); 00518 lcdWrite(4, 0, JUSTIFICATION_ABSOLUTE, " T_C _ %2.3f", PHTEMP); 00519 lcdWrite(5, 0, JUSTIFICATION_ABSOLUTE, " F - %3d L - %3d", (int)pgm[stepIx][0], (int)pgm[stepIx][1]); 00520 lcdWrite(6, 0, JUSTIFICATION_ABSOLUTE, "3 - Next Program Step"); 00521 lcdWrite(7, 0, JUSTIFICATION_ABSOLUTE, "4 - Stop"); 00522 00523 uMolO2 = getO2InMicromole(O2Float); 00524 00525 wifiEventsSendDataExpInd(stepIx + 1, TotalTimeRemaining, pHCorrected, O2Float, batteryGet(), PHTEMP); 00526 PRINT_RESULT_TO_FILE(stepIx+1, deltaTime, O2Float, uMolO2, PHASEFloat, AmplitudeInt); 00527 00528 wait(.1); 00529 00530 NVIC_EnableIRQ(UART1_IRQn); 00531 00532 return false; 00533 } 00534 00535 void finishExperiment(void) 00536 { 00537 if (MeasurementTypeVal == PGM) { 00538 buzzerBeep(0.7); 00539 wait(0.2); 00540 buzzerBeep(0.7); 00541 wait(0.2); 00542 buzzerBeep(0.7); 00543 00544 /* Clen up filePrefix. It will be new, if user will want this. */ 00545 memset(FilePrefix, 0, FILE_PREFIX_LENGTH); 00546 } 00547 00548 /* Experiment finilisation. */ 00549 lightSet(LIGHT_OFF_INTENSITY); 00550 pumpSet(PUMP_OFF_INTENSITY); 00551 00552 fclose(currentFile); 00553 00554 }
Generated on Tue Sep 27 2022 18:47:00 by
1.7.2