Changes done in ECG and BT
Dependencies: SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217
Fork of merged_code2_20sept_2017_4th_oct_2017 by
main.cpp@50:b42238e7f46d, 2017-09-16 (annotated)
- Committer:
- nikitateggi
- Date:
- Sat Sep 16 06:54:42 2017 +0000
- Revision:
- 50:b42238e7f46d
- Parent:
- 49:3ff80c4bc1be
- Child:
- 51:1a4693774b60
modified in sd read debug
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nikitateggi | 0:c47fb0c1bbf6 | 1 | #include "mbed.h" |
nikitateggi | 0:c47fb0c1bbf6 | 2 | #include "display_modules.h" |
nikitateggi | 0:c47fb0c1bbf6 | 3 | #include "touch_modules.h" |
nikitateggi | 1:8316c23ec6b9 | 4 | #include "ecg_dec.h" |
nikitateggi | 1:8316c23ec6b9 | 5 | #include "touch_modules.h" |
nikitateggi | 1:8316c23ec6b9 | 6 | #include "glc.h" |
nikitateggi | 3:9a06c2bed650 | 7 | #include "bp.h" |
nikitateggi | 1:8316c23ec6b9 | 8 | #include "sdcard.h" |
nikitateggi | 4:6bd81bb1790d | 9 | #include "eeprom_pgm.h" |
nikitateggi | 19:1650bbc923cc | 10 | #include "struct.h" |
nikitateggi | 22:ffa88619551d | 11 | #include "battery.h" |
rashmivenkataramaiah | 41:1141a75eacc4 | 12 | #include "main.h" |
nikitateggi | 45:067673dae242 | 13 | |
nikitateggi | 45:067673dae242 | 14 | #define TIMER_RXACK_BTCONNECTION 10000 |
nikitateggi | 45:067673dae242 | 15 | #define BATTERY_TIMER_VALUE 600000 |
nikitateggi | 45:067673dae242 | 16 | #define SERIAL_BAUD_RATE 115200 |
nikitateggi | 45:067673dae242 | 17 | #define BATTERY_SCREEN_NO_CHARGE_CONDITION 3 |
nikitateggi | 49:3ff80c4bc1be | 18 | #define TIMER_ENTER_DEBUG_MODE 10000 |
nikitateggi | 24:d992ee8369f4 | 19 | |
nikitateggi | 0:c47fb0c1bbf6 | 20 | Serial gc(USBTX, USBRX); |
nikitateggi | 0:c47fb0c1bbf6 | 21 | DigitalIn q1(PTB11); |
nikitateggi | 29:7edc76b15e3d | 22 | DigitalIn q(PTC5); |
nikitateggi | 29:7edc76b15e3d | 23 | DigitalIn q3(PTC12); |
rashmivenkataramaiah | 42:c81673b04b6a | 24 | DigitalIn BT(PTA5); |
nikitateggi | 44:05dbea558c9a | 25 | Serial blue1(PTC4,PTC3); |
nikitateggi | 44:05dbea558c9a | 26 | uint32_t get_timer_bluetooth(); |
nikitateggi | 45:067673dae242 | 27 | static void battery_status_monitoring(); //bluetooth status pin |
nikitateggi | 45:067673dae242 | 28 | uint8_t touch(uint8_t state); // touch state |
nikitateggi | 45:067673dae242 | 29 | uint8_t display(uint8_t state1); // display state |
nikitateggi | 45:067673dae242 | 30 | |
rashmivenkataramaiah | 42:c81673b04b6a | 31 | static uint8_t nstate=0; |
rashmivenkataramaiah | 42:c81673b04b6a | 32 | static uint8_t nstate1=0; |
rashmivenkataramaiah | 43:85a7f399cb9d | 33 | static uint32_t pid = 0; // patient ID |
rashmivenkataramaiah | 43:85a7f399cb9d | 34 | static bool file_created_status = false; //initialise file created to 0 |
rashmivenkataramaiah | 43:85a7f399cb9d | 35 | static uint32_t filepid_btpid[2] = {}; |
nikitateggi | 45:067673dae242 | 36 | Timer timer_bt; // timer for bluetooth |
nikitateggi | 45:067673dae242 | 37 | Timer timer_battery; // timer for battery |
nikitateggi | 49:3ff80c4bc1be | 38 | uint8_t debug_mode=0; |
nikitateggi | 44:05dbea558c9a | 39 | |
nikitateggi | 0:c47fb0c1bbf6 | 40 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 41 | int main() |
rashmivenkataramaiah | 41:1141a75eacc4 | 42 | { |
rashmivenkataramaiah | 41:1141a75eacc4 | 43 | static uint8_t main_state=1; |
rashmivenkataramaiah | 41:1141a75eacc4 | 44 | static uint8_t state_display = 0; |
rashmivenkataramaiah | 41:1141a75eacc4 | 45 | static uint8_t state_touch = 1; |
nikitateggi | 47:3716dd41dba6 | 46 | uint8_t state_t = 1; // state to transmit to bluetooth |
nikitateggi | 47:3716dd41dba6 | 47 | uint8_t state_r = 0; // state to receive from bluetooth |
nikitateggi | 49:3ff80c4bc1be | 48 | |
avp2417 | 37:92fcbf22bf91 | 49 | |
avp2417 | 37:92fcbf22bf91 | 50 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 51 | DisableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 52 | gc.baud(115200); |
nikitateggi | 47:3716dd41dba6 | 53 | blue1.baud(115200); |
rashmivenkataramaiah | 41:1141a75eacc4 | 54 | init_screen(); //initialize lcd |
rashmivenkataramaiah | 42:c81673b04b6a | 55 | pid = get_filepid(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 56 | screen_main(); // display of main screen |
nikitateggi | 45:067673dae242 | 57 | battery_monitor(); // monitor battery at the start only |
nikitateggi | 45:067673dae242 | 58 | battery_status_display(); // display of main screen |
nikitateggi | 45:067673dae242 | 59 | timer_battery.start(); |
nikitateggi | 49:3ff80c4bc1be | 60 | timer_bt.start(); |
nikitateggi | 49:3ff80c4bc1be | 61 | gc.printf("Press any key to enter into debug mode\n"); |
avp2417 | 37:92fcbf22bf91 | 62 | |
nikitateggi | 49:3ff80c4bc1be | 63 | while(timer_bt.read_ms()<TIMER_ENTER_DEBUG_MODE) |
nikitateggi | 49:3ff80c4bc1be | 64 | { |
nikitateggi | 49:3ff80c4bc1be | 65 | |
nikitateggi | 50:b42238e7f46d | 66 | if (gc.readable()) // checking whether there is any data read |
nikitateggi | 49:3ff80c4bc1be | 67 | { |
nikitateggi | 50:b42238e7f46d | 68 | gc.getc(); |
nikitateggi | 50:b42238e7f46d | 69 | //getchar(); |
nikitateggi | 50:b42238e7f46d | 70 | debug_mode = 1; |
nikitateggi | 50:b42238e7f46d | 71 | timer_bt.stop(); |
nikitateggi | 50:b42238e7f46d | 72 | timer_bt.reset(); |
nikitateggi | 50:b42238e7f46d | 73 | gc.printf("entered debug mode\n"); |
nikitateggi | 50:b42238e7f46d | 74 | break; |
nikitateggi | 49:3ff80c4bc1be | 75 | } |
nikitateggi | 49:3ff80c4bc1be | 76 | } |
nikitateggi | 49:3ff80c4bc1be | 77 | |
nikitateggi | 49:3ff80c4bc1be | 78 | timer_bt.stop(); |
nikitateggi | 49:3ff80c4bc1be | 79 | timer_bt.reset(); |
nikitateggi | 0:c47fb0c1bbf6 | 80 | while(1) |
nikitateggi | 0:c47fb0c1bbf6 | 81 | { |
nikitateggi | 45:067673dae242 | 82 | battery_status_monitoring(); // to monitior battery status after every 10 min. |
nikitateggi | 45:067673dae242 | 83 | |
nikitateggi | 45:067673dae242 | 84 | if (get_battery_status() == BATTERY_SCREEN_NO_CHARGE_CONDITION) // to check battery status and take action |
nikitateggi | 45:067673dae242 | 85 | { |
nikitateggi | 45:067673dae242 | 86 | DisableTouch(); |
nikitateggi | 45:067673dae242 | 87 | } |
nikitateggi | 45:067673dae242 | 88 | else |
nikitateggi | 45:067673dae242 | 89 | { |
nikitateggi | 45:067673dae242 | 90 | |
nikitateggi | 45:067673dae242 | 91 | EnableTouch(); |
nikitateggi | 45:067673dae242 | 92 | switch(main_state) // main state machine |
nikitateggi | 45:067673dae242 | 93 | { |
nikitateggi | 45:067673dae242 | 94 | case 1: |
nikitateggi | 45:067673dae242 | 95 | state_display = touch(state_touch); // touch state |
nikitateggi | 45:067673dae242 | 96 | if(state_display == 12) |
nikitateggi | 45:067673dae242 | 97 | { |
nikitateggi | 45:067673dae242 | 98 | main_state = 3; |
nikitateggi | 45:067673dae242 | 99 | } |
nikitateggi | 45:067673dae242 | 100 | else |
nikitateggi | 45:067673dae242 | 101 | { |
nikitateggi | 45:067673dae242 | 102 | main_state = 2; |
nikitateggi | 45:067673dae242 | 103 | } |
nikitateggi | 45:067673dae242 | 104 | break; |
avp2417 | 37:92fcbf22bf91 | 105 | |
nikitateggi | 45:067673dae242 | 106 | case 2: |
nikitateggi | 45:067673dae242 | 107 | state_touch = display(state_display); //display state |
nikitateggi | 45:067673dae242 | 108 | main_state = 1; |
nikitateggi | 45:067673dae242 | 109 | break; |
nikitateggi | 19:1650bbc923cc | 110 | |
nikitateggi | 19:1650bbc923cc | 111 | |
nikitateggi | 45:067673dae242 | 112 | case 3: |
nikitateggi | 45:067673dae242 | 113 | DisableTouch(); // bluetooth send |
nikitateggi | 45:067673dae242 | 114 | timer_bt.start(); |
nikitateggi | 45:067673dae242 | 115 | if(get_timer_bluetooth()<TIMER_RXACK_BTCONNECTION) // bluetooth connection timer 15 sec |
nikitateggi | 45:067673dae242 | 116 | { |
nikitateggi | 44:05dbea558c9a | 117 | |
nikitateggi | 45:067673dae242 | 118 | if(BT==1) // checking for bluetooth connection |
nikitateggi | 45:067673dae242 | 119 | { |
nikitateggi | 44:05dbea558c9a | 120 | |
nikitateggi | 45:067673dae242 | 121 | timer_bt.stop(); // stop the timer once connected to app |
nikitateggi | 45:067673dae242 | 122 | timer_bt.reset(); |
nikitateggi | 44:05dbea558c9a | 123 | BT_connection() ; // displaying connection on bluetooth |
nikitateggi | 44:05dbea558c9a | 124 | state_r=bt_send(state_t); |
nikitateggi | 45:067673dae242 | 125 | timer_bt.start(); |
nikitateggi | 47:3716dd41dba6 | 126 | //gc.printf(" state_t = %d\n", state_t); |
nikitateggi | 48:f90edb35a20e | 127 | // gc.printf(" state_r = %d\n", state_r); |
nikitateggi | 44:05dbea558c9a | 128 | if (state_r==0) // if the state received is zero, then there is no new file to send |
nikitateggi | 45:067673dae242 | 129 | { |
nikitateggi | 45:067673dae242 | 130 | timer_bt.stop(); // stop the timer once connected to app |
nikitateggi | 45:067673dae242 | 131 | timer_bt.reset(); |
nikitateggi | 45:067673dae242 | 132 | BT_finished(); // screen to display communication finished |
nikitateggi | 45:067673dae242 | 133 | screen_BT_return(); //screen to return back |
nikitateggi | 45:067673dae242 | 134 | EnableTouch(); |
nikitateggi | 45:067673dae242 | 135 | main_state=1; |
nikitateggi | 45:067673dae242 | 136 | state_touch=12; |
nikitateggi | 45:067673dae242 | 137 | break; |
nikitateggi | 44:05dbea558c9a | 138 | } |
nikitateggi | 44:05dbea558c9a | 139 | |
nikitateggi | 44:05dbea558c9a | 140 | else |
nikitateggi | 44:05dbea558c9a | 141 | { |
nikitateggi | 44:05dbea558c9a | 142 | main_state=4; // move to receving stste of bluetooth |
nikitateggi | 44:05dbea558c9a | 143 | } |
nikitateggi | 44:05dbea558c9a | 144 | |
nikitateggi | 45:067673dae242 | 145 | } |
nikitateggi | 44:05dbea558c9a | 146 | |
nikitateggi | 45:067673dae242 | 147 | else |
nikitateggi | 45:067673dae242 | 148 | { |
nikitateggi | 45:067673dae242 | 149 | BT_no_connection(); // display screen to show that there is no connection |
nikitateggi | 45:067673dae242 | 150 | } |
nikitateggi | 45:067673dae242 | 151 | } |
nikitateggi | 44:05dbea558c9a | 152 | |
nikitateggi | 45:067673dae242 | 153 | else |
nikitateggi | 45:067673dae242 | 154 | { |
nikitateggi | 45:067673dae242 | 155 | BT_no_connection(); // display screen to show that there is no connection |
nikitateggi | 45:067673dae242 | 156 | gc.printf("stopped"); |
nikitateggi | 45:067673dae242 | 157 | screen_BT_return(); // button to return |
nikitateggi | 45:067673dae242 | 158 | EnableTouch(); |
nikitateggi | 45:067673dae242 | 159 | main_state=1; |
nikitateggi | 45:067673dae242 | 160 | state_touch=12; |
nikitateggi | 49:3ff80c4bc1be | 161 | //sd_close(); |
nikitateggi | 45:067673dae242 | 162 | timer_bt.stop(); |
nikitateggi | 45:067673dae242 | 163 | timer_bt.reset(); |
nikitateggi | 45:067673dae242 | 164 | } |
nikitateggi | 45:067673dae242 | 165 | break; |
nikitateggi | 19:1650bbc923cc | 166 | |
nikitateggi | 45:067673dae242 | 167 | case 4: |
nikitateggi | 45:067673dae242 | 168 | DisableTouch(); |
nikitateggi | 44:05dbea558c9a | 169 | |
nikitateggi | 45:067673dae242 | 170 | if(get_timer_bluetooth()<TIMER_RXACK_BTCONNECTION) |
nikitateggi | 45:067673dae242 | 171 | { |
nikitateggi | 45:067673dae242 | 172 | if (blue1.readable()) // if there is data to receive enter the loop |
nikitateggi | 45:067673dae242 | 173 | { |
nikitateggi | 46:162ed3f051b2 | 174 | |
nikitateggi | 46:162ed3f051b2 | 175 | state_t=bt_receive(state_r); |
nikitateggi | 48:f90edb35a20e | 176 | // gc.printf(" state_t = %d\n", state_t); |
nikitateggi | 47:3716dd41dba6 | 177 | // gc.printf(" state_r = %d\n", state_r); |
nikitateggi | 45:067673dae242 | 178 | timer_bt.stop(); |
nikitateggi | 45:067673dae242 | 179 | timer_bt.reset(); |
nikitateggi | 45:067673dae242 | 180 | if(state_t ==0) // if state_t is zero, there is no other file to send |
nikitateggi | 45:067673dae242 | 181 | { |
nikitateggi | 45:067673dae242 | 182 | |
nikitateggi | 45:067673dae242 | 183 | BT_finished(); |
nikitateggi | 45:067673dae242 | 184 | screen_BT_return(); |
nikitateggi | 45:067673dae242 | 185 | EnableTouch(); |
nikitateggi | 45:067673dae242 | 186 | main_state=1; |
nikitateggi | 45:067673dae242 | 187 | state_touch=12; // jumping to touch case 12 |
nikitateggi | 45:067673dae242 | 188 | break; |
nikitateggi | 45:067673dae242 | 189 | } |
nikitateggi | 45:067673dae242 | 190 | else // move to bluetooth transmit if the states are 1,2,3,4 |
nikitateggi | 45:067673dae242 | 191 | { |
nikitateggi | 44:05dbea558c9a | 192 | main_state=3; |
nikitateggi | 45:067673dae242 | 193 | } |
nikitateggi | 45:067673dae242 | 194 | } |
nikitateggi | 45:067673dae242 | 195 | } |
nikitateggi | 44:05dbea558c9a | 196 | |
nikitateggi | 45:067673dae242 | 197 | else |
nikitateggi | 45:067673dae242 | 198 | { |
nikitateggi | 45:067673dae242 | 199 | DisableTouch(); |
nikitateggi | 45:067673dae242 | 200 | BT_no_connection(); // display screen to show that there is no connection |
nikitateggi | 45:067673dae242 | 201 | gc.printf("stopped"); |
nikitateggi | 45:067673dae242 | 202 | screen_BT_return(); // button to return |
nikitateggi | 45:067673dae242 | 203 | EnableTouch(); |
nikitateggi | 45:067673dae242 | 204 | main_state=1; |
nikitateggi | 45:067673dae242 | 205 | state_touch=12; |
nikitateggi | 47:3716dd41dba6 | 206 | state_t = 1; // state to transmit to bluetooth |
nikitateggi | 48:f90edb35a20e | 207 | state_r = 0; // state to receive from bluetooth |
nikitateggi | 46:162ed3f051b2 | 208 | sd_close(); ///close the opened file which was used for bluetooth |
nikitateggi | 45:067673dae242 | 209 | timer_bt.stop(); |
nikitateggi | 45:067673dae242 | 210 | timer_bt.reset(); |
nikitateggi | 45:067673dae242 | 211 | } |
nikitateggi | 45:067673dae242 | 212 | break; |
nikitateggi | 45:067673dae242 | 213 | } |
nikitateggi | 45:067673dae242 | 214 | } |
nikitateggi | 45:067673dae242 | 215 | } |
nikitateggi | 45:067673dae242 | 216 | |
nikitateggi | 22:ffa88619551d | 217 | } |
nikitateggi | 19:1650bbc923cc | 218 | uint8_t touch(uint8_t state) |
nikitateggi | 19:1650bbc923cc | 219 | { |
nikitateggi | 19:1650bbc923cc | 220 | static uint8_t state1=0; |
rashmivenkataramaiah | 41:1141a75eacc4 | 221 | detect_touch(state); // determine the touch points |
nikitateggi | 1:8316c23ec6b9 | 222 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 223 | switch(state) // state for touch |
nikitateggi | 0:c47fb0c1bbf6 | 224 | { |
rashmivenkataramaiah | 41:1141a75eacc4 | 225 | case 1: |
rashmivenkataramaiah | 41:1141a75eacc4 | 226 | state1=touch_main(); // determining the touch for main screen |
nikitateggi | 0:c47fb0c1bbf6 | 227 | state=0; |
nikitateggi | 1:8316c23ec6b9 | 228 | nstate1=state1; |
rashmivenkataramaiah | 41:1141a75eacc4 | 229 | break; |
nikitateggi | 0:c47fb0c1bbf6 | 230 | |
nikitateggi | 0:c47fb0c1bbf6 | 231 | case 2: |
rashmivenkataramaiah | 41:1141a75eacc4 | 232 | state1=touch_main_1(); // determining the touch for SYSTEM CONFIGURATION screen |
nikitateggi | 0:c47fb0c1bbf6 | 233 | state=0; |
nikitateggi | 3:9a06c2bed650 | 234 | nstate1=state1; |
nikitateggi | 0:c47fb0c1bbf6 | 235 | break; |
nikitateggi | 0:c47fb0c1bbf6 | 236 | |
nikitateggi | 0:c47fb0c1bbf6 | 237 | case 3: |
rashmivenkataramaiah | 41:1141a75eacc4 | 238 | state1=touch_main_2(); // determining the touch for TEST screen |
nikitateggi | 0:c47fb0c1bbf6 | 239 | state=0; |
nikitateggi | 1:8316c23ec6b9 | 240 | nstate1=state1; |
nikitateggi | 0:c47fb0c1bbf6 | 241 | break; |
nikitateggi | 0:c47fb0c1bbf6 | 242 | |
nikitateggi | 0:c47fb0c1bbf6 | 243 | case 4: |
rashmivenkataramaiah | 41:1141a75eacc4 | 244 | state1=touch_glc(); // determining the touch for GLC screen |
nikitateggi | 1:8316c23ec6b9 | 245 | state=0; |
nikitateggi | 1:8316c23ec6b9 | 246 | nstate1=state1; |
nikitateggi | 1:8316c23ec6b9 | 247 | break; |
nikitateggi | 1:8316c23ec6b9 | 248 | |
nikitateggi | 1:8316c23ec6b9 | 249 | case 5: |
rashmivenkataramaiah | 41:1141a75eacc4 | 250 | state1=touch_ecg(); // determining the touch for ECG screen |
nikitateggi | 1:8316c23ec6b9 | 251 | state=0; |
nikitateggi | 3:9a06c2bed650 | 252 | nstate1=state1; |
nikitateggi | 3:9a06c2bed650 | 253 | break; |
nikitateggi | 4:6bd81bb1790d | 254 | case 6: |
rashmivenkataramaiah | 41:1141a75eacc4 | 255 | state1=touch_ret(); // determining the touch for returning back to the main screen |
nikitateggi | 0:c47fb0c1bbf6 | 256 | state=0; |
nikitateggi | 3:9a06c2bed650 | 257 | nstate1=state1; |
nikitateggi | 1:8316c23ec6b9 | 258 | break; |
nikitateggi | 1:8316c23ec6b9 | 259 | |
nikitateggi | 4:6bd81bb1790d | 260 | case 7: |
rashmivenkataramaiah | 41:1141a75eacc4 | 261 | state1=touch_again_ecg(); // determining the touch when readings are taken more than once screen |
nikitateggi | 1:8316c23ec6b9 | 262 | state=0; |
nikitateggi | 1:8316c23ec6b9 | 263 | nstate1=state1; |
nikitateggi | 1:8316c23ec6b9 | 264 | break; |
nikitateggi | 0:c47fb0c1bbf6 | 265 | |
nikitateggi | 3:9a06c2bed650 | 266 | case 8: |
rashmivenkataramaiah | 41:1141a75eacc4 | 267 | state1=touch_bp(); // determining the touch for BP screen |
nikitateggi | 3:9a06c2bed650 | 268 | state=0; |
nikitateggi | 3:9a06c2bed650 | 269 | nstate1=state1; |
nikitateggi | 3:9a06c2bed650 | 270 | break; |
nikitateggi | 3:9a06c2bed650 | 271 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 272 | case 9: |
rashmivenkataramaiah | 41:1141a75eacc4 | 273 | state1=touch_again_glc(); |
suhasini | 5:a3ea7c82b7e1 | 274 | state=0; |
suhasini | 5:a3ea7c82b7e1 | 275 | nstate1=state1; |
suhasini | 5:a3ea7c82b7e1 | 276 | break; |
nikitateggi | 3:9a06c2bed650 | 277 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 278 | case 10 : |
rashmivenkataramaiah | 41:1141a75eacc4 | 279 | DisableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 280 | wait_ms(300); |
rashmivenkataramaiah | 41:1141a75eacc4 | 281 | EnableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 282 | state=nstate; |
rashmivenkataramaiah | 41:1141a75eacc4 | 283 | break; |
suhasini | 5:a3ea7c82b7e1 | 284 | |
suhasini | 5:a3ea7c82b7e1 | 285 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 286 | case 11: |
rashmivenkataramaiah | 41:1141a75eacc4 | 287 | state1=touch_again_bp(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 288 | state=0; |
rashmivenkataramaiah | 41:1141a75eacc4 | 289 | nstate1=state1; |
rashmivenkataramaiah | 41:1141a75eacc4 | 290 | break; |
suhasini | 5:a3ea7c82b7e1 | 291 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 292 | case 12: |
rashmivenkataramaiah | 41:1141a75eacc4 | 293 | state1=BT_return(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 294 | state=0; |
rashmivenkataramaiah | 41:1141a75eacc4 | 295 | nstate1=state1; |
rashmivenkataramaiah | 41:1141a75eacc4 | 296 | break; |
nikitateggi | 49:3ff80c4bc1be | 297 | |
nikitateggi | 49:3ff80c4bc1be | 298 | case 13: |
nikitateggi | 49:3ff80c4bc1be | 299 | state1 = touch_debug(); //touch state for debug |
nikitateggi | 49:3ff80c4bc1be | 300 | //state=0; |
nikitateggi | 49:3ff80c4bc1be | 301 | nstate1=state1; |
nikitateggi | 49:3ff80c4bc1be | 302 | break; |
rashmivenkataramaiah | 41:1141a75eacc4 | 303 | default : |
rashmivenkataramaiah | 41:1141a75eacc4 | 304 | DisableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 305 | wait_ms(300); |
rashmivenkataramaiah | 41:1141a75eacc4 | 306 | EnableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 307 | state=nstate; |
rashmivenkataramaiah | 41:1141a75eacc4 | 308 | break; |
nikitateggi | 1:8316c23ec6b9 | 309 | |
nikitateggi | 0:c47fb0c1bbf6 | 310 | } |
nikitateggi | 0:c47fb0c1bbf6 | 311 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 312 | return state1; |
rashmivenkataramaiah | 41:1141a75eacc4 | 313 | } |
nikitateggi | 0:c47fb0c1bbf6 | 314 | |
nikitateggi | 0:c47fb0c1bbf6 | 315 | |
nikitateggi | 19:1650bbc923cc | 316 | uint8_t display(uint8_t state1) |
nikitateggi | 19:1650bbc923cc | 317 | { |
rashmivenkataramaiah | 41:1141a75eacc4 | 318 | static uint8_t state=0; |
rashmivenkataramaiah | 41:1141a75eacc4 | 319 | static uint8_t ecg_flag=0; // ecg_flag to indicate the ecg test is already done for the same pid |
rashmivenkataramaiah | 41:1141a75eacc4 | 320 | static uint8_t glc_flag=0; // glc_flag to indicate the glc test is already done for the same pid |
rashmivenkataramaiah | 41:1141a75eacc4 | 321 | uint16_t heart_rate=0; |
nikitateggi | 50:b42238e7f46d | 322 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 323 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 324 | switch(state1) // state for display screens |
rashmivenkataramaiah | 41:1141a75eacc4 | 325 | { |
nikitateggi | 4:6bd81bb1790d | 326 | |
nikitateggi | 1:8316c23ec6b9 | 327 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 328 | case 1: |
rashmivenkataramaiah | 41:1141a75eacc4 | 329 | DisableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 330 | screen_main(); // main screen |
nikitateggi | 1:8316c23ec6b9 | 331 | state1=0; |
nikitateggi | 1:8316c23ec6b9 | 332 | state=1; |
nikitateggi | 1:8316c23ec6b9 | 333 | nstate=state; |
rashmivenkataramaiah | 41:1141a75eacc4 | 334 | ecg_flag=0; // ecg, glc flag to determine whether the readings are taken more than once |
nikitateggi | 1:8316c23ec6b9 | 335 | glc_flag=0; |
rashmivenkataramaiah | 41:1141a75eacc4 | 336 | clear_filecreated_status(); |
rashmivenkataramaiah | 42:c81673b04b6a | 337 | pid = get_filepid(); |
nikitateggi | 45:067673dae242 | 338 | battery_status_display(); //Display battery status on LCD |
nikitateggi | 49:3ff80c4bc1be | 339 | debug_mode = 0; |
nikitateggi | 3:9a06c2bed650 | 340 | EnableTouch(); |
nikitateggi | 1:8316c23ec6b9 | 341 | break; |
nikitateggi | 1:8316c23ec6b9 | 342 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 343 | case 2: |
rashmivenkataramaiah | 41:1141a75eacc4 | 344 | DisableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 345 | screen_main_1(); // System configration screen |
nikitateggi | 0:c47fb0c1bbf6 | 346 | state1=0; |
nikitateggi | 0:c47fb0c1bbf6 | 347 | state=2; |
nikitateggi | 1:8316c23ec6b9 | 348 | nstate=state; |
nikitateggi | 45:067673dae242 | 349 | battery_status_display(); //Display battery status on LCD |
nikitateggi | 3:9a06c2bed650 | 350 | EnableTouch(); |
nikitateggi | 0:c47fb0c1bbf6 | 351 | break; |
nikitateggi | 0:c47fb0c1bbf6 | 352 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 353 | case 3: |
rashmivenkataramaiah | 41:1141a75eacc4 | 354 | DisableTouch(); |
rashmivenkataramaiah | 42:c81673b04b6a | 355 | //sd_read(pid_btpid); //read pid from sd card |
rashmivenkataramaiah | 42:c81673b04b6a | 356 | //pid=pid_btpid[0]; //copy pid to a variable |
nikitateggi | 19:1650bbc923cc | 357 | gc.printf("pidinit=%d",pid); |
rashmivenkataramaiah | 41:1141a75eacc4 | 358 | screen_main_2(pid); |
rashmivenkataramaiah | 41:1141a75eacc4 | 359 | state1=0; |
rashmivenkataramaiah | 41:1141a75eacc4 | 360 | state=3; |
rashmivenkataramaiah | 41:1141a75eacc4 | 361 | nstate=state; |
nikitateggi | 45:067673dae242 | 362 | battery_status_display(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 363 | EnableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 364 | break; |
nikitateggi | 0:c47fb0c1bbf6 | 365 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 366 | case 4: |
rashmivenkataramaiah | 41:1141a75eacc4 | 367 | DisableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 368 | if (glc_flag==1) // glc_flag=1 when already the reading has been taken |
rashmivenkataramaiah | 41:1141a75eacc4 | 369 | { |
rashmivenkataramaiah | 41:1141a75eacc4 | 370 | screen_again(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 371 | state1=0; |
rashmivenkataramaiah | 41:1141a75eacc4 | 372 | state=9; |
rashmivenkataramaiah | 41:1141a75eacc4 | 373 | nstate=state; |
rashmivenkataramaiah | 41:1141a75eacc4 | 374 | } |
rashmivenkataramaiah | 41:1141a75eacc4 | 375 | else |
nikitateggi | 19:1650bbc923cc | 376 | { |
rashmivenkataramaiah | 41:1141a75eacc4 | 377 | screen_glc(); // glc screen |
rashmivenkataramaiah | 41:1141a75eacc4 | 378 | state1=0; |
rashmivenkataramaiah | 41:1141a75eacc4 | 379 | state=4; |
rashmivenkataramaiah | 41:1141a75eacc4 | 380 | nstate=state; |
rashmivenkataramaiah | 41:1141a75eacc4 | 381 | } |
nikitateggi | 3:9a06c2bed650 | 382 | EnableTouch(); |
nikitateggi | 3:9a06c2bed650 | 383 | |
nikitateggi | 0:c47fb0c1bbf6 | 384 | break; |
nikitateggi | 1:8316c23ec6b9 | 385 | |
nikitateggi | 1:8316c23ec6b9 | 386 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 387 | case 5: |
rashmivenkataramaiah | 41:1141a75eacc4 | 388 | DisableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 389 | if (ecg_flag==1) |
rashmivenkataramaiah | 41:1141a75eacc4 | 390 | { |
rashmivenkataramaiah | 41:1141a75eacc4 | 391 | screen_again(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 392 | state1=0; |
rashmivenkataramaiah | 41:1141a75eacc4 | 393 | state=7; |
nikitateggi | 1:8316c23ec6b9 | 394 | nstate=state; |
rashmivenkataramaiah | 41:1141a75eacc4 | 395 | } |
rashmivenkataramaiah | 41:1141a75eacc4 | 396 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 397 | else |
rashmivenkataramaiah | 41:1141a75eacc4 | 398 | { |
rashmivenkataramaiah | 41:1141a75eacc4 | 399 | screen_ecg(); //ecg main screen |
rashmivenkataramaiah | 41:1141a75eacc4 | 400 | state1=0; |
rashmivenkataramaiah | 41:1141a75eacc4 | 401 | state=5; |
nikitateggi | 1:8316c23ec6b9 | 402 | nstate=state; |
rashmivenkataramaiah | 41:1141a75eacc4 | 403 | } |
rashmivenkataramaiah | 41:1141a75eacc4 | 404 | EnableTouch(); |
nikitateggi | 1:8316c23ec6b9 | 405 | break; |
nikitateggi | 1:8316c23ec6b9 | 406 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 407 | case 6: |
rashmivenkataramaiah | 41:1141a75eacc4 | 408 | DisableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 409 | screen_bp(); // bp main screen |
nikitateggi | 3:9a06c2bed650 | 410 | state1=0; |
nikitateggi | 3:9a06c2bed650 | 411 | state=8; |
rashmivenkataramaiah | 41:1141a75eacc4 | 412 | nstate=state; |
rashmivenkataramaiah | 41:1141a75eacc4 | 413 | EnableTouch(); |
nikitateggi | 3:9a06c2bed650 | 414 | break; |
nikitateggi | 3:9a06c2bed650 | 415 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 416 | case 7: |
rashmivenkataramaiah | 41:1141a75eacc4 | 417 | DisableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 418 | glc(pid); // glc measurement |
nikitateggi | 1:8316c23ec6b9 | 419 | glc_flag=1; |
avp2417 | 35:43133f017ed4 | 420 | wait(1); |
nikitateggi | 4:6bd81bb1790d | 421 | state1=0; |
nikitateggi | 4:6bd81bb1790d | 422 | screen_glc_2(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 423 | state=6; |
rashmivenkataramaiah | 41:1141a75eacc4 | 424 | eprom_write_8(30,0); |
rashmivenkataramaiah | 41:1141a75eacc4 | 425 | nstate=state; |
rashmivenkataramaiah | 41:1141a75eacc4 | 426 | EnableTouch(); |
nikitateggi | 1:8316c23ec6b9 | 427 | break; |
nikitateggi | 1:8316c23ec6b9 | 428 | |
nikitateggi | 3:9a06c2bed650 | 429 | case 8: DisableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 430 | ecg_countdown(); // countdown before ecg capture |
rashmivenkataramaiah | 41:1141a75eacc4 | 431 | heart_rate=ecg(pid); // capturing ecg |
nikitateggi | 1:8316c23ec6b9 | 432 | state1=0; |
nikitateggi | 20:7c64e6ecad76 | 433 | if (heart_rate==0) |
nikitateggi | 20:7c64e6ecad76 | 434 | { |
avp2417 | 34:8f6b0dc124e8 | 435 | |
nikitateggi | 20:7c64e6ecad76 | 436 | screen_ecg_lead(); |
nikitateggi | 20:7c64e6ecad76 | 437 | } |
rashmivenkataramaiah | 41:1141a75eacc4 | 438 | else if(heart_rate==1) // if heart rate goes above or below range display error // 10/7/17 nikita |
nikitateggi | 31:0f67acfc6236 | 439 | { |
nikitateggi | 31:0f67acfc6236 | 440 | screen_ecg_error(); |
nikitateggi | 31:0f67acfc6236 | 441 | |
nikitateggi | 31:0f67acfc6236 | 442 | } |
avp2417 | 34:8f6b0dc124e8 | 443 | else |
avp2417 | 34:8f6b0dc124e8 | 444 | { |
avp2417 | 34:8f6b0dc124e8 | 445 | |
nikitateggi | 20:7c64e6ecad76 | 446 | screen_ecg_2(heart_rate); |
nikitateggi | 20:7c64e6ecad76 | 447 | ecg_flag=1; |
rashmivenkataramaiah | 43:85a7f399cb9d | 448 | } |
nikitateggi | 1:8316c23ec6b9 | 449 | state=6; |
nikitateggi | 24:d992ee8369f4 | 450 | eprom_write_8(30,1); |
nikitateggi | 20:7c64e6ecad76 | 451 | nstate=state; |
nikitateggi | 20:7c64e6ecad76 | 452 | screen_ecg_bp(); |
nikitateggi | 4:6bd81bb1790d | 453 | EnableTouch(); |
nikitateggi | 1:8316c23ec6b9 | 454 | break; |
rashmivenkataramaiah | 41:1141a75eacc4 | 455 | |
nikitateggi | 49:3ff80c4bc1be | 456 | case 9: |
nikitateggi | 3:9a06c2bed650 | 457 | DisableTouch(); |
rashmivenkataramaiah | 41:1141a75eacc4 | 458 | screen_bp2(); // bp main screen |
rashmivenkataramaiah | 41:1141a75eacc4 | 459 | bp_countdown(); // countdown for bp |
rashmivenkataramaiah | 41:1141a75eacc4 | 460 | bp(pid); // measuring bp earlier bp() changed to bp(pid) 28/4/2017 |
nikitateggi | 3:9a06c2bed650 | 461 | state1=0; |
nikitateggi | 3:9a06c2bed650 | 462 | state=6; |
nikitateggi | 24:d992ee8369f4 | 463 | eprom_write_8(30,2); |
nikitateggi | 3:9a06c2bed650 | 464 | nstate=state; |
nikitateggi | 3:9a06c2bed650 | 465 | EnableTouch(); |
nikitateggi | 3:9a06c2bed650 | 466 | break; |
nikitateggi | 31:0f67acfc6236 | 467 | |
nikitateggi | 31:0f67acfc6236 | 468 | |
nikitateggi | 31:0f67acfc6236 | 469 | case 10 : DisableTouch(); |
nikitateggi | 31:0f67acfc6236 | 470 | wait_ms(300); |
nikitateggi | 31:0f67acfc6236 | 471 | EnableTouch(); |
nikitateggi | 31:0f67acfc6236 | 472 | state=nstate; |
nikitateggi | 31:0f67acfc6236 | 473 | break; |
nikitateggi | 31:0f67acfc6236 | 474 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 475 | case 11 : |
rashmivenkataramaiah | 41:1141a75eacc4 | 476 | DisableTouch(); |
rashmivenkataramaiah | 42:c81673b04b6a | 477 | //sd_read(pid_btpid); //read pid from sd card |
rashmivenkataramaiah | 42:c81673b04b6a | 478 | //current_test_pid=pid_btpid[0]; |
rashmivenkataramaiah | 42:c81673b04b6a | 479 | //bt_file_sent_pid=pid_btpid[1]; |
rashmivenkataramaiah | 42:c81673b04b6a | 480 | //screen_patient_info(current_test_pid, bt_file_sent_pid); |
rashmivenkataramaiah | 42:c81673b04b6a | 481 | screen_patient_info(get_filepid(), get_btpid()); |
rashmivenkataramaiah | 41:1141a75eacc4 | 482 | state1=0; |
rashmivenkataramaiah | 41:1141a75eacc4 | 483 | state=12; |
rashmivenkataramaiah | 41:1141a75eacc4 | 484 | EnableTouch(); |
nikitateggi | 49:3ff80c4bc1be | 485 | break; |
nikitateggi | 49:3ff80c4bc1be | 486 | |
nikitateggi | 49:3ff80c4bc1be | 487 | case 13 : //display screen for debug |
nikitateggi | 49:3ff80c4bc1be | 488 | DisableTouch(); |
nikitateggi | 49:3ff80c4bc1be | 489 | screen_debug(); |
nikitateggi | 49:3ff80c4bc1be | 490 | state1=0; |
nikitateggi | 49:3ff80c4bc1be | 491 | state=13; |
nikitateggi | 49:3ff80c4bc1be | 492 | nstate=state; |
nikitateggi | 49:3ff80c4bc1be | 493 | EnableTouch(); |
nikitateggi | 49:3ff80c4bc1be | 494 | break; |
nikitateggi | 49:3ff80c4bc1be | 495 | |
nikitateggi | 49:3ff80c4bc1be | 496 | case 14 : |
nikitateggi | 49:3ff80c4bc1be | 497 | DisableTouch(); //state to delete SD card |
nikitateggi | 49:3ff80c4bc1be | 498 | delete_sdcard(); |
nikitateggi | 49:3ff80c4bc1be | 499 | screen_sdcard_delete(); |
nikitateggi | 49:3ff80c4bc1be | 500 | state1=0; |
nikitateggi | 49:3ff80c4bc1be | 501 | state= 12; |
nikitateggi | 49:3ff80c4bc1be | 502 | nstate=state; |
nikitateggi | 49:3ff80c4bc1be | 503 | EnableTouch(); |
nikitateggi | 49:3ff80c4bc1be | 504 | break; |
nikitateggi | 49:3ff80c4bc1be | 505 | |
nikitateggi | 49:3ff80c4bc1be | 506 | case 15 : |
nikitateggi | 49:3ff80c4bc1be | 507 | DisableTouch(); |
nikitateggi | 49:3ff80c4bc1be | 508 | // screen_sdcard_read(); //state to delete SD card |
nikitateggi | 50:b42238e7f46d | 509 | gc.printf("Enter the PID number"); |
nikitateggi | 50:b42238e7f46d | 510 | /// gc.scanf("%d", &pid_read); |
nikitateggi | 50:b42238e7f46d | 511 | // gc.printf("%d\n",pid_read); |
nikitateggi | 50:b42238e7f46d | 512 | read_sdcard_file(); |
nikitateggi | 49:3ff80c4bc1be | 513 | // screen_sdcard_read(); |
nikitateggi | 49:3ff80c4bc1be | 514 | state1=0; |
nikitateggi | 49:3ff80c4bc1be | 515 | state= 12; |
nikitateggi | 49:3ff80c4bc1be | 516 | nstate=state; |
nikitateggi | 49:3ff80c4bc1be | 517 | EnableTouch(); |
nikitateggi | 49:3ff80c4bc1be | 518 | break; |
nikitateggi | 31:0f67acfc6236 | 519 | |
nikitateggi | 1:8316c23ec6b9 | 520 | default : |
nikitateggi | 3:9a06c2bed650 | 521 | |
nikitateggi | 1:8316c23ec6b9 | 522 | state1=nstate1; |
nikitateggi | 1:8316c23ec6b9 | 523 | break; |
nikitateggi | 1:8316c23ec6b9 | 524 | |
nikitateggi | 0:c47fb0c1bbf6 | 525 | |
nikitateggi | 0:c47fb0c1bbf6 | 526 | } |
nikitateggi | 0:c47fb0c1bbf6 | 527 | |
nikitateggi | 0:c47fb0c1bbf6 | 528 | |
nikitateggi | 0:c47fb0c1bbf6 | 529 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 530 | return state; |
nikitateggi | 0:c47fb0c1bbf6 | 531 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 532 | } |
rashmivenkataramaiah | 41:1141a75eacc4 | 533 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 534 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 535 | bool get_filecreated_status(void) //function to get file created status |
rashmivenkataramaiah | 41:1141a75eacc4 | 536 | { |
rashmivenkataramaiah | 41:1141a75eacc4 | 537 | return file_created_status; |
rashmivenkataramaiah | 41:1141a75eacc4 | 538 | } |
rashmivenkataramaiah | 41:1141a75eacc4 | 539 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 540 | void set_filecreated_status(void) //function to set file created status |
rashmivenkataramaiah | 41:1141a75eacc4 | 541 | { |
rashmivenkataramaiah | 42:c81673b04b6a | 542 | file_created_status = true; |
rashmivenkataramaiah | 41:1141a75eacc4 | 543 | } |
rashmivenkataramaiah | 41:1141a75eacc4 | 544 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 545 | |
rashmivenkataramaiah | 41:1141a75eacc4 | 546 | void clear_filecreated_status(void) //function to clear file created status |
rashmivenkataramaiah | 41:1141a75eacc4 | 547 | { |
rashmivenkataramaiah | 42:c81673b04b6a | 548 | file_created_status = false; |
rashmivenkataramaiah | 42:c81673b04b6a | 549 | } |
rashmivenkataramaiah | 42:c81673b04b6a | 550 | |
rashmivenkataramaiah | 43:85a7f399cb9d | 551 | void increment_filepid (void) //increment pid if a test is completed |
rashmivenkataramaiah | 42:c81673b04b6a | 552 | { |
rashmivenkataramaiah | 43:85a7f399cb9d | 553 | //uint32_t filepid_btpid[2] = {}; |
rashmivenkataramaiah | 42:c81673b04b6a | 554 | |
rashmivenkataramaiah | 42:c81673b04b6a | 555 | //set_filecreated_status(); //set it to make it append mode |
rashmivenkataramaiah | 42:c81673b04b6a | 556 | sd_read(filepid_btpid); //read pid from sd card |
rashmivenkataramaiah | 42:c81673b04b6a | 557 | filepid_btpid[0] = filepid_btpid[0] + 1; //increment it by 1 |
rashmivenkataramaiah | 42:c81673b04b6a | 558 | sd_write(filepid_btpid); //write it back to sd card |
rashmivenkataramaiah | 42:c81673b04b6a | 559 | |
rashmivenkataramaiah | 42:c81673b04b6a | 560 | } |
rashmivenkataramaiah | 42:c81673b04b6a | 561 | |
rashmivenkataramaiah | 43:85a7f399cb9d | 562 | void increment_btpid (void) //increment pid if a test is completed |
rashmivenkataramaiah | 43:85a7f399cb9d | 563 | { |
rashmivenkataramaiah | 43:85a7f399cb9d | 564 | //uint32_t filepid_btpid[2] = {}; |
rashmivenkataramaiah | 43:85a7f399cb9d | 565 | |
rashmivenkataramaiah | 43:85a7f399cb9d | 566 | //set_filecreated_status(); //set it to make it append mode |
rashmivenkataramaiah | 43:85a7f399cb9d | 567 | sd_read(filepid_btpid); //read pid from sd card |
nikitateggi | 45:067673dae242 | 568 | filepid_btpid[1] = filepid_btpid[1] + 1; //increment it by 1 |
rashmivenkataramaiah | 43:85a7f399cb9d | 569 | sd_write(filepid_btpid); //write it back to sd card |
rashmivenkataramaiah | 43:85a7f399cb9d | 570 | |
rashmivenkataramaiah | 43:85a7f399cb9d | 571 | } |
rashmivenkataramaiah | 43:85a7f399cb9d | 572 | |
rashmivenkataramaiah | 42:c81673b04b6a | 573 | uint32_t get_filepid(void) |
rashmivenkataramaiah | 42:c81673b04b6a | 574 | { |
rashmivenkataramaiah | 42:c81673b04b6a | 575 | //uint32_t filepid_btpid[2] = {}; |
rashmivenkataramaiah | 42:c81673b04b6a | 576 | uint32_t filepid = 0; |
rashmivenkataramaiah | 42:c81673b04b6a | 577 | |
rashmivenkataramaiah | 42:c81673b04b6a | 578 | sd_read(filepid_btpid); //read pid from sd card |
nikitateggi | 45:067673dae242 | 579 | filepid = filepid_btpid[0]; |
rashmivenkataramaiah | 42:c81673b04b6a | 580 | return filepid; |
rashmivenkataramaiah | 42:c81673b04b6a | 581 | |
rashmivenkataramaiah | 42:c81673b04b6a | 582 | } |
rashmivenkataramaiah | 42:c81673b04b6a | 583 | |
rashmivenkataramaiah | 42:c81673b04b6a | 584 | void store_filepid(uint32_t pid) |
rashmivenkataramaiah | 42:c81673b04b6a | 585 | { |
rashmivenkataramaiah | 42:c81673b04b6a | 586 | //uint32_t filepid_btpid[2] = {}; |
rashmivenkataramaiah | 42:c81673b04b6a | 587 | sd_read(filepid_btpid); //read pid from sd card |
rashmivenkataramaiah | 42:c81673b04b6a | 588 | filepid_btpid[0] = pid; |
rashmivenkataramaiah | 42:c81673b04b6a | 589 | sd_write(filepid_btpid); //write it back to sd card |
rashmivenkataramaiah | 42:c81673b04b6a | 590 | |
rashmivenkataramaiah | 42:c81673b04b6a | 591 | } |
rashmivenkataramaiah | 42:c81673b04b6a | 592 | |
rashmivenkataramaiah | 42:c81673b04b6a | 593 | uint32_t get_btpid(void) |
rashmivenkataramaiah | 42:c81673b04b6a | 594 | { |
rashmivenkataramaiah | 42:c81673b04b6a | 595 | //uint32_t filepid_btpid[2] = {}; |
rashmivenkataramaiah | 42:c81673b04b6a | 596 | uint32_t btpid = 0; |
rashmivenkataramaiah | 42:c81673b04b6a | 597 | |
rashmivenkataramaiah | 42:c81673b04b6a | 598 | sd_read(filepid_btpid); //read pid from sd card |
nikitateggi | 45:067673dae242 | 599 | btpid = filepid_btpid[1]; |
rashmivenkataramaiah | 42:c81673b04b6a | 600 | return btpid; |
rashmivenkataramaiah | 42:c81673b04b6a | 601 | |
rashmivenkataramaiah | 42:c81673b04b6a | 602 | } |
rashmivenkataramaiah | 42:c81673b04b6a | 603 | |
rashmivenkataramaiah | 42:c81673b04b6a | 604 | void store_btpid(uint32_t bt_pid) |
rashmivenkataramaiah | 42:c81673b04b6a | 605 | { |
rashmivenkataramaiah | 42:c81673b04b6a | 606 | //uint32_t filepid_btpid[2] = {}; |
rashmivenkataramaiah | 42:c81673b04b6a | 607 | |
rashmivenkataramaiah | 42:c81673b04b6a | 608 | sd_read(filepid_btpid); //read pid from sd card |
rashmivenkataramaiah | 42:c81673b04b6a | 609 | filepid_btpid[1] = bt_pid; |
rashmivenkataramaiah | 42:c81673b04b6a | 610 | sd_write(filepid_btpid); //write it back to sd card |
rashmivenkataramaiah | 42:c81673b04b6a | 611 | |
rashmivenkataramaiah | 42:c81673b04b6a | 612 | } |
rashmivenkataramaiah | 42:c81673b04b6a | 613 | |
nikitateggi | 45:067673dae242 | 614 | |
nikitateggi | 44:05dbea558c9a | 615 | uint32_t get_timer_bluetooth() |
nikitateggi | 44:05dbea558c9a | 616 | { |
nikitateggi | 45:067673dae242 | 617 | return timer_bt.read_ms(); |
nikitateggi | 44:05dbea558c9a | 618 | } |
nikitateggi | 45:067673dae242 | 619 | |
nikitateggi | 45:067673dae242 | 620 | void battery_status_monitoring() |
nikitateggi | 45:067673dae242 | 621 | { |
nikitateggi | 45:067673dae242 | 622 | if(timer_battery.read_ms() > BATTERY_TIMER_VALUE ) |
nikitateggi | 45:067673dae242 | 623 | { |
nikitateggi | 45:067673dae242 | 624 | battery_monitor(); |
nikitateggi | 45:067673dae242 | 625 | timer_battery.reset(); |
nikitateggi | 45:067673dae242 | 626 | } |
nikitateggi | 49:3ff80c4bc1be | 627 | } |
nikitateggi | 49:3ff80c4bc1be | 628 | |
nikitateggi | 49:3ff80c4bc1be | 629 | uint8_t read_debug_status() |
nikitateggi | 49:3ff80c4bc1be | 630 | { |
nikitateggi | 49:3ff80c4bc1be | 631 | return debug_mode; |
nikitateggi | 45:067673dae242 | 632 | } |