
Changes done in ECG and BT
Dependencies: SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217
Fork of merged_code2_20sept_2017_4th_oct_2017 by
Revision 1:8316c23ec6b9, committed 2017-01-30
- Comitter:
- nikitateggi
- Date:
- Mon Jan 30 07:45:41 2017 +0000
- Parent:
- 0:c47fb0c1bbf6
- Child:
- 2:3b7b71bfc941
- Commit message:
- POC code
Changed in this revision
--- a/display_modules.cpp Tue Dec 27 10:30:48 2016 +0000 +++ b/display_modules.cpp Mon Jan 30 07:45:41 2017 +0000 @@ -3,20 +3,54 @@ #include "lcd_base.h" #include "display_modules.h" #include "touch_modules.h" +#include "rtc.h" +#include "main.h" BusOut dataBus( PTC12, PTC13, PTB10, PTC9, PTD4, PTD5, PTD6, PTD7 ); // 16 pins//POC ILI9325_LCD lcd( PTC5, PTB9, PTC0, PTB0, &dataBus, NC, PTE31); -void init_screen() // initializing the screen -{ lcd.Initialize(PORTRAIT); -} + void init_screen() // initializing the screen + { + lcd.Initialize(PORTRAIT); + } void screen_main()//main screen { - lcd.SetFont(&TerminusBigFont); - lcd.FillRect(5,127,230,320,COLOR_BLACK); + char buff1[32]; + time_t epoch_time; + DisableTouch(); + lcd.ClearScreen(); + lcd.SetFont(&TerminusFont); + epoch_time=rtc_read(); + sprintf(buff1 ,"%s", ctime(&epoch_time)); + lcd.Print( buff1,20,100,COLOR_YELLOW,COLOR_BLACK, 0); + lcd.SetFont(&TerminusBigFont); + lcd.Print( "SENSESEMI",50,20,COLOR_WHITE,COLOR_BLACK, 0); + lcd.Print( "SenseSmart",45,60,COLOR_WHITE,COLOR_BLACK, 0);// align text to center horizontally and use starndard colors + lcd.FillRoundRect(60,130,180,200,COLOR_YELLOW); + lcd.Print( "SYS",100,140,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( "TEST",90,250,COLOR_BLACK,COLOR_GREEN,0); + EnableTouch(); + + } + + void screen_main_2(int pid)//main screen + { + + char buff2[10]; + DisableTouch(); + 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); + + lcd.SetFont(&TerminusBigFont); + lcd.FillRect(5,120,230,320,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); @@ -24,98 +58,157 @@ lcd.FillRoundRect(10,215,100,285,COLOR_MAGENTA); lcd.Print( "BP",40,245,COLOR_BLACK,COLOR_MAGENTA,0); lcd.FillRoundRect(130,215,220,285,COLOR_GREEN); - lcd.Print( "SET",160,245,COLOR_BLACK,COLOR_GREEN,0); - } + lcd.Print( "HOME",150,245,COLOR_BLACK,COLOR_GREEN,0); + EnableTouch(); + } + + + void screen_main_1()//main screen + { + DisableTouch(); + lcd.SetFont(&TerminusBigFont); + lcd.FillRect(5,127,230,320,COLOR_BLACK); + lcd.FillRoundRect(10,130,100,200,COLOR_CYAN); + lcd.Print( "BLE",30,160,COLOR_BLACK,COLOR_CYAN,0); + lcd.FillRoundRect(130,130,220,200,COLOR_YELLOW); + lcd.Print( "ERASE",140,160,COLOR_BLACK,COLOR_YELLOW,0); + lcd.FillRoundRect(10,215,100,285,COLOR_MAGENTA); + lcd.Print( "FILE",20,245,COLOR_BLACK,COLOR_MAGENTA,0); + lcd.FillRoundRect(130,215,220,285,COLOR_GREEN); + lcd.Print( "HOME",145,245,COLOR_BLACK,COLOR_GREEN,0); + EnableTouch(); + } void screen_ecg() { - DisableTouch(); - - lcd.ClearScreen(); - //lcd.FillScreen(COLOR_BLACK); - - - lcd.FillRect(5,127,230,320,COLOR_BLACK); - lcd.FillRect(10,30,100,90,COLOR_GREEN); - lcd.FillTriangle(10,30,60,10,100,30,COLOR_YELLOW); - lcd.DrawRect(20,90,90,40,COLOR_BLACK); - //lcd.Print( "HOME",80,60,COLOR_BLACK,COLOR_GREEN,0); - lcd.FillRoundRect(10,130,100,200,COLOR_CYAN); - lcd.Print( "SET",30,160,COLOR_BLACK,COLOR_CYAN,0); - lcd.FillRoundRect(130,130,220,285,COLOR_YELLOW); - lcd.Print( "start",140,200,COLOR_BLACK,COLOR_YELLOW,0); - lcd.FillRoundRect(10,215,100,285,COLOR_MAGENTA); - lcd.Print( "HIS",40,245,COLOR_BLACK,COLOR_MAGENTA,0); - EnableTouch(); - } + DisableTouch(); + lcd.FillRect(5,127,230,320,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); + EnableTouch(); + } + + + void screen_ecg_2() + { + DisableTouch(); + // lcd.FillRect(5,90,230,320,COLOR_BLACK); + // lcd.Print( "DONE", CENTER, 95); + lcd.FillRoundRect(60,230,180,300,COLOR_GREEN); + lcd.Print( "RET",100,250,COLOR_BLACK,COLOR_GREEN,0); + EnableTouch(); + } + + void screen_bp() // bp main screen { - DisableTouch(); - lcd.ClearScreen(); - // lcd.FillScreen(COLOR_BLACK); - lcd.FillRect(5,127,230,320,COLOR_BLACK); - lcd.FillRoundRect(10,130,100,200,COLOR_CYAN); - lcd.Print( "meas",30,160,COLOR_BLACK,COLOR_CYAN,0); - lcd.FillRoundRect(130,130,220,200,COLOR_YELLOW); - lcd.Print( "start",140,160,COLOR_BLACK,COLOR_YELLOW,0); - lcd.FillRoundRect(10,215,100,285,COLOR_MAGENTA); - lcd.Print( "his",40,245,COLOR_BLACK,COLOR_MAGENTA,0); - lcd.FillRoundRect(130,215,220,285,COLOR_GREEN); - lcd.Print( "SET",160,245,COLOR_BLACK,COLOR_GREEN,0); - - EnableTouch(); + DisableTouch(); + lcd.FillRect(5,127,230,320,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); + EnableTouch(); } - void screen_glc() // glc main screen + void screen_glc() // glc main screen { - DisableTouch(); - lcd.ClearScreen(); - // lcd.FillScreen(COLOR_BLACK); - lcd.FillRect(5,127,230,320,COLOR_BLACK); - lcd.FillRoundRect(10,130,100,200,COLOR_CYAN); - lcd.Print( "meas",30,160,COLOR_BLACK,COLOR_CYAN,0); - lcd.FillRoundRect(130,130,220,200,COLOR_YELLOW); - lcd.Print( "start",140,160,COLOR_BLACK,COLOR_YELLOW,0); - lcd.FillRoundRect(10,215,100,285,COLOR_MAGENTA); - lcd.Print( "his",40,245,COLOR_BLACK,COLOR_MAGENTA,0); - lcd.FillRoundRect(130,215,220,285,COLOR_GREEN); - lcd.Print( "SET",160,245,COLOR_BLACK,COLOR_GREEN,0); - - EnableTouch(); + DisableTouch(); + //lcd.FillRect(5,127,230,320,COLOR_BLACK); + lcd.FillRect(5,127,230,320,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); + EnableTouch(); } -void screen_ecg_2() // ecg second screen -{ + + + + void ecg_countdown() + { + char tim1[5]; DisableTouch(); + lcd.DrawRect(20,90,90,40,COLOR_BLACK); + lcd.FillRect(5,127,230,320,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); + + } + EnableTouch(); + } + + + + void screen_again() + { + DisableTouch(); + //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); + } + + + void screen_glc_2() + { + DisableTouch(); + lcd.FillRect(5,127,230,320,COLOR_BLACK); + - lcd.ClearScreen(); - // lcd.FillScreen(COLOR_BLACK); + lcd.FillRoundRect(60,230,180,300,COLOR_GREEN); + lcd.Print( "RET",100,250,COLOR_BLACK,COLOR_GREEN,0); + EnableTouch(); + } + + void glc_1() + { + DisableTouch(); + //lcd.ClearScreen(); + lcd.DrawRect(20,90,90,40,COLOR_BLACK); + lcd.FillRect(5,127,230,320,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 + } + + void glc_2() + { + DisableTouch(); + lcd.Print( "Strip Detected",5,160, COLOR_GREEN,COLOR_BLACK, 0); + lcd.Print( "Insert Blood",5,190,COLOR_RED,COLOR_BLACK, 0); + } - lcd.FillRect(10,30,100,90,COLOR_GREEN); - lcd.FillTriangle(10,30,60,10,100,30,COLOR_YELLOW); - lcd.DrawRect(20,90,90,40,COLOR_BLACK); - //lcd.FillRect(5,127,230,320,COLOR_BLACK); - //lcd.FillRect(60,30,170,90,COLOR_GREEN); - //lcd.FillTriangle(60,30,115,10,170,30,COLOR_YELLOW); - //lcd.DrawRect(90,90,140,40,COLOR_BLACK); - //lcd.Print( "HOME",80,60,COLOR_BLACK,COLOR_GREEN,0); - lcd.FillRoundRect(10,130,100,200,COLOR_CYAN); - lcd.Print( "2 s",30,160,COLOR_BLACK,COLOR_CYAN,0); - lcd.FillRoundRect(130,130,220,200,COLOR_YELLOW); - lcd.Print( "5 s",140,160,COLOR_BLACK,COLOR_YELLOW,0); - lcd.FillRoundRect(10,215,100,285,COLOR_MAGENTA); - lcd.Print( "10 s",40,245,COLOR_BLACK,COLOR_MAGENTA,0); - lcd.FillRoundRect(130,215,220,285,COLOR_GREEN); - lcd.Print( "1 m",160,245,COLOR_BLACK,COLOR_GREEN,0); - - EnableTouch(); - } - - - \ No newline at end of file + void glc_3() + { + DisableTouch(); + 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) + { + DisableTouch(); + lcd.FillRect(5,127,230,320,COLOR_BLACK); + char buf[10]; + sprintf (buf, "BG is %d mgdl",mgdl); + lcd.Print( buf, 5,100,COLOR_YELLOW,COLOR_BLACK, 0); + } \ No newline at end of file
--- a/display_modules.h Tue Dec 27 10:30:48 2016 +0000 +++ b/display_modules.h Mon Jan 30 07:45:41 2017 +0000 @@ -4,12 +4,18 @@ void screen_main();//main screen +void screen_main_1(); +void screen_main_2(int pid); void screen_ecg(); void screen_bp(); void screen_glc(); - void init_screen(); - void screen_ecg_2(); - - - -#endif \ No newline at end of file +void init_screen(); +void screen_ecg_2(); +void ecg_countdown(); +void glc_1(); +void glc_2(); +void glc_3(); +void glc_4(unsigned int mgdl); + void screen_again(); + void screen_glc_2(); +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ecg_dec.h Mon Jan 30 07:45:41 2017 +0000 @@ -0,0 +1,67 @@ + + +#ifndef ECG_DEC_H_ +#define ECG_DEC_H_ + +#include "mbed.h" +//#include "rtos.h" +#define PIN_MOSI PTA16 +#define PIN_MISO PTA17 +#define PIN_SCLK PTD1 +#define MA4_SIZE 4 // DO NOT CHANGE +//SDFileSystem sd(PTE1, PTE3, PTE2, PTE4, "sd"); + +//SPI commands +#define CMD_WAKEUP 0x02 +#define CMD_STANDBY 0x04 +#define CMD_RESET 0x06 +#define CMD_START 0x08 +#define CMD_STOP 0x0A +#define CMD_OFFSET_CAL 0x1A +#define CMD_RDATAC 0x10 +#define CMD_SDATAC 0x11 +#define CMD_RDATA 0x12 +//Note the following commands are 3 bits and have the following structure +// CMD_REGr_rrrr; where r_rrrr is the register address given below +#define CMD_WREG 0x02 +#define CMD_RREG 0x01 + +//SPI registers addresses, 5 bits width +#define REG_ID 0x00 +#define REG_CONFIG1 0x01 +#define REG_CONFIG2 0x02 +#define REG_LOFF 0x03 +#define REG_CH1SET 0x04 +#define REG_CH2SET 0x05 +#define REG_RLD_SENS 0x06 +#define REG_LOFF_SENS 0x07 +#define REG_LOFF_STAT 0x08 +#define REG_MISC1 0x09 +#define REG_MISC2 0x0A +#define REG_GIPO 0x0B + +//Register bit configurations +#define sps500 0x02 //CONFIG1 REG bits 010 +#define sps125 0x00 //CONFIG1 REG bits 000 +#define sps1k 0x03 //CONFIG1 REG bits 011 +#define no_mode 0xA8 //CONFIG2 REG set to zero for device check +#define test_mode 0xA3 //CONFIG2 REG bits set to test mode, to generate a square wave +#define default_mode 0xE0 //CONFIG2 REG bits set to default mode, to generate ECG signal from an external input +#define loff_conf 0xF0 //LOFF register bits set to F0 to configure LOFF reg for leadoff detection +#define offset_meas 0x01 //CH1SET REG set to Gain = 6 and offset measurement +#define test_inp 0x05 //CH1SET REG set to Gain = 6 and generate test signal +#define elec_inp 0x00 //CH1SET REG set to Gain = 6 and take in electrode input +#define rld_sens_sig 0x23 +#define loff_sens_sig 0x03 +#define misc1_inp 0x02 +#define misc2_inp 0x03 + +#define LSHIFT_8 8 //left shift the obtained 8bit data by 8 values +#define LSHIFT_16 16 ////left shift the obtained 8bit data by 16 values +#define N_ERR 100 +#define N_TEST 500 +#define N_ECG 2000 + +int ecg(int pid); + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ecgg.cpp Mon Jan 30 07:45:41 2017 +0000 @@ -0,0 +1,445 @@ +/** ECG ADS1291 Test program. +ADS1291 is a single channel ECG chip +with a 24 bit Sigma-Delta ADC + */ + +#include "mbed.h" +//#include "timer.h" +#include <string.h> +#include <stdio.h> +#include "ds3231.h" +#include "SDFileSystem.h" +#include "ecg_dec.h" +#include "rtc.h" +#include "sdcard.h" +//#include "rtos.h" + +//SPI SETTINGS +#define baud_rate 115200 +#define freq 1000000 +#define bits 8 +#define mode 1 +#define loop 1000000 + +//PIN DECLARATIONS +Serial pc(USBTX,USBRX); +DigitalIn DRDY_BAR(PTC8); +DigitalOut CHIPSEL_BAR(PTD0); +DigitalOut ADS_START(PTC16); +DigitalOut RESET_BAR(PTC17); + +//FILE *fp = NULL; + + +//unsigned char chk2= 0; +float value = 0; +unsigned int value1 = 0; +unsigned int value2 = 0; +unsigned int value3 = 0; +unsigned int value4 = 0; +unsigned int value5 = 0; +unsigned int value6 = 0; +unsigned int data1 = 0; +unsigned int count = 0; + +//static int32_t ecg_x[500]; +SPI mySpi(PIN_MOSI, PIN_MISO, PIN_SCLK) ; /* SPI is the spi function written in mbed and mySpi is the instance name*/ + +typedef void (*func_ptr)(void) ; /*creates typedef to function pointer, does not take any arguement and returns void*/ + +void doHelp(void) ; +void doStatus(void) ; +void doFreq(void) ; +void doMode(void) ; +void doBit(void) ; +void doWrite(void) ; +void doWrite2(void) ; +void doRead(void) ; +void doLoop(void) ; +void setup(void); +void testsetup(void); +void ecgsetup(void); +void regWrite(int,int); +void cmdWrite(int); +void regRead(int); +void lpf_coef(void); +float lpf( float coeff[5], float); +void drdy_int(void); +/*FILE *sd_openfile(char *buf); +void sd_write (FILE *n,int value); +void sd_close(FILE *n); +time_t rtc_read();*/ + +typedef struct _cmd_func { + char *name ; + func_ptr func ; +} cmd_func_type ; + +cmd_func_type cmd_list[] = { /*"cmd_func_type cmd_list[]" is same as "struct cmd_list[]"*/ + {"help", doHelp}, + {"status", doStatus}, + {"freq", doFreq}, + {"mode", doMode}, + {"bit", doBit}, + {"write", doWrite}, + {"read", doRead}, + {"loop", doLoop}, + { 0, 0 } +} ; + +func_ptr getFunc(char *cmd) /*here "func_ptr is same as void*/ +{ + int i = 0 ; + while(cmd_list[i].name != 0) { + if (strcmp(cmd, cmd_list[i].name) == 0) { + return(cmd_list[i].func) ; ; + } + i++ ; + } + return(0) ; +} + +void doHello() +{ + printf("=== spi test program ===\n\r") ; + printf("please set your terminal program\n\r") ; + printf("local echo on\n\r") ; + printf("\n\r") ; +} + +int ecg(int pid) { + //time_t epoch_time; + //int fp; + int concatenate_value = 0; + +//uint32_t ecg_buf[1500]; +//int32_t ecg_der[1500]; +//int buff1[15]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +int32_t sample_sum; // static int32_t avg[1500]; + count = 0; int32_t fs = 500; int32_t w=0,w1=0; +Timer t; + unsigned char chk = 1; + pc.baud(baud_rate); + mySpi.frequency(freq) ; + mySpi.format(bits, mode) ; + // Ds3231 rtc(PTC11, PTC10); //sda,scl2yy + + + + //Initialize ADS1291 + setup() ; + + //Put device back in RDATAC mode + cmdWrite(CMD_RDATAC) ; +// printf("The device is in RDATAC mode\n"); +//Activate conversion, At this point DRDY should toggle + ADS_START = 1; + + // printf( "ADC noise data is= \n"); + for(int i=0;i<N_ERR;i++) + { + while(DRDY_BAR); + doWrite() ; + //printf( "ADC status is= %X %X %X\n", value1,value2,value3); + concatenate_value = ((value4<< LSHIFT_16)|(value5 <<LSHIFT_8) |(value6)); + // printf( "%X\n", concatenate_value); + } + + + /*testsetup(); // To set the ADS1291 registers for internal test signal generation + wait(0.2); + cmdWrite(CMD_RDATAC) ; + //printf("The device is in RDATAC mode\n"); + // printf("Test data is\n"); + ADS_START = 1; + //printf("Test data is\n"); + sd_open_file(); + + for(int j=0;j<N_TEST;j++) + { + while(DRDY_BAR); + doWrite() ; + concatenate_value = ((value4<< LSHIFT_16)|(value5 <<LSHIFT_8) |(value6)); + + sd_write(concatenate_value); + pc.printf("%d\n",concatenate_value); + // fprintf(fp,"%d\n",concatenate_value) ; + } + sd_close();*/ + + ecgsetup(); // To set the ADS1291 registers for ECG signal generation +// printf("\n Reading****"); + //DRDY_BAR1.enable_irq(); + cmdWrite(CMD_RDATAC) ; +// printf("The device is in RDATAC mode\n"); + ADS_START = 1; + chk = 1; + t.start(); + sd_open_ECGfile(pid); + for(int i=0; i<N_ECG; i++) + { + while(DRDY_BAR); + doWrite() ; + concatenate_value = ((value4<< 16)|(value5 <<8) |(value6)); + sd_write(concatenate_value); + //printf( "%d\n", concatenate_value); + } + sd_close(); + t.stop(); + printf( "%f\n", t.read()); + /* + // remove DC of ecg signal + uint32_t ecg_mean=0, buf_length = 500; + printf("DC removed\ ECG Data\n"); + for (int k=0 ; k<buf_length ; k++ ) + {ecg_mean = ecg_mean+ ecg_buf[k] ; + /// printf("ecg_mean is %d\n",ecg_mean); + } + ecg_mean =ecg_mean/buf_length ; + //printf("ecg_mean is %d\n",ecg_mean); + for (k=0 ; k<buf_length ; k++ ) + { + ecg_x[k] = ecg_buf[k] - ecg_mean ; + printf("%d\n",(ecg_x[k])); + } + */ + // 4 pt Moving Average + /*printf("Averaged ECG Data\n"); + for(int k=0; k<N_ECG; k++) + { + // sample_sum= ( ecg_x[k]+ecg_x[k+1]+ ecg_x[k+2]+ ecg_x[k+3]); + sample_sum= ( ecg_buf[k]+ecg_buf[k+1]+ ecg_buf[k+2]+ ecg_buf[k+3]); + ecg_buf[k]= sample_sum/(int32_t)4; + +// printf("%d\n",(ecg_buf[k])); + } + + // Derivative filtering of the averaged ECG signal +// printf("Derivative filtered ECG Data\n"); + ecg_der[0]=0; + for(int k=0; k<N_ECG-3; k++) + { + w1= (fs*(ecg_buf[k+1]-ecg_buf[k])); + //w1=1; + // w=0.995; + // ecg_der[k]=(w+w1); + w=(1*ecg_der[k]); + ecg_der[k+1]=(w1+w); + // printf("ecg_der[k+1]=%d\n",(ecg_der[k+1])); + // printf("w=%f\n", w); + // printf("w1=%f\n", w1); + // printf("%d\n",(ecg_der[k])); + //printf("k=%d\n", k); + }*/ + } // End of main function + +//for initial configurations +void setup() +{ + //initially make all inputs low until power is up and stabilized + CHIPSEL_BAR = 0; + ADS_START = 0; + RESET_BAR = 0; + //wait for oscillator to wake up + wait(1); + + CHIPSEL_BAR = 1; + RESET_BAR = 1; //wait for tpor time + //wait for power on reset + wait(1); + RESET_BAR = 0; // send a reset pulse and wait for t_reset amount of time + wait(1); + RESET_BAR = 1;//release the reset + //Wait for 18 tclks = 36 us + wait_us(36); + + //Device wakes up in RDATAC mode so send SDATAC command to write to registers + cmdWrite(CMD_SDATAC) ; +// printf("Device is in SDATAC mode\n"); + + regRead(REG_ID); + printf("DEVICE ID register read from ADS is= 0x%X\n",data1); + wait(1); + + //Since we are using internal 2.42V reference and enable clock on the CLK PIN + //Write 0xA8 to CONFIG2 register + regWrite(REG_CONFIG2,no_mode); + + //Set continuous sampling mode, 500 SPS + regWrite(REG_CONFIG1,sps500); + + //PGA Gain = 6, inputs shorted for noise measurements + regWrite(REG_CH1SET, offset_meas); + + //read data from CONFIG2 register + regRead(REG_CONFIG2); +// printf("REG_CONFIG2 register read from ADS for initial setup is= 0x%X\n",data1); + + //read data from CONFIG1 register + regRead(REG_CONFIG1); +// printf("REG_CONFIG1 register read from ADS for initial setup is= 0x%X\n",data1); + + //read data from CONFIG1 register + regRead(REG_CH1SET); +// printf("REG_CH1SET register read from ADS for initial setup is= 0x%X\n",data1); +} + +void testsetup() +{ + //Send SDATAC command to write to registers to set test signals + cmdWrite(CMD_SDATAC) ; + printf("Device is in SDATAC mode\n"); + + //Since we are using internal 2.42V reference and enable clock on the CLK PIN + //Write 0xA3 to CONFIG2 register to set test signal and its freq = 1Hz + regWrite(REG_CONFIG2,test_mode); + + //PGA Gain = 6, test signal selected + regWrite(REG_CH1SET, test_inp); + + //read data from CONFIG2 register + regRead(REG_CONFIG2); + printf("REG_CONFIG2 register read from ADS for test signal setup is= 0x%X\n",data1); + + //read data from CONFIG1 register + regRead(REG_CH1SET); + printf("REG_CH1SET register read from ADS for test signal setup is= 0x%X\n",data1); +} + +void ecgsetup() +{ +cmdWrite(CMD_SDATAC) ; //Set to SDATAC mode to set CH1SET register + +regWrite(REG_CONFIG1,sps500); +regWrite(REG_CONFIG2, default_mode);//put INT_TEST and TEST_FREQ bits to default mode(set those bits to '0') +regWrite(REG_LOFF, loff_conf); +regWrite(REG_CH1SET, elec_inp);// Set to read normal electrode input +regWrite(REG_RLD_SENS, rld_sens_sig);//Set RLD_SENS +regWrite(REG_LOFF_SENS, loff_sens_sig);//Set LOFF_SENS +regWrite(REG_MISC1, misc1_inp );//Set RESP1 +regWrite(REG_MISC2, misc2_inp );//Set RESP2 +//printf("connect ECG leads\n"); +wait(0.5); +regRead(REG_LOFF_STAT);//Read LOFF_STAT register +printf("REG_LOFF_STAT register read from ADS for ecg setup is= 0x%X\n",data1); +} + +void doHelp(void) +{ + printf("=== spi test ===\n\r") ; + printf("commands available\n\r") ; + printf("help\n\r") ; + printf("status\n\r") ; + printf("freq freq_in_hz\n\r") ; + printf("mode (0 | 1 | 2 | 3)\n\r") ; + printf("bit (4 - 16)\n\r") ; + printf("write value\n\r") ; + printf("read\n\r") ; + printf("loop number (set repeat number for read/write)\n\r") ; +} + +void doStatus(void) +{ + printf("=== Status Report ===\n\r") ; + printf("bits: %d\n\r", bits) ; + printf("mode: %d\n\r", mode) ; + printf("freq: %d Hz\n\r", freq) ; + printf("loop: %d\n\r", loop) ; +} + +void doFreq(void) +{ + // int freq = 0 ; + // scanf("%d", &freq) ; + printf("setting frequency to %d\n\r", freq) ; + mySpi.frequency(freq) ; +} + +void doMode(void) +{ + //scanf("%d", &mode) ; + printf("setting format(%d, %d)\n\r",bits, mode) ; + mySpi.format(bits, mode) ; +} + +void doBit(void) +{ + // scanf("%d", &bits) ; + printf("setting format(%d, %d)\n\r",bits, mode) ; + mySpi.format(bits, mode) ; +} + +void doWrite(void) +{ + + //DRDY_BAR1.disable_irq(); + + CHIPSEL_BAR = 0; + // int freq1 = 50000; + // mySpi.frequency(freq1) ; + value1 = mySpi.write(0x00); + value2 = mySpi.write(0x00); + value3 = mySpi.write(0x00); + value4 = mySpi.write(0x00); + value5 = mySpi.write(0x00); + value6 = mySpi.write(0x00); + + CHIPSEL_BAR = 0; + //DRDY_BAR1.enable_irq(); +} + +void doRead(void) +{ + int dummy = 0 ; + + while(!DRDY_BAR) + ADS_START = 0; + + value = mySpi.write(dummy) ; + +} + +void doLoop(void) +{ + // scanf("%d", &loop) ; + printf("repeat number has been set to %d\n\r", loop) ; +} + +void cmdWrite(int data) +{ + CHIPSEL_BAR = 0; + mySpi.write(data) ; + wait_ms(1); + CHIPSEL_BAR = 1; +} + +void regWrite(int address, int data) +{ + int data_to_send = CMD_WREG << 5; + data_to_send = data_to_send | address; + CHIPSEL_BAR = 0; + mySpi.write(data_to_send); + wait_ms(1); + mySpi.write(0x00) ; + wait_ms(1); + mySpi.write(data) ; + wait_ms(1); + CHIPSEL_BAR = 1; +} + +void regRead(int address) +{ + int data_to_receive = CMD_RREG << 5; + data_to_receive = data_to_receive | address; + CHIPSEL_BAR = 0; + mySpi.write(data_to_receive); + wait_ms(1); + mySpi.write(0x00) ; + wait_ms(1); + data1 = mySpi.write(0x00) ; + + //printf("DEVICE ID register read from ADS is= 0x%X\n",data1); + + //wait_ms(1); + CHIPSEL_BAR = 1; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glc.cpp Mon Jan 30 07:45:41 2017 +0000 @@ -0,0 +1,187 @@ +#include "mbed.h" +#include "glc.h" +#include "i2c_dec.h" +#include "ili9325.h" +#include "lcd_base.h" +#include "display_modules.h" +//#include "touch_modules.h" +#include "rtc.h" +#include "sdcard.h" + + +void sample(); +void Compute(); +void i2c_spec(); +Ticker flipper; +Ticker flipper1; + +//osTimerDef (sample_data, sample); // define timers +//osTimerDef (Compute_GLC, Compute); +DigitalIn test_strip(PTA12); + +AnalogIn Ain(PTC1);//Electrode one +AnalogIn Ain2(PTE29); // Electrode two +AnalogOut DAC_signal(PTE30); +//Serial gc(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; +unsigned int daata1= 0; +unsigned int data2 = 0; + +unsigned int data1n= 0; +unsigned int data2n = 0; +unsigned int datafinal1 = 0; +unsigned int datafinal2 = 0; +//unsigned int data_diff = 0; +unsigned char err = 0; + +Serial ble(PTC4,PTC3); + +void sample() + +{ + data1n = Ain.read_u16(); + data2n = Ain2.read_u16(); + daata1 = beta*daata1+alpha*data1n; + data2 = beta*data2+alpha*data2n; + + if( ((daata1-data2) >=(data2/10) && (daata1 > data2)) || ((data2-daata1) >=(data2/10) && (data2 > daata1)) ) + { + + err = 1; + } + else + { + err = 0; + } + +} + +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; + + + if (err == 0) + { + + glc_4(mgdl); + + sd_write(mgdl); + sd_close(); + ble.printf("blood glucose is %d", mgdl); + flipper.detach(); + flipper1.detach(); + // return mgdl; + + } + else +{ + // lcd1.Print( " ERROR RESULT", 5,220,COLOR_RED,COLOR_BLACK, 0); + // ble.printf("E:"); + } + + +} + + +void T_S_detect(void) +{ + GLC_START = 1; + //st_strip=1; +} + + + + + + + + + + + + + + + + +void glc(int pid){ + char t_s_d = 0; + 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(); + err = 0; + data1n = 0; + data2n = 0; + daata1 = 0; + data2 = 0; + sd_open_GLCfile(pid); + + while((test_strip)); + + + // wait(500); + // Shutdown = 1; + + if (!test_strip) + { + + flipper.attach(&sample, 0.8); + t_s_d = 0; + glc_2(); + //gc.printf("%d\n", data1n); + + while((!t_s_d) && (!test_strip)) + { + + + if ((daata1 >= THRESHOLD) || (data2 >= THRESHOLD)) + { + t_s_d = 1; + flipper1.attach(&Compute, 2.25); + glc_3(); + + + } + else + { + //wait for insertion of blood; + } + + } + + + // t_s_d = 0; + wait_ms(800); + //flipper.detach(); + +} + + +} + +} + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glc.h Mon Jan 30 07:45:41 2017 +0000 @@ -0,0 +1,18 @@ +#ifndef GLC_H_ +#define GLC_H_ + + +#include "mbed.h" +#define THRESHOLD 9000 +#define SAMPLE_TIME 8 +#define COMPUTE_TIME 2250 +#define VREF 3.3 +#define TOTAL 65535 +#define NUMB1 929.3 +#define NUMB2 381.5 +#define alpha 0.99 +#define beta 0.01 + +void glc(int pid); + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/i2c_dec.cpp Mon Jan 30 07:45:41 2017 +0000 @@ -0,0 +1,13 @@ +#include "mbed.h" +#define ADDR 0x70 + +void i2c_spec() +{ +I2C i2c(PTC11, PTC10); + char dat[1]; + i2c.start(); + dat[0]=0xBB; + i2c.write(ADDR,dat,1); + i2c.stop(); + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/i2c_dec.h Mon Jan 30 07:45:41 2017 +0000 @@ -0,0 +1,6 @@ +#ifndef I2C_DEC_H_ +#define I2C_DEC_H_ + +#include "mbed.h" +void i2c_spec(); +#endif \ No newline at end of file
--- a/main.cpp Tue Dec 27 10:30:48 2016 +0000 +++ b/main.cpp Mon Jan 30 07:45:41 2017 +0000 @@ -3,13 +3,17 @@ #include "lcd_base.h" #include "display_modules.h" #include "touch_modules.h" +#include "ecg_dec.h" +#include "touch_modules.h" +#include "glc.h" +#include "sdcard.h" - + Serial gc(USBTX, USBRX); DigitalIn q1(PTB11); DigitalIn q(PTB8); - +//Serial ble(PTC4,PTC3); @@ -18,42 +22,88 @@ unsigned char state; unsigned char state1; -unsigned char state2; - - - DisableTouch(); - - - gc.baud(115200); - init_screen(); //initialize lcd - screen_main(); // display of main screen +unsigned char nstate; +unsigned char nstate1; +int pid=0; +unsigned char flag=0; +unsigned char ecg_flag=0; +unsigned char glc_flag=0; + + unsigned int mgdll; + DisableTouch(); + gc.baud(115200); + + init_screen(); //initialize lcd + screen_main(); // display of main screen state=1; + flag=0; + nstate=state; EnableTouch(); // enable touch function while(1) { detect_touch(); // detrmine the touch points + switch(state) { case 1: state1=touch_main(); // determining the touch for main screen state=0; - break; + nstate1=state1; + break; case 2: - state1=touch_glc(); // determining the touch for glc screen + state1=touch_main_1(); // determining the touch for glc screen state=0; + nstate1=state1; break; case 3: - state1=touch_ecg(); // determining the touch for ecg screen + state1=touch_main_2(); + // determining the touch for ecg screen state=0; + nstate1=state1; break; case 4: - state1=touch_bp(); // determining the touch for bp screen + state1=touch_glc(); // determining the touch for bp screen + state=0; + nstate1=state1; + break; + + case 5: + state1=touch_ecg(); // determining the touch for bp screen + state=0; + nstate1=state1; + break; + case 6: + state1=touch_ret(); // determining the touch for bp screen state=0; - break; + nstate1=state1; + // gc.printf("state=%d", state); + //gc.printf("state1=%d", state1); + break; + + case 7: + state1=touch_again(); // determining the touch for bp screen + state=0; + nstate1=state1; + break; + case 10 : DisableTouch(); + wait_ms(300); + EnableTouch(); + state=nstate; + // gc.printf("%d", nstate); + //state=0; + break; + + default : DisableTouch(); + wait_ms(300); + EnableTouch(); + state=nstate; + // gc.printf("%d", nstate); + break; + } @@ -63,25 +113,130 @@ switch(state1) { + case 0: + DisableTouch(); + wait_ms(300); + + state=nstate; + EnableTouch(); + + break; + case 1: - screen_glc(); // glc main screen + screen_main(); // glc main screen + state1=0; + state=1; + nstate=state; + flag=0; + ecg_flag=0; + glc_flag=0; + + break; + + case 2: + screen_main_1(); // glc main screen state1=0; state=2; + nstate=state; + break; - case 2: - screen_ecg(); // ecg main screen - state1=0; - state=3; - break; + case 3: + if (flag==0) + { + pid=pid+1; + screen_main_2(pid); + sd_open_GLCfile(pid); + sd_close(); + sd_open_ECGfile(pid); + sd_close(); + sd_open_BPfile(pid); + sd_close(); + flag=1; + } + else + { + screen_main_2(pid); + } + + state1=0; + state=3; + nstate=state; + break; - case 3: - screen_bp(); //bp main screen + case 4: + if (glc_flag==1) + { + screen_again(); //bp main screen + state1=0; + state=7; + nstate=state; + } + else + { screen_glc(); state1=0; state=4; + nstate=state; + } break; + + + case 5: + if (ecg_flag==1) + { + screen_again(); + state1=0; + state=7; + nstate=state; + } + + else + { + screen_ecg(); //bp main screen + state1=0; + state=5; + nstate=state; + } + break; + + case 7: + glc(pid); + + glc_flag=1; + wait(5); + // glc_4(mgdll); + state1=9; + // gc.printf("%d", state); + break; + + case 8: + + ecg_countdown(); + ecg(pid); + state1=0; + screen_ecg_2(); + state=6; + nstate=state; + ecg_flag=1; + // ble.printf("ecg"); + break; + + + case 9: + + screen_glc_2(); + state1=0; + state=6; + nstate=state; + + + break; + default : + state1=nstate1; + break; + } @@ -99,3 +254,4 @@ +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.h Mon Jan 30 07:45:41 2017 +0000 @@ -0,0 +1,7 @@ +#ifndef DISPLAY_MODULES_H_ +#define DISPLAY_MODULES_H_ + + + + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rtc.cpp Mon Jan 30 07:45:41 2017 +0000 @@ -0,0 +1,22 @@ +#include "mbed.h" +#include <stdio.h> +#include "ds3231.h" +#include "rtc.h" + + + + + +time_t rtc_read() +{ + + Ds3231 rtc(PTC11, PTC10); + + time_t epoch_time1; + //char buff1[10]; + epoch_time1 = rtc.get_epoch(); + // sprintf(buff1 ,"%s", ctime(&epoch_time1)); + return epoch_time1; + + + } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rtc.h Mon Jan 30 07:45:41 2017 +0000 @@ -0,0 +1,6 @@ +#ifndef RTC_H_ +#define RTC_H_ + +time_t rtc_read(); + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sdcard.cpp Mon Jan 30 07:45:41 2017 +0000 @@ -0,0 +1,70 @@ + #include "mbed.h" + #include <stdio.h> + #include "SDFileSystem.h" + #include "sdcard.h" + #include "rtc.h" + #include "main.h" + + SDFileSystem sd(PTE1, PTE3, PTE2, PTE4, "sd"); + FILE *fp=NULL; + + void sd_open_GLCfile(int pid) + { + + char buffer[32]; + char buffer1[32]; + time_t epoch_time1; + epoch_time1=rtc_read(); + // strftime(buffer, 32, "GLC_%s", pid); + + sprintf(buffer1,"/sd/GLC_%d.csv",pid); + fp = fopen(buffer1,"a"); + fprintf(fp,"%s\n",ctime(&epoch_time1) ); + + + } + + void sd_open_ECGfile(int pid) + { + + // char buffer[32]; + char buffer1[32]; + time_t epoch_time1; + epoch_time1=rtc_read(); + // strftime(buffer, 32, "ECG_%d", pid); + + sprintf(buffer1,"/sd/ECG_%d.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_BPfile(int pid) + { + + char buffer[32]; + char buffer1[32]; + time_t epoch_time1; + epoch_time1=rtc_read(); + // strftime(buffer, 32, "ECG_%d", pid); + + sprintf(buffer1,"/sd/BP_%d.csv",pid); + fp = fopen(buffer1,"a"); + fprintf(fp,"%s\n",ctime(&epoch_time1) ); + } + + + + void sd_write (int value) + { + + fprintf(fp,"%d\n", value); + } + + void sd_close() + { + fclose(fp); + } + + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sdcard.h Mon Jan 30 07:45:41 2017 +0000 @@ -0,0 +1,10 @@ +#ifndef SDCARD_H_ +#define SDCARD_H_ + +void sd_open_ECGfile(int pid); +void sd_open_GLCfile(int pid); +void sd_open_BPfile(int pid); +void sd_write (int value); +void sd_close(); + +#endif \ No newline at end of file
--- a/touch_modules.cpp Tue Dec 27 10:30:48 2016 +0000 +++ b/touch_modules.cpp Mon Jan 30 07:45:41 2017 +0000 @@ -7,13 +7,16 @@ int i; unsigned int xt; unsigned int yt; - +Serial kc(USBTX, USBRX); void touch1() //determining the touch co-ordinates { xt = (X_MAX*readTouchX()/TOTAL1); yt = (Y_MAX*readTouchY()/TOTAL1); + kc.printf("%d\n", xt); + kc.printf("%d\n", yt); + } @@ -31,9 +34,12 @@ break; } DisableTouch(); - + //kc.printf("touch"); + } } + + } @@ -43,65 +49,134 @@ unsigned char state; + if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // system configuration + { + + state=2; + } + + else if ( ((xt >=70) && (xt<=170)) && ( (yt>=80) && (yt<=140) ) ) // test + { + state=3; + } + else + state=10; + + return state; + } + + +unsigned char touch_main_1() //determining the touch for home screen +{ + + unsigned char state; + + if ( ((xt >=35) && (xt<=100)) && ( (yt>= 135) && (yt<= 185) ) ) // ble + { + + // state=3; + } + + else if ( ((xt >=130) && (xt<=195)) && ( (yt>= 135) && (yt<= 185) ) ) // erase + { + // state=4; + + + } + else if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // file + { + // state=5; + + } + else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // home + { + //state=6; + + } + else + state=10; + + return state; + } + +unsigned char touch_main_2() //determining the touch for home screen +{ + + unsigned char state; + if ( ((xt >=35) && (xt<=100)) && ( (yt>= 135) && (yt<= 185) ) ) // GLC { - state=1; + state=4; } else if ( ((xt >=130) && (xt<=195)) && ( (yt>= 135) && (yt<= 185) ) ) // ECG { - state=2; + state=5; } else if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // BP { - state=3; + //state=5; } - else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // SET + else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // Home { - state=4; + state=1; } + else + state=10; + return state; } - - + + + + + unsigned char touch_ecg() // determining the touch for ecg screen { unsigned char state; -if ( ((xt >=28) && (xt<=125)) && ( (yt>= 225) && (yt<= 285) ) ) // home screen - { - - state=5; - } - - if ( ((xt >=35) && (xt<=100)) && ( (yt>= 135) && (yt<= 185) ) ) // SET - { - state=6; - - } - - else if ( ((xt >=150) && (xt<=195)) && ( (yt>= 80) && (yt<= 190) ) ) // start - { - state=7; - } - - else if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // history - { - state=8; - - } - + if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // GLC + { + + state=8; + } + + else if ( ((xt >=70) && (xt<=170)) && ( (yt>=90) && (yt<=140) ) ) // ECG + { + // state=2; + } + else + state=10; + return state; } +unsigned char touch_ret() // determining the touch for ecg screen +{ + + unsigned char state; + + + if ( ((xt >=70) && (xt<=170)) && ( (yt>=85) && (yt<=140) ) ) // ECG + { + state=3; + } + + else + state=10; + return state; + } + + + unsigned char touch_bp() // //determining the touch for bp screen @@ -136,7 +211,8 @@ state=5; } - + else + state=10; return state; } @@ -146,41 +222,49 @@ unsigned char touch_glc() ////determining the touch for home screen { unsigned char state; -if ( ((xt >=28) && (xt<=125)) && ( (yt>= 225) && (yt<= 285) ) ) - { - state=1; - } - - else if ( ((xt >=35) && (xt<=100)) && ( (yt>= 135) && (yt<= 185) ) ) + + if ( ((xt >=70) && (xt<=170)) && ( (yt>= 140) && (yt<= 195) ) ) // GLC { - state=2; - + state=7; } - else if ( ((xt >=130) && (xt<=195)) && ( (yt>= 135) && (yt<= 185) ) ) - { - state=3; - - - } - else if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) + else if ( ((xt >=70) && (xt<=170)) && ( (yt>=85) && (yt<=140) ) ) // ECG { - state=4; - - } - else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // SET - { - state=5; - - } - + // state=2; + } + else + state=10; return state; } - - + + + unsigned char touch_again() //determining the touch for home screen +{ + + unsigned char state; + + if ( ((xt >= 35) && (xt<=100)) && ( (yt>= 65) && (yt<= 118) ) ) // BP + { + state=8; + + } + else if ( ((xt >= 130) && (xt<=195)) && ( (yt>= 65) && (yt<= 118) ) ) // SET + { + state=3; + + } + else + state=10; + return state; + } + + + + + int readTouchY(void) { DigitalOut YD(PTD6);
--- a/touch_modules.h Tue Dec 27 10:30:48 2016 +0000 +++ b/touch_modules.h Mon Jan 30 07:45:41 2017 +0000 @@ -5,6 +5,8 @@ #define X_MAX 240 #define Y_MAX 320 unsigned char touch_main(); +unsigned char touch_main_1(); +unsigned char touch_main_2(); void touch1() ; int readTouchY(void); void detect_touch(); @@ -15,5 +17,6 @@ unsigned char touch_glc(); unsigned char touch_ecg(); unsigned char touch_bp(); - +unsigned char touch_ret(); + unsigned char touch_again(); #endif \ No newline at end of file