Updated with option to return from BP screen to main screen, resolved screen navigation issues
Dependencies: SDFileSystem TFTLCD_8bit ds3231 program mbed
Fork of poc_dis_5 by
Diff: glc.cpp
- Revision:
- 4:6bd81bb1790d
- Parent:
- 2:3b7b71bfc941
- Child:
- 5:a3ea7c82b7e1
diff -r 9a06c2bed650 -r 6bd81bb1790d glc.cpp --- a/glc.cpp Fri Feb 10 10:39:13 2017 +0000 +++ b/glc.cpp Wed Mar 01 18:49:33 2017 +0000 @@ -22,10 +22,10 @@ AnalogIn Ain(PTC1);//Electrode one AnalogIn Ain2(PTE29); // Electrode two AnalogOut DAC_signal(PTE30); -//Serial gc(USBTX, USBRX); +Serial gtc(USBTX, USBRX); //unsigned char c; //unsigned char HOME = 0; -unsigned char GLC_START = 0; + //signed char test_strip = 0; unsigned int mgdl = 0; unsigned int mgdll = 0; @@ -41,6 +41,8 @@ Serial ble(PTC4,PTC3); + + void sample() { @@ -61,13 +63,12 @@ } + + void Compute() { - //datafinal1 = data1; - // unsigned char check; - //osTimerStop(id2); - //osTimerStop(id1); + datafinal1 = (unsigned int) NUMB1*(data2*VREF/(TOTAL))-NUMB2; datafinal2 = (unsigned int) NUMB1*(daata1*VREF/(TOTAL))-NUMB2; mgdl = (unsigned int) NUMB1*(((daata1+data2)/2)*VREF/(TOTAL))-NUMB2; @@ -77,8 +78,7 @@ { glc_4(mgdl); - - sd_write(mgdl); + sd_write(mgdl); // storing value into the sd card sd_close(); ble.printf("blood glucose is %d mg/dl", mgdl); flipper.detach(); @@ -86,6 +86,7 @@ // return mgdl; } + else { // lcd1.Print( " ERROR RESULT", 5,220,COLOR_RED,COLOR_BLACK, 0); @@ -96,11 +97,6 @@ } -void T_S_detect(void) -{ - GLC_START = 1; - //st_strip=1; -} @@ -118,23 +114,24 @@ void glc(int pid){ + unsigned char GLC_START = 0; char t_s_d = 0; - i2c_spec(); - GLC_START = 1; - ble.baud(115200); -if(GLC_START == 1) + i2c_spec(); + GLC_START = 1; + // ble.baud(115200); + if(GLC_START == 1) { //DisableTouch(); //gpo_t = 0; //lcd1.FillRect(5,127,230,320,COLOR_BLACK); - glc_1(); + glc_1(); // displaying messages to insert the test strip err = 0; data1n = 0; data2n = 0; daata1 = 0; data2 = 0; - sd_open_GLCfile(pid); + sd_open_GLCfile(pid); // opening the glc file while((test_strip)); @@ -142,22 +139,21 @@ // wait(500); // Shutdown = 1; - if (!test_strip) + if (!test_strip) // checks for the presence of test strip { - flipper.attach(&sample, 0.8); + flipper.attach(&sample, 0.8); t_s_d = 0; - glc_2(); - //gc.printf("%d\n", data1n); - - while((!t_s_d) && (!test_strip)) + glc_2(); // displaying message to insert blood + + while((!t_s_d) && (!test_strip)) { - + // gtc.printf("%d\n", data1n); if ((daata1 >= THRESHOLD) || (data2 >= THRESHOLD)) { t_s_d = 1; - flipper1.attach(&Compute, 2.25); + flipper1.attach(&Compute, 2.25); //computing the glucose level glc_3();