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.
Dependencies: mbed
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.5f,%c,%2.2f,%2.1f,%2.4f,%2.2f,%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, "pH Vo (buffer): %1.5f\n", PHVOLTSF); 00388 fprintf(currentFile, "cal. Buffer temp. %1.5f\n", PHTEMPF); 00389 fprintf(currentFile, "Salinity: %d\n", Salinity); 00390 fprintf(currentFile, "O2 0 Phase: %1.5f\n", PhaseCal1); 00391 fprintf(currentFile, "O2 0 Temp: %1.5f\n", TempCal1); 00392 fprintf(currentFile, "O2 100 Phase: %1.5f\n", PhaseCal2); 00393 fprintf(currentFile, "O2 100 Temp: %1.5f\n", TempCal2); 00394 fprintf(currentFile, "O2 LED Current: %1.5f\n", LEDCurrent); 00395 fprintf(currentFile, "O2 Pressure Cal: %1.5f\n", PresCal); 00396 fprintf(currentFile, "Total number of steps: %d\n", numberofprograms); 00397 wait (0.1); 00398 00399 stepIx = 0; 00400 00401 calculateStartTime(); 00402 00403 presensGetData(presensData); 00404 O2Float = presensData[2]; 00405 00406 O2old = O2Float; 00407 phold = 1; /* In the old version it was 1 in the beggining. Probably this is error. */ 00408 00409 SwitchMode = 0; // instead of isGoToNextProgram 00410 00411 lightSet(pgm[stepIx][1]); 00412 #ifdef USE_WIFI 00413 pumpSetRpm(pgm[stepIx][0]); 00414 #else 00415 pumpSet(pgm[stepIx][0]); 00416 #endif 00417 00418 buzzerBeep(0.1); 00419 wait(0.2); 00420 buzzerBeep(0.1); 00421 wait(0.2); 00422 buzzerBeep(0.1); 00423 00424 fprintf(currentFile, "Step Number: %d\n", stepIx + 1); 00425 fprintf(currentFile, "Time Threshold: %3.0f\n",pgm[stepIx][2]); 00426 fprintf(currentFile, "O2 Threshold: %3.0f\n", pgm[stepIx][4]); 00427 fprintf(currentFile, "pH Threshold: %2.3f\n", pgm[stepIx][3]); 00428 fprintf(currentFile, "Flow Rate: %f\n", pgm[stepIx][0]); 00429 fprintf(currentFile, "Light Level: %f\n", pgm[stepIx][1]); 00430 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"); 00431 } 00432 00433 bool experimentRunUserProgram(void) 00434 { 00435 int TotalTimeRemaining; 00436 int AmplitudeInt; 00437 int tremmin; 00438 int tremsec; 00439 00440 float deltaTime; 00441 float O2Float; 00442 float O2thres; 00443 double phthres; 00444 float PHASEFloat; 00445 float presensData[PRESENS_RES_LENGTH]; 00446 float uMolO2; 00447 00448 deltaTime = getDeltaTime(); 00449 00450 TotalTimeRemaining = pgm[stepIx][2] - deltaTime; 00451 00452 DEBUG1("total time remaining %d", TotalTimeRemaining); 00453 presensGetData(presensData); 00454 00455 phthres = (pHCorrected - pgm[stepIx][3]) * (phold - pgm[stepIx][3]); 00456 phold = pHCorrected; 00457 00458 AmplitudeInt = presensData[0]; 00459 PHASEFloat = presensData[1]; 00460 O2Float = presensData[2]; 00461 DEBUG1("amp %d phase float %2.2f", AmplitudeInt, PHASEFloat); 00462 00463 O2thres = (O2Float - pgm[stepIx][4]) * (O2old - pgm[stepIx][4]); 00464 O2old = O2Float; 00465 00466 tremmin = TotalTimeRemaining / 60; 00467 tremsec = TotalTimeRemaining - tremmin * 60; 00468 00469 if (SwitchMode == 1 || /* switching because user push button. */ 00470 TotalTimeRemaining <= 0 || phthres < 0 || O2thres < 0) { /* legacy switch conditions. */ 00471 lcdClear(); 00472 00473 DEBUG1("Switching step: SwitchMode=%d TotalTimeRemaining=%4.0f phthres=%f O2thres=%f" 00474 "switch in cases: SwitchMode==1 time<=0 phthres<0, O2thres<0", 00475 SwitchMode, TotalTimeRemaining, phthres, O2thres); 00476 stepIx++; 00477 SwitchMode = 0; 00478 00479 if (stepIx >= numberofprograms) { 00480 /* The last step was finished. */ 00481 return true; 00482 } 00483 00484 INFO("going to step stepIx=%d", stepIx); 00485 00486 calculateStartTime(); 00487 deltaTime = 0; 00488 TotalTimeRemaining = pgm[stepIx][2] - deltaTime; 00489 00490 tremmin = TotalTimeRemaining / 60; 00491 tremsec = TotalTimeRemaining - tremmin * 60; 00492 00493 lightSet(pgm[stepIx][1]); 00494 #ifdef USE_WIFI 00495 pumpSetRpm(pgm[stepIx][0]); 00496 #else 00497 pumpSet(pgm[stepIx][0]); 00498 #endif 00499 00500 buzzerBeep(0.1); 00501 wait(0.2); 00502 buzzerBeep(0.1); 00503 wait(0.2); 00504 buzzerBeep(0.1); 00505 00506 fprintf(currentFile, "Step Number: %d\n", stepIx + 1); 00507 fprintf(currentFile, "Time Threshold: %3.0f\n",pgm[stepIx][2]); 00508 fprintf(currentFile, "O2 Threshold: %3.0f\n", pgm[stepIx][4]); 00509 fprintf(currentFile, "pH Threshold: %2.3f\n", pgm[stepIx][3]); 00510 fprintf(currentFile, "Flow Rate: %f\n", pgm[stepIx][0]); 00511 fprintf(currentFile, "Light Level: %f\n", pgm[stepIx][1]); 00512 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"); 00513 } 00514 00515 lcdWrite(0, 0, JUSTIFICATION_ABSOLUTE, "Step# %2d Bat_%3.1f", stepIx + 1, batteryGet()); 00516 lcdWrite(1, 0, JUSTIFICATION_ABSOLUTE, "T Rem _ %2d:%-.2d %2.0f:00", tremmin, tremsec, pgm[stepIx][2] / 60); 00517 lcdWrite(2, 0, JUSTIFICATION_ABSOLUTE, "%%a.s O2_%3.2f %2.2f", O2Float, pgm[stepIx][4]); 00518 lcdWrite(3, 0, JUSTIFICATION_ABSOLUTE, "pH_%3.3f %2.3f", pHCorrected, pgm[stepIx][3]); 00519 lcdWrite(4, 0, JUSTIFICATION_ABSOLUTE, " T_C _ %2.3f", PHTEMP); 00520 lcdWrite(5, 0, JUSTIFICATION_ABSOLUTE, " F - %3d L - %3d", (int)pgm[stepIx][0], (int)pgm[stepIx][1]); 00521 lcdWrite(6, 0, JUSTIFICATION_ABSOLUTE, "3 - Next Program Step"); 00522 lcdWrite(7, 0, JUSTIFICATION_ABSOLUTE, "4 - Stop"); 00523 00524 uMolO2 = getO2InMicromole(O2Float); 00525 00526 wifiEventsSendDataExpInd(stepIx + 1, TotalTimeRemaining, pHCorrected, O2Float, batteryGet(), PHTEMP); 00527 PRINT_RESULT_TO_FILE(stepIx+1, deltaTime, O2Float, uMolO2, PHASEFloat, AmplitudeInt); 00528 00529 wait(.1); 00530 00531 NVIC_EnableIRQ(UART1_IRQn); 00532 00533 return false; 00534 } 00535 00536 void finishExperiment(void) 00537 { 00538 if (MeasurementTypeVal == PGM) { 00539 buzzerBeep(0.7); 00540 wait(0.2); 00541 buzzerBeep(0.7); 00542 wait(0.2); 00543 buzzerBeep(0.7); 00544 00545 /* Clen up filePrefix. It will be new, if user will want this. */ 00546 memset(FilePrefix, 0, FILE_PREFIX_LENGTH); 00547 } 00548 00549 /* Experiment finilisation. */ 00550 lightSet(LIGHT_OFF_INTENSITY); 00551 pumpSet(PUMP_OFF_INTENSITY); 00552 00553 fclose(currentFile); 00554 00555 }
Generated on Fri Sep 23 2022 19:29:17 by
1.7.2