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