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
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 //float lastPercentPump = 45.0; 00056 00057 char instrumentId[INSTRUMENT_ID_LEN] = "C1"; 00058 00059 DigitalOut L1(LED1); 00060 DigitalOut L2(LED2); 00061 DigitalOut L3(LED3); 00062 DigitalOut L4(LED4); 00063 00064 // Configure Analog Input 00065 DigitalIn SDOFlag(p8); 00066 00067 00068 /******************************************************************************\ 00069 ** main 00070 \******************************************************************************/ 00071 int main() 00072 { 00073 FILE *paramFile; 00074 FILE *isFetFile; 00075 00076 int DebugFlag = 0; 00077 00078 debugInit(DEBUG_LEVEL_INFO); 00079 SDOFlag.mode(OpenDrain); 00080 buzzerInit(); 00081 00082 L1 = 0; 00083 L2 = 0; 00084 L3 = 0; 00085 L4 = 0; 00086 00087 presensInit(); 00088 lcdInit(); 00089 00090 lcdEventSplash(); 00091 00092 opendir("/" FSNAME); 00093 00094 isFetFile = fopen("/" FSNAME "/Parameters/isfet.sys","r"); 00095 00096 if (isFetFile == NULL) { 00097 lcdClear(); 00098 ERROR("Could not open file for write /" FSNAME "/Parameters/isfet.sys"); 00099 lcdWrite(4, 0, JUSTIFICATION_CENTER, "isfet File Missing"); 00100 ADD_START_ERROR(ERROR_MISSED_ISFET); 00101 } else { 00102 fscanf(isFetFile, "%f,%f,%f,%f", &A, &B, &C, &D); 00103 fclose(isFetFile); 00104 } 00105 00106 // Read default parameters from file 00107 paramFile = fopen("/" FSNAME "/Parameters/dsparams.sys", "r"); 00108 00109 if (paramFile == NULL) { 00110 lcdClear(); 00111 lcdWrite(4, 0, JUSTIFICATION_CENTER, "Dsprams File Missing"); 00112 ERROR("Dsparams file missing."); 00113 ADD_START_ERROR(ERROR_MISSED_DSPARAMS); 00114 } else { 00115 fscanf(paramFile, "%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%d", 00116 &a, &b, &c, &PresCal, &PhaseCal2, &TempCal2, &PhaseCal1, 00117 &TempCal1, &LEDCurrent, &PHBUFFERF, &PHTEMPF, &PHTEMPKF, 00118 &PHVOLTSF, &MSINGLEPT, &EOSINGLEPT, &UNIT, &DebugFlag); 00119 fclose(paramFile); 00120 } 00121 00122 debugSetLvl(DebugFlag); 00123 INFO("Debug level set to %s", debugFormatTraceLevel(DebugFlag)); 00124 00125 DEBUG1("Debug Mode active: A=%F, B=%F, C=%F, D=%F, a=%F, b=%F, c=%F", 00126 A, B, C, D, a, b, c); 00127 00128 readUserPrograms(); 00129 00130 pumpInit(); 00131 lightInit(); 00132 00133 L1=1; 00134 00135 adcInit(); 00136 00137 DEBUG2("PHBUFFERF=%2.6f, PHTEMPF=%2.6f, PHTEMPKF=%2.6f, PHVOLTSF=%2.6f, MSINGLEPT=%2.6f, EOSINGLEPT=%2.6f", 00138 PHBUFFERF, PHTEMPF, PHTEMPKF, PHVOLTSF, MSINGLEPT, EOSINGLEPT); 00139 DEBUG2("PresCal=%2.6f, PhaseCal2=%2.6f, TempCal2=%2.6f, PhaseCal1=%2.6f, TempCal1=%2.6f, LEDCurrent=%2.6f", 00140 PresCal, PhaseCal2, TempCal2, PhaseCal1, TempCal1, LEDCurrent); 00141 00142 wait(0.3); 00143 00144 presensConfig(LEDCurrent); 00145 00146 L2=1; 00147 00148 MeasurementTypeVal = 1; 00149 MeasurementFlow = 0; 00150 MeasurementLight = 0; 00151 00152 L3=1; 00153 00154 wifiInit(); 00155 00156 L4=1; 00157 // L1=0; 00158 // L2=0; 00159 // L3=0; 00160 // wait(0.5); 00161 // L1=1; 00162 // L2=1; 00163 // L3=1; 00164 00165 buzzerBeep(0.2); 00166 wait(0.2); 00167 buzzerBeep(0.2); 00168 wait(0.2); 00169 buzzerBeep(0.2); 00170 wait(0.2); 00171 buzzerBeep(0.2); 00172 wait(0.2); 00173 00174 INFO("Done startup. Enter event loop"); 00175 00176 // Go to main event loop 00177 lcdEventsStart(); 00178 wifiEventsStart(); 00179 }
Generated on Fri Sep 23 2022 19:29:17 by
1.7.2