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.
main.cpp
00001 #include "mbed.h" 00002 #include "cisme.h" 00003 #include "keys.h" 00004 #include "lcd.h" 00005 #include "lcd_events.h" 00006 #include "wifi_events.h" 00007 #include "wifi.h" 00008 #include "MSCFileSystem.h" 00009 #include "debug.h" 00010 #include "pump.h" 00011 #include "light.h" 00012 #include "buzzer.h" 00013 #include "presens.h" 00014 #include "adc.h" 00015 #include "experiments.h" 00016 00017 MSCFileSystem msc(FSNAME); 00018 00019 int Salinity = 36; 00020 double PHTEMP = 0.0; 00021 double pH = 0.0; 00022 double pHCorrected = 0.0; 00023 float pHT = 0.0; 00024 int flowintime = 0; 00025 int lightintime = 0; 00026 int minRESP = 0; 00027 int minPHOTO = 0; 00028 int MeasurementFlow = 0; 00029 int MeasurementLight = 0; 00030 int MeasurementTypeVal = 0; 00031 int mtimeRemaining = 0; 00032 // a, b and c variables are used for example in file lcd_events.c in function phCal in fprintf. 00033 float a = 0.0; 00034 float b = 2.8; 00035 float c = 0.0; 00036 float PresCal = 1.0; 00037 float PhaseCal2 = 1.0; 00038 float TempCal2 = 1.0; 00039 float PhaseCal1 = 1.0; 00040 float TempCal1 = 1.0; 00041 float LEDCurrent = 150.0; 00042 float UNIT = 0; 00043 float PHBUFFERF = 0.0; 00044 float PHTEMPF = 0.0; 00045 float PHTEMPKF = 0.0; 00046 float PHVOLTSF = 0.0; 00047 float MSINGLEPT = 0.0; 00048 float EOSINGLEPT = 0.0; 00049 int numberofprograms = 0; 00050 float pHNoGain = 0.0; 00051 float A = 0.0; 00052 float B = 0.0; 00053 float C = 0.0; 00054 float D = 0.0; 00055 00056 char instrumentId[INSTRUMENT_ID_LEN] = "C1"; 00057 00058 DigitalOut L1(LED1); 00059 DigitalOut L2(LED2); 00060 DigitalOut L3(LED3); 00061 DigitalOut L4(LED4); 00062 00063 // Configure Analog Input 00064 DigitalIn SDOFlag(p8); 00065 00066 00067 /******************************************************************************\ 00068 ** main 00069 \******************************************************************************/ 00070 int main() 00071 { 00072 FILE *paramFile; 00073 FILE *isFetFile; 00074 00075 int DebugFlag = 0; 00076 00077 debugInit(DEBUG_LEVEL_INFO); 00078 SDOFlag.mode(OpenDrain); 00079 buzzerInit(); 00080 00081 L1 = 0; 00082 L2 = 0; 00083 L3 = 0; 00084 L4 = 0; 00085 00086 presensInit(); 00087 lcdInit(); 00088 00089 lcdEventSplash(); 00090 00091 opendir("/" FSNAME); 00092 00093 isFetFile = fopen("/" FSNAME "/Parameters/isfet.sys","r"); 00094 00095 if (isFetFile == NULL) { 00096 lcdClear(); 00097 ERROR("Could not open file for write /" FSNAME "/Parameters/isfet.sys"); 00098 lcdWrite(4, 0, JUSTIFICATION_CENTER, "isfet File Missing"); 00099 ADD_START_ERROR(ERROR_MISSED_ISFET); 00100 } else { 00101 fscanf(isFetFile, "%f,%f,%f,%f", &A, &B, &C, &D); 00102 fclose(isFetFile); 00103 } 00104 00105 // Read default parameters from file 00106 paramFile = fopen("/" FSNAME "/Parameters/dsparams.sys", "r"); 00107 00108 if (paramFile == NULL) { 00109 lcdClear(); 00110 lcdWrite(4, 0, JUSTIFICATION_CENTER, "Dsprams File Missing"); 00111 ERROR("Dsparams file missing."); 00112 ADD_START_ERROR(ERROR_MISSED_DSPARAMS); 00113 } else { 00114 fscanf(paramFile, "%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%d", 00115 &a, &b, &c, &PresCal, &PhaseCal2, &TempCal2, &PhaseCal1, 00116 &TempCal1, &LEDCurrent, &PHBUFFERF, &PHTEMPF, &PHTEMPKF, 00117 &PHVOLTSF, &MSINGLEPT, &EOSINGLEPT, &UNIT, &DebugFlag); 00118 fclose(paramFile); 00119 } 00120 00121 debugSetLvl(DebugFlag); 00122 INFO("Debug level set to %s", debugFormatTraceLevel(DebugFlag)); 00123 00124 DEBUG1("Debug Mode active: A=%F, B=%F, C=%F, D=%F, a=%F, b=%F, c=%F", 00125 A, B, C, D, a, b, c); 00126 00127 readUserPrograms(); 00128 00129 pumpInit(); 00130 lightInit(); 00131 00132 L1=1; 00133 00134 adcInit(); 00135 00136 DEBUG2("PHBUFFERF=%2.6f, PHTEMPF=%2.6f, PHTEMPKF=%2.6f, PHVOLTSF=%2.6f, MSINGLEPT=%2.6f, EOSINGLEPT=%2.6f", 00137 PHBUFFERF, PHTEMPF, PHTEMPKF, PHVOLTSF, MSINGLEPT, EOSINGLEPT); 00138 DEBUG2("PresCal=%2.6f, PhaseCal2=%2.6f, TempCal2=%2.6f, PhaseCal1=%2.6f, TempCal1=%2.6f, LEDCurrent=%2.6f", 00139 PresCal, PhaseCal2, TempCal2, PhaseCal1, TempCal1, LEDCurrent); 00140 00141 wait(.3); 00142 00143 presensConfig(LEDCurrent); 00144 00145 L2=1; 00146 00147 MeasurementTypeVal = 1; 00148 MeasurementFlow = 0; 00149 MeasurementLight = 0; 00150 00151 L3=1; 00152 00153 wifiInit(); 00154 00155 INFO("Done startup. Enter event loop"); 00156 00157 // Go to main event loop 00158 lcdEventsStart(); 00159 wifiEventsStart(); 00160 }
Generated on Tue Sep 27 2022 18:47:00 by
1.7.2