
Modification into 17th July New display demo code
Dependencies: SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217
Fork of Ext_Demo_17July2017_newdis by
Revision 4:6bd81bb1790d, committed 2017-03-01
- Comitter:
- nikitateggi
- Date:
- Wed Mar 01 18:49:33 2017 +0000
- Parent:
- 3:9a06c2bed650
- Child:
- 5:a3ea7c82b7e1
- Commit message:
- POC code with eeprom
Changed in this revision
--- a/display_modules.cpp Fri Feb 10 10:39:13 2017 +0000 +++ b/display_modules.cpp Wed Mar 01 18:49:33 2017 +0000 @@ -7,7 +7,7 @@ //#include "main.h" -BusOut dataBus( PTC12, PTC13, PTB10, PTC9, PTD4, PTD5, PTD6, PTD7 ); // 16 pins//POC +BusOut dataBus( PTC12, PTC13, PTB10, PTC9, PTD4, PTD5, PTD6, PTD7 ); // 16 pins//POC DISPALY 240*320 pixels ILI9325_LCD lcd( PTC5, PTB9, PTC0, PTB0, &dataBus, NC, PTE31); @@ -16,14 +16,14 @@ lcd.Initialize(PORTRAIT); } - void screen_main()//main screen + void screen_main() //main screen { char buff1[32]; time_t epoch_time; lcd.ClearScreen(); lcd.SetFont(&TerminusFont); - epoch_time=rtc_read(); - sprintf(buff1 ,"%s", ctime(&epoch_time)); + epoch_time=rtc_read(); // read the time from rtc module + sprintf(buff1 ,"%s", ctime(&epoch_time)); // display time on LCD lcd.Print( buff1,20,100,COLOR_YELLOW,COLOR_BLACK, 0); lcd.SetFont(&TerminusBigFont); lcd.Print( "SENSESEMI",50,20,COLOR_WHITE,COLOR_BLACK, 0); @@ -36,21 +36,23 @@ } - void screen_main_2(int pid)//main screen + + + void screen_main_2(int pid) // test main screen { char buff2[10]; lcd.FillRect(5,10,250,120,COLOR_BLACK); //lcd.Print( "SenseSmart", CENTER, 95); - sprintf(buff2 ,"%d", pid); - lcd.Print( "PATIENT ID",20,50,COLOR_YELLOW,COLOR_BLACK, 0); - lcd.Print(buff2,200,50,COLOR_YELLOW,COLOR_BLACK, 0); + sprintf(buff2 ,"%d", pid); + lcd.Print( "PATIENT ID",20,50,COLOR_YELLOW,COLOR_BLACK, 0); + lcd.Print(buff2,200,50,COLOR_YELLOW,COLOR_BLACK, 0); lcd.SetFont(&TerminusBigFont); // lcd.FillRect(5,120,230,320,COLOR_BLACK); - lcd.FillRoundRect(60,130,180,200,COLOR_BLACK); - lcd.FillRoundRect(60,230,180,300,COLOR_BLACK); + lcd.FillRoundRect(60,130,180,200,COLOR_BLACK); + lcd.FillRoundRect(60,230,180,300,COLOR_BLACK); lcd.FillRoundRect(10,130,100,200,COLOR_CYAN); lcd.Print( "BG",40,160,COLOR_BLACK,COLOR_CYAN,0); lcd.FillRoundRect(130,130,220,200,COLOR_YELLOW); @@ -64,7 +66,7 @@ - void screen_main_1()//main screen + void screen_main_1() // System Configuration main screen { lcd.SetFont(&TerminusBigFont); @@ -81,19 +83,17 @@ } -void screen_ecg() + void screen_ecg() //ECG screen 1 { // lcd.FillRect(5,127,230,320,COLOR_BLACK); - - lcd.FillRoundRect(10,130,100,200,COLOR_BLACK); - lcd.FillRoundRect(130,130,220,200,COLOR_BLACK); - lcd.FillRoundRect(10,215,100,285,COLOR_BLACK); - lcd.FillRoundRect(130,215,220,285,COLOR_BLACK); - - lcd.FillRoundRect(60,130,180,200,COLOR_YELLOW); - lcd.Print( "START",80,150,COLOR_BLACK,COLOR_YELLOW,0); - // lcd.Print( "CONFIG",70,170,COLOR_BLACK,COLOR_YELLOW,0); + lcd.FillRoundRect(10,130,100,200,COLOR_BLACK); + lcd.FillRoundRect(130,130,220,200,COLOR_BLACK); + lcd.FillRoundRect(10,215,100,285,COLOR_BLACK); + lcd.FillRoundRect(130,215,220,285,COLOR_BLACK); + lcd.FillRoundRect(60,130,180,200,COLOR_YELLOW); + lcd.Print( "START",80,150,COLOR_BLACK,COLOR_YELLOW,0); + // lcd.Print( "CONFIG",70,170,COLOR_BLACK,COLOR_YELLOW,0); lcd.FillRoundRect(60,230,180,300,COLOR_GREEN); lcd.Print( "RET",100,250,COLOR_BLACK,COLOR_GREEN,0); @@ -101,49 +101,52 @@ - void screen_ecg_2() + void screen_ecg_2() // ECG screen 2 { - lcd.FillRect(5,90,230,150,COLOR_BLACK); - lcd.Print( " Tst is Done ",3,150,COLOR_GREEN,COLOR_BLACK,0); + lcd.FillRect(5,90,230,150,COLOR_BLACK); + lcd.Print( " Tst is Done ",3,100,COLOR_GREEN,COLOR_BLACK,0); + lcd.Print( " HeartRate ",3,150,COLOR_GREEN,COLOR_BLACK,0); + lcd.Print( " 72 bpm",3,180,COLOR_CYAN,COLOR_BLACK,0); // lcd.Print( "DONE", CENTER, 95); - // lcd.Print( "s Done ",80,150,COLOR_GREEN,COLOR_BLACK,0); - lcd.FillRect(10,215,230,290,COLOR_BLACK); + // lcd.Print( "s Done ",80,150,COLOR_GREEN,COLOR_BLACK,0); + lcd.FillRect(10,215,230,290,COLOR_BLACK); // lcd.FillRoundRect(10,215,100,285,COLOR_MAGENTA); // lcd.FillRoundRect(130,215,220,285,COLOR_GREEN); - lcd.FillRoundRect(60,230,180,300,COLOR_GREEN); - lcd.Print( "RET",100,250,COLOR_BLACK,COLOR_GREEN,0); + lcd.FillRoundRect(60,230,180,300,COLOR_GREEN); + lcd.Print( "RET",100,250,COLOR_BLACK,COLOR_GREEN,0); } - void screen_bp() // bp main screen + void screen_bp() // BP main screen { - lcd.FillRoundRect(10,130,100,200,COLOR_BLACK); - lcd.FillRoundRect(130,130,220,200,COLOR_BLACK); - lcd.FillRoundRect(10,215,100,285,COLOR_BLACK); - lcd.FillRoundRect(130,215,220,285,COLOR_BLACK); - - lcd.FillRoundRect(60,130,180,200,COLOR_YELLOW); - lcd.Print( "START",80,150,COLOR_BLACK,COLOR_YELLOW,0); - // lcd.Print( "CONFIG",70,170,COLOR_BLACK,COLOR_YELLOW,0); - lcd.FillRoundRect(60,230,180,300,COLOR_GREEN); - lcd.Print( "RET",100,250,COLOR_BLACK,COLOR_GREEN,0); + lcd.FillRoundRect(10,130,100,200,COLOR_BLACK); + lcd.FillRoundRect(130,130,220,200,COLOR_BLACK); + lcd.FillRoundRect(10,215,100,285,COLOR_BLACK); + lcd.FillRoundRect(130,215,220,285,COLOR_BLACK); + lcd.FillRoundRect(60,130,180,200,COLOR_YELLOW); + lcd.Print( "START",80,150,COLOR_BLACK,COLOR_YELLOW,0); + // lcd.Print( "CONFIG",70,170,COLOR_BLACK,COLOR_YELLOW,0); + lcd.FillRoundRect(60,230,180,300,COLOR_GREEN); + lcd.Print( "RET",100,250,COLOR_BLACK,COLOR_GREEN,0); } - void screen_bp1(float SBP, float DBP) // bp main screen + + void screen_bp1(float SBP, float DBP) // BP screen 2 { + + char buf[10]; lcd.FillRoundRect(3,130,200,200,COLOR_BLACK); - lcd.FillRoundRect(60,230,180,300,COLOR_BLACK); - char buf[10]; - sprintf (buf, "SBP: %f",SBP); - lcd.Print( buf, 5,100,COLOR_CYAN,COLOR_BLACK, 0); - sprintf (buf, "DBP: %f",DBP); - lcd.Print( buf, 5,150,COLOR_CYAN,COLOR_BLACK, 0); - lcd.FillRoundRect(60,230,180,300,COLOR_GREEN); - lcd.Print( "RET",100,250,COLOR_BLACK,COLOR_GREEN,0); + lcd.FillRoundRect(60,230,180,300,COLOR_BLACK); + sprintf (buf, "SBP: %f",SBP); + lcd.Print( buf, 5,100,COLOR_CYAN,COLOR_BLACK, 0); + sprintf (buf, "DBP: %f",DBP); + lcd.Print( buf, 5,150,COLOR_CYAN,COLOR_BLACK, 0); + lcd.FillRoundRect(60,230,180,300,COLOR_GREEN); + lcd.Print( "RET",100,250,COLOR_BLACK,COLOR_GREEN,0); } @@ -155,109 +158,104 @@ //lcd.FillRect(5,127,230,320,COLOR_BLACK); // lcd.FillRect(5,127,230,320,COLOR_BLACK); - lcd.FillRoundRect(10,130,100,200,COLOR_BLACK); - lcd.FillRoundRect(130,130,220,200,COLOR_BLACK); - lcd.FillRoundRect(10,215,100,285,COLOR_BLACK); - lcd.FillRoundRect(130,215,220,285,COLOR_BLACK); - lcd.FillRoundRect(60,130,180,200,COLOR_YELLOW); - lcd.Print( "START",80,150,COLOR_BLACK,COLOR_YELLOW,0); - lcd.FillRoundRect(60,230,180,300,COLOR_GREEN); - lcd.Print( "RET",100,250,COLOR_BLACK,COLOR_GREEN,0); + lcd.FillRoundRect(10,130,100,200,COLOR_BLACK); + lcd.FillRoundRect(130,130,220,200,COLOR_BLACK); + lcd.FillRoundRect(10,215,100,285,COLOR_BLACK); + lcd.FillRoundRect(130,215,220,285,COLOR_BLACK); + lcd.FillRoundRect(60,130,180,200,COLOR_YELLOW); + lcd.Print( "START",80,150,COLOR_BLACK,COLOR_YELLOW,0); + lcd.FillRoundRect(60,230,180,300,COLOR_GREEN); + lcd.Print( "RET",100,250,COLOR_BLACK,COLOR_GREEN,0); } - void screen_bp2() + + void screen_bp2() //BP screen 3 { - lcd.FillRoundRect(3,130,200,200,COLOR_BLACK); lcd.FillRoundRect(60,230,180,300,COLOR_BLACK); lcd.FillRect(5,215,230,290,COLOR_BLACK); - } - void ecg_countdown() + void ecg_countdown() // ECG measurement countdown { char tim1[5]; // lcd.DrawRect(20,90,90,40,COLOR_BLACK); // lcd.FillRect(5,127,230,320,COLOR_BLACK); - lcd.FillRoundRect(3,130,200,200,COLOR_BLACK); - lcd.FillRoundRect(60,230,180,300,COLOR_BLACK); - lcd.FillRect(5,215,230,290,COLOR_BLACK); - lcd.Print( "ECG starts in", CENTER, 95); - for(int i=5;i>=0;i--) + lcd.FillRoundRect(3,130,200,200,COLOR_BLACK); + lcd.FillRoundRect(60,230,180,300,COLOR_BLACK); + lcd.FillRect(5,215,230,290,COLOR_BLACK); + lcd.Print( "ECG starts in", CENTER, 95); + for(int i=5;i>=0;i--) { wait(1); sprintf (tim1, "%d",i); lcd.Print( tim1,120,120,COLOR_YELLOW,COLOR_BLACK, 0); - } - lcd.Print( "Tst in Progres",3,150,COLOR_GREEN,COLOR_BLACK,0); + + lcd.Print( "Tst in Progres",3,150,COLOR_GREEN,COLOR_BLACK,0); } - void screen_again() + void screen_again() // screen to press 'yes' or 'no' to repeat the test { //lcd.DrawRect(20,90,90,40,COLOR_BLACK); - lcd.FillRect(5,127,230,200,COLOR_BLACK); - lcd.Print( "Take test",50,130 ,COLOR_CYAN,COLOR_BLACK, 0); - lcd.Print( "again?",75,160 ,COLOR_CYAN,COLOR_BLACK, 0); - lcd.Print( "YES",30,245,COLOR_BLACK,COLOR_MAGENTA,0); - - lcd.Print( " NO ",150,245,COLOR_BLACK,COLOR_GREEN,0); + lcd.FillRect(5,127,230,200,COLOR_BLACK); + lcd.Print( "Take test",50,130 ,COLOR_CYAN,COLOR_BLACK, 0); + lcd.Print( "again?",75,160 ,COLOR_CYAN,COLOR_BLACK, 0); + lcd.Print( "YES",30,245,COLOR_BLACK,COLOR_MAGENTA,0); + lcd.Print( " NO ",150,245,COLOR_BLACK,COLOR_GREEN,0); //lcd.FillRect(5 ,127,230,200,COLOR_BLACK); } - void screen_glc_2() + void screen_glc_2() // GLC screen 3 after test { lcd.FillRect(5,127,230,320,COLOR_BLACK); - - - lcd.FillRoundRect(60,230,180,300,COLOR_GREEN); - lcd.Print( "RET",100,250,COLOR_BLACK,COLOR_GREEN,0); - + lcd.FillRoundRect(60,230,180,300,COLOR_GREEN); + lcd.Print( "RET",100,250,COLOR_BLACK,COLOR_GREEN,0); } - void glc_1() + + void glc_1() // GLC screen { - //lcd.ClearScreen(); - // lcd.DrawRect(20,90,90,40,COLOR_BLACK); - // lcd.FillRect(5,127,230,320,COLOR_BLACK); lcd.FillRoundRect(3,130,200,200,COLOR_BLACK); lcd.FillRoundRect(60,230,180,300,COLOR_BLACK); lcd.FillRect(5,215,230,290,COLOR_BLACK); - lcd.Print( "BLOOD GLUCOSE",20,130 ,COLOR_CYAN,COLOR_BLACK, 0); // align text to center horizontally and use starndard colors - lcd.Print( "Insert strip",5,160,COLOR_MAGENTA,COLOR_BLACK, 0); // align text to center horizontally and use starndard colors + lcd.Print( "BLOOD GLUCOSE",20,130 ,COLOR_CYAN,COLOR_BLACK, 0); // align text to center horizontally and use starndard colors + lcd.Print( "Insert strip",5,160,COLOR_MAGENTA,COLOR_BLACK, 0); // align text to center horizontally and use starndard colors } - void glc_2() + void glc_2() // GLC screen { lcd.Print( "Strip Detected",5,160, COLOR_GREEN,COLOR_BLACK, 0); lcd.Print( "Insert Blood",5,190,COLOR_RED,COLOR_BLACK, 0); } - void glc_3() + + void glc_3() // GLC screen { lcd.Print( "Blood Detected",5,190,COLOR_GREEN,COLOR_BLACK, 0); lcd.Print( "computing", 5,220,COLOR_MAGENTA,COLOR_BLACK, 0); } - void glc_4(unsigned int mgdl) + + void glc_4(unsigned int mgdl) // GLC screen to display blood glucose level on the LCD { - lcd.FillRect(5,127,230,320,COLOR_BLACK); + lcd.FillRect(5,127,230,320,COLOR_BLACK); char buf[10]; - sprintf (buf, "BG is %d mg/dl",mgdl); + sprintf (buf, " BG %d mg/dl",mgdl); lcd.Print( buf, 5,100,COLOR_YELLOW,COLOR_BLACK, 0); } \ No newline at end of file
--- a/display_modules.h Fri Feb 10 10:39:13 2017 +0000 +++ b/display_modules.h Wed Mar 01 18:49:33 2017 +0000 @@ -16,7 +16,9 @@ void glc_2(); void glc_3(); void glc_4(unsigned int mgdl); - void screen_again(); - void screen_glc_2(); - void screen_bp1(float SBP, float DBP) ; +void screen_again(); +void screen_glc_2(); +void screen_bp1(float SBP, float DBP) ; + + #endif
--- a/ecgg.cpp Fri Feb 10 10:39:13 2017 +0000 +++ b/ecgg.cpp Wed Mar 01 18:49:33 2017 +0000 @@ -25,23 +25,21 @@ Timer t; unsigned char chk = 1; pc.baud(baud_rate); - freqset(); - setupfunc(); + freqset(); // setting the frequency + setupfunc(); ecgsetupfunc(); chk = 1; - // t.start(); - sd_open_ECGfile(pid); + sd_open_ECGfile(pid); // opening the ecg file for(int i=0; i<N_ECG; i++) { concatenate_value2= readvalue(); - sd_write(concatenate_value2); + sd_write(concatenate_value2); // writing into the sd card pc.printf( "%d\n", concatenate_value2); } - sd_close(); - // t.stop(); - // printf( "%f\n", t.read()); + sd_close(); // closing the file + } // End of main function
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eeprom.lib Wed Mar 01 18:49:33 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/SenseSemi/code/program/#4707b0a9acaa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eeprom_pgm.cpp Wed Mar 01 18:49:33 2017 +0000 @@ -0,0 +1,27 @@ +#include "mbed.h" +#include "eeprom.h" +#include "eeprom_pgm.h" + +#include <stdio.h> +Serial ec(USBTX, USBRX); // tx, rx +EEPROM rom(PTC11, PTC10, 0x00, EEPROM::T24C32); + + + + +void eprom_write(uint32_t address, int8_t data) +{ + rom.write(address ,data); // write data into the address + +} + + + + +int eprom_read(uint32_t address) // readng the data from the specified address +{ + int8_t rdata; + rom.read(address, rdata); + ec.printf("Read back value=%u\n", rdata); + return rdata; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eeprom_pgm.h Wed Mar 01 18:49:33 2017 +0000 @@ -0,0 +1,8 @@ +#ifndef EEPROM_PGM_H_ +#define EEPROM_PGM_H_ + + +void eprom_write(uint32_t address, int8_t data); +int eprom_read(uint32_t address); + +#endif
--- 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();
--- a/i2c_dec.cpp Fri Feb 10 10:39:13 2017 +0000 +++ b/i2c_dec.cpp Wed Mar 01 18:49:33 2017 +0000 @@ -1,13 +1,13 @@ #include "mbed.h" -#define ADDR 0x70 +#define ADDR 0x70 // address of the I2C void i2c_spec() { -I2C i2c(PTC11, PTC10); + I2C i2c(PTC11, PTC10); char dat[1]; - i2c.start(); - dat[0]=0xBB; - i2c.write(ADDR,dat,1); - i2c.stop(); + i2c.start(); + dat[0]=0xBB; + i2c.write(ADDR,dat,1); + i2c.stop(); } \ No newline at end of file
--- a/main.cpp Fri Feb 10 10:39:13 2017 +0000 +++ b/main.cpp Wed Mar 01 18:49:33 2017 +0000 @@ -8,7 +8,7 @@ #include "glc.h" #include "bp.h" #include "sdcard.h" - +#include "eeprom_pgm.h" Serial gc(USBTX, USBRX); @@ -44,9 +44,9 @@ while(1) { - detect_touch(); // detrmine the touch points + detect_touch(); // determine the touch points - switch(state) + switch(state) // state for touch { case 1: state1=touch_main(); // determining the touch for main screen state=0; @@ -54,43 +54,43 @@ break; case 2: - state1=touch_main_1(); // determining the touch for glc screen + state1=touch_main_1(); // determining the touch for SYSTEM CONFIGURATION screen state=0; nstate1=state1; break; case 3: - state1=touch_main_2(); - // determining the touch for ecg screen + state1=touch_main_2(); //// determining the touch for TEST screen + state=0; nstate1=state1; break; case 4: - state1=touch_glc(); // determining the touch for bp screen + state1=touch_glc(); // determining the touch for GLC screen state=0; nstate1=state1; break; case 5: - state1=touch_ecg(); // determining the touch for bp screen + state1=touch_ecg(); // determining the touch for ECG screen state=0; nstate1=state1; break; - case 6: - state1=touch_ret(); // determining the touch for bp screen + case 6: + state1=touch_ret(); // determining the touch for returning back to the main screen state=0; nstate1=state1; break; - case 7: - state1=touch_again(); // determining the touch for bp screen + case 7: + state1=touch_again(); // determining the touch when readings are taken more than once screen state=0; nstate1=state1; break; case 8: - state1=touch_bp(); // determining the touch for bp screen + state1=touch_bp(); // determining the touch for BP screen state=0; nstate1=state1; break; @@ -103,7 +103,7 @@ state=nstate; break; - default : DisableTouch(); + default : DisableTouch(); wait_ms(300); EnableTouch(); state=nstate; @@ -115,29 +115,23 @@ - switch(state1) + switch(state1) // state for display screens { - - case 0: - DisableTouch(); - wait_ms(300); - state=nstate; - EnableTouch(); - break; + case 1: DisableTouch(); - screen_main(); // glc main screen + screen_main(); // main screen state1=0; state=1; nstate=state; flag=0; - ecg_flag=0; + ecg_flag=0; // ecg, glc flag to determine whether the readings are taken more than once glc_flag=0; EnableTouch(); break; case 2: DisableTouch(); - screen_main_1(); // glc main screen + screen_main_1(); // System configration screen state1=0; state=2; nstate=state; @@ -147,19 +141,22 @@ case 3: DisableTouch(); if (flag==0) { - pid=pid+1; + //pid=pid+1; + pid=eprom_read(1); // reading the patient id from eeprom + pid=pid+1; + eprom_write(1,pid); // writing the patient id to eeprom screen_main_2(pid); - sd_open_GLCfilee(pid); + sd_open_GLCfilee(pid); // only opening the glc,bp and ecg file sd_close(); sd_open_ECGfilee(pid); sd_close(); - sd_open_BPfile(pid); + sd_open_BPfilee(pid); sd_close(); flag=1; } else { - screen_main_2(pid); + screen_main_2(pid); // TEST screen } state1=0; @@ -169,15 +166,15 @@ break; case 4: DisableTouch(); - if (glc_flag==1) + if (glc_flag==1) // glc_flag=1 when already the reading has been taken { - screen_again(); //bp main screen + screen_again(); state1=0; state=7; nstate=state; } else - { screen_glc(); + { screen_glc(); // glc screen state1=0; state=4; nstate=state; @@ -198,7 +195,7 @@ else { - screen_ecg(); //bp main screen + screen_ecg(); //ecg main screen state1=0; state=5; nstate=state; @@ -207,7 +204,7 @@ break; case 6: DisableTouch(); - screen_bp(); + screen_bp(); // bp main screen EnableTouch(); state1=0; state=8; @@ -217,49 +214,43 @@ - case 7: DisableTouch(); - glc(pid); - - + case 7: DisableTouch(); + glc(pid); // glc measurement glc_flag=1; wait(5); - // glc_4(mgdll); - state1=0; - screen_glc_2(); - - state=6;; + state1=0; + screen_glc_2(); + state=6;; // gc.printf("%d", state); EnableTouch(); break; case 8: DisableTouch(); - - ecg_countdown(); - ecg(pid); + ecg_countdown(); // countdown before ecg capture + ecg(pid); // capturing ecg state1=0; screen_ecg_2(); state=6; nstate=state; ecg_flag=1; - - // ble.printf("ecg"); - EnableTouch(); + // ble.printf("ecg"); + EnableTouch(); break; - case 9: + /*case 9: DisableTouch(); - screen_glc_2(); - state1=0; + screen_glc_2(); + state1=0; state=6; nstate=state; EnableTouch(); - break; + break;*/ case 11: DisableTouch(); - screen_bp2(); - bp(); + screen_bp2(); // bp main screen + bp(); // measuring bp state1=0; // wait(1); state=6;
--- a/rtc.cpp Fri Feb 10 10:39:13 2017 +0000 +++ b/rtc.cpp Wed Mar 01 18:49:33 2017 +0000 @@ -5,18 +5,13 @@ - - time_t rtc_read() { Ds3231 rtc(PTC11, PTC10); - - time_t epoch_time1; - //char buff1[10]; + time_t epoch_time1; epoch_time1 = rtc.get_epoch(); - // sprintf(buff1 ,"%s", ctime(&epoch_time1)); - return epoch_time1; + + return epoch_time1; // return the time - - } \ No newline at end of file +} \ No newline at end of file
--- a/sdcard.cpp Fri Feb 10 10:39:13 2017 +0000 +++ b/sdcard.cpp Wed Mar 01 18:49:33 2017 +0000 @@ -8,7 +8,7 @@ SDFileSystem sd(PTE1, PTE3, PTE2, PTE4, "sd"); FILE *fp=NULL; - void sd_open_GLCfile(int pid) + void sd_open_GLCfile(int pid) // opening the glc file { char buffer[32]; @@ -17,29 +17,26 @@ epoch_time1=rtc_read(); // strftime(buffer, 32, "GLC_%s", pid); - sprintf(buffer1,"/sd/%d_GLC.csv",pid); + sprintf(buffer1,"/sd/%d_GLC.csv",pid); fp = fopen(buffer1,"a"); - fprintf(fp,"%s\n",ctime(&epoch_time1) ); + fprintf(fp,"%s\n",ctime(&epoch_time1) ); //writing the date, time into the file } - void sd_open_GLCfilee(int pid) + void sd_open_GLCfilee(int pid) // only opening the glc file after entering TEST screen { - char buffer[32]; + char buffer1[32]; - time_t epoch_time1; - epoch_time1=rtc_read(); - // strftime(buffer, 32, "GLC_%s", pid); - - sprintf(buffer1,"/sd/%d_GLC.csv",pid); + sprintf(buffer1,"/sd/%d_GLC.csv",pid); fp = fopen(buffer1,"a"); fprintf(fp,"PATIENT ID %d\n",pid); } - void sd_open_ECGfile(int pid) + + void sd_open_ECGfile(int pid) { // char buffer[32]; @@ -51,26 +48,21 @@ sprintf(buffer1,"/sd/%d_ECG.csv",pid); fp = fopen(buffer1,"a"); fprintf(fp,"%s\n",ctime(&epoch_time1) ); - // strftime(buffer, 32, "ECG_%d-%m-%Y_%H_%M",localtime(&epoch_time1)); - // fprintf(fp,"%d\n",buffer ); + } - void sd_open_ECGfilee(int pid) + void sd_open_ECGfilee(int pid) // only opening the ECG file after entering TEST screen { - // char buffer[32]; char buffer1[32]; - time_t epoch_time1; - epoch_time1=rtc_read(); - // strftime(buffer, 32, "ECG_%d", pid); - - sprintf(buffer1,"/sd/%d_ECG.csv",pid); + sprintf(buffer1,"/sd/%d_ECG.csv",pid); fp = fopen(buffer1,"a"); fprintf(fp,"PATIENT ID %d\n",pid ); - // strftime(buffer, 32, "ECG_%d-%m-%Y_%H_%M",localtime(&epoch_time1)); - // fprintf(fp,"%d\n",buffer ); + } - void sd_open_BPfile(int pid) + + + void sd_open_BPfile(int pid) { char buffer[32]; @@ -84,15 +76,24 @@ fprintf(fp,"%s\n",ctime(&epoch_time1) ); } - +void sd_open_BPfilee(int pid) // only opening the BP file after entering TEST screen + { + - void sd_write (int value) + char buffer1[32]; + sprintf(buffer1,"/sd/%d_BP.csv",pid); + fp = fopen(buffer1,"a"); + fprintf(fp,"PATIENT ID %d\n",pid ); + + } + + void sd_write (int value) // writing data into the file { fprintf(fp,"%d\n", value); } - void sd_close() + void sd_close() //closing the file { fclose(fp); }
--- a/sdcard.h Fri Feb 10 10:39:13 2017 +0000 +++ b/sdcard.h Wed Mar 01 18:49:33 2017 +0000 @@ -5,6 +5,7 @@ void sd_open_ECGfilee(int pid); void sd_open_GLCfile(int pid); void sd_open_GLCfilee(int pid); +void sd_open_BPfilee(int pid); void sd_open_BPfile(int pid); void sd_write (int value); void sd_close();
--- a/touch_modules.cpp Fri Feb 10 10:39:13 2017 +0000 +++ b/touch_modules.cpp Wed Mar 01 18:49:33 2017 +0000 @@ -11,13 +11,12 @@ void touch1() //determining the touch co-ordinates -{ - xt = (X_MAX*readTouchX()/TOTAL1); + { + xt = (X_MAX*readTouchX()/TOTAL1); yt = (Y_MAX*readTouchY()/TOTAL1); kc.printf("%d\n", xt); kc.printf("%d\n", yt); - - } + } void detect_touch() // detect the touch //debounce @@ -68,7 +67,7 @@ } -unsigned char touch_main_1() //determining the touch for home screen +unsigned char touch_main_1() //determining the touch for System Configuration screen { unsigned char state; @@ -101,7 +100,8 @@ return state; } -unsigned char touch_main_2() //determining the touch for home screen + + unsigned char touch_main_2() //determining the touch for TEST screen { unsigned char state; @@ -130,7 +130,7 @@ } else - state=10; + state=10; // default - goes to wait for a valid touch return state; } @@ -140,17 +140,17 @@ -unsigned char touch_ecg() // determining the touch for ecg screen +unsigned char touch_ecg() // determining the touch for ecg main screen { unsigned char state; - if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // GLC + if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // START { state=8; } - else if ( ((xt >=70) && (xt<=170)) && ( (yt>=90) && (yt<=140) ) ) // ECG + else if ( ((xt >=70) && (xt<=170)) && ( (yt>=90) && (yt<=140) ) ) // RETURN { // state=2; } @@ -161,13 +161,13 @@ } -unsigned char touch_ret() // determining the touch for ecg screen +unsigned char touch_ret() // determining the touch for ecg screen after the test { unsigned char state; - if ( ((xt >=70) && (xt<=170)) && ( (yt>=85) && (yt<=140) ) ) // ECG + if ( ((xt >=70) && (xt<=170)) && ( (yt>=85) && (yt<=140) ) ) // press on return box { state=3; } @@ -180,17 +180,17 @@ -unsigned char touch_bp() // //determining the touch for bp screen +unsigned char touch_bp() // //determining the touch for bp main screen { unsigned char state; - if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // GLC + if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // START { state=11; } - else if ( ((xt >=70) && (xt<=170)) && ( (yt>=90) && (yt<=140) ) ) // ECG + else if ( ((xt >=70) && (xt<=170)) && ( (yt>=90) && (yt<=140) ) ) // RETURN { // state=2; } @@ -202,17 +202,17 @@ -unsigned char touch_glc() ////determining the touch for home screen + unsigned char touch_glc() //determining the touch for GLC screen { unsigned char state; - if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // GLC + if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // START { state=7; } - else if ( ((xt >=70) && (xt<=170)) && ( (yt>=85) && (yt<=140) ) ) // ECG + else if ( ((xt >=70) && (xt<=170)) && ( (yt>=85) && (yt<=140) ) ) // RETURN { // state=2; } @@ -224,17 +224,17 @@ - unsigned char touch_again() //determining the touch for home screen + unsigned char touch_again() //determining the touch for Repeat test { unsigned char state; - if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // BP + if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // YES { state=8; } - else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // SET + else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // NO { state=3; @@ -247,9 +247,10 @@ - + //TOUCH Functionalities// -int readTouchY(void) { +int readTouchY(void) // read the Y co-ordinate +{ DigitalOut YD(PTD6); DigitalIn XL(PTD7); DigitalOut YU(PTC0); @@ -260,7 +261,9 @@ return XR.read_u16(); } -int readTouchX(void) { + +int readTouchX(void) // // read the X co-ordinate +{ DigitalOut XR(PTB0); DigitalIn YD(PTD6); DigitalOut XL(PTD7); @@ -272,7 +275,8 @@ return YU.read_u16(); } -void EnableTouch(void){ +void EnableTouch(void) // Enable touch +{ DigitalIn YD(PTD6); DigitalOut XL(PTD7); @@ -282,12 +286,14 @@ YD.mode(PullUp); YU.mode(PullNone); XR.mode(PullNone); - i=1; + i=1; Touch_D.fall(&touch1); Touch_D.enable_irq(); - } -void DisableTouch (void){ + } + +void DisableTouch (void) // Disable touch +{ Touch_D.disable_irq(); i=0; DigitalOut YD(PTD6);