Exemple #1
0
void loop(void){
    
    // A Visual Queue that the System is in a Rolling State
    // Pin 13 -> Lights up a Status LED
    
    digitalWrite(StartupLED, HIGH);

#ifDEf DEBUG
    if(DEBUGsendRandom == 1){
        sendPseudoRandom();
    }
#endif
    
#ifdef MEGA
    
    // Process any commands from the host Terminal ONLY
    // IF THE BOARD IS CONNETED TO A CPU
    processTerminalCommands();
    
#ifdef ConnectedUSB
    // Echo data from the VDIP back to the host if conected to a PC
    processVdipBuffer();
#endif
    
#ifdef EnableLogging
    
    // in this one:
    // ambientTemp, TympTemp, DiffTemp (5 characters -> in 100 we get 20 samples/page)
    
    char vdipBuffer1[100];
    PString logEntryTemp(vdipBuffer1, sizeof(vdipBuffer1)); // Create a PString object called logEntry
    
    // in this one:
    // ECG, SPO2 RAW, SPO2 IR, SPO2 ERROR, RESP (9 characters -> in 180 we get 20 samples/page)
    
    char vdipBuffer2[180];
    PString logEntryVitals(vdipBuffer2, sizeof(vdipBuffer2)); // Create a PString object called logEntry
    
    // in this one:
    // Light, Battery (3 characters -> in 60 we get 20 samples/page)
    
    char vdipBuffer3[60];
    PString logEntryOthers(vdipBuffer3, sizeof(vdipBuffer3)); // Create a PString object called logEntry
    
    char valBuffer[15];  // Buffer for converting numbers to strings before appending to vdipBuffer
#endif
    
    // test buttons
    test_buttons();
    
    sendSensorValues();
    
    FillUSBBuffers();
    
    if(BuffersFull){
        writeUSBBUffer();  
    } 
#endif
}
Exemple #2
0
void viewBatteryLevels(void){
  char Buffer[11];
  PString printable_string(Buffer, sizeof(Buffer));  
  clearLCD();
    
    // display only battery voltage
    goToLine(2);
    LCDprint("Battery Voltages:");
    
    do{
        
        goToLine(3);
        printable_string = "- Board: ";
        printable_string += tempBat;
        printable_string += "V";
        
        LCDprintConst(printable_string);
        
        goToLine(4);
        printable_string = "- ECG: ";
        printable_string += tempECGBat;
        printable_string += "V";
        
        LCDprintConst(printable_string);
        
        if(LEFT_BUTTON_PRESSED){
            break;
        }
        
        #ifdef ConnectedUSB
        // Echo data from the VDIP back to the host if conected to a PC
        processVdipBuffer();
        #endif
        
        // test buttons
        test_buttons();
        
        sendSensorValues();
        
        #ifdef EnableLogging
        FillUSBBuffers();
        
        if(BuffersFull == 1){
            printUSBBUffer();  
        }   
        #endif
        
    }while(1);
}
Exemple #3
0
void viewBatteryLevels(void){
    clearLCD();

    // display only battery voltage
    goToLine(2);
    LCDprint("Battery Voltages:");
    
    do{
        
        goToLine(3);
        LCDprint("- Board: " + tempBat +"V");
        
        goToLine(4);
        LCDprint("- ECG: " + tempECGBat +"V");
        
        if(LEFT_BUTTON_PRESSED){
            break;
        }
        
        #ifdef ConnectedUSB
        // Echo data from the VDIP back to the host if conected to a PC
        processVdipBuffer();
        #endif
        
        // test buttons
        test_buttons();
        
        sendSensorValues();
        
        #ifdef EnableLogging
        FillUSBBuffers();
        
        if(BuffersFull == 1){
            writeUSBBUffer();  
        }   
        #endif
        
    }while(1);
}
Exemple #4
0
void showSystemCom(void){
    
    clearLCD();
    
    // Show the Comms On the system that are activated
    goToLine(2);
    LCDprint("Comms Init():");
    
    do{
        
        // display special characters for:
        // -> Xbee 'X'
        // -> PC 'P'
        // -> Debug 'D'
        // -> Storage 'S'
        // case statement
        
        switch (Connection) {
            case 'X':
                goToLine(3);
                LCDprint("-> XBee");
                break;
            case 'P':
                goToLine(3);
                LCDprint("-> PC-USB");
                break;
                
            default:
                goToLine(3);
                LCDprint("          ");
                break;
        }
        switch (Store) {
            case 'S':
                goToLine(4);
                LCDprint("-> Recording to USB");
                break;
            default:
                goToLine(4);
                LCDprint("-> Not Recording");
                break;
        } 
        
        if(LEFT_BUTTON_PRESSED){
            break;
        }
        
        #ifdef ConnectedUSB
        // Echo data from the VDIP back to the host if conected to a PC
        processVdipBuffer();
        #endif
        
        // test buttons
        test_buttons();
        
        sendSensorValues();
        
        #ifdef EnableLogging
        FillUSBBuffers();
        
        if(BuffersFull == 1){
            printUSBBUffer();  
        }   
        #endif
        
    }while(1);
    
}
Exemple #5
0
void viewHeartBeat(void){
    clearLCD();

    // display the signal strenght ICONS
    
    do{
        if(pulse == 0){
            clearLCD();
            
            //p1 = (44, 22)
            //p2 = (44, 42)
            //p3 = (84, 22)
            //p4 = (82, 42)
            
            
            // p1-------------p3
            //  |              |
            //  |   NO FILL    |
            //  |              |
            //  |              |
            // p2-------------p4
            
            //draw the above box
            drawBox(44, 22, 82, 42, 0);
        }else if( pulse == 0){
            clearLCD();
            
            //p1 = (44, 22)
            //p2 = (44, 42)
            //p3 = (84, 22)
            //p4 = (82, 42)
            
            
            // p1-------------p3
            //  |              |
            //  |    FILL      |
            //  |              |
            //  |              |
            // p2-------------p4
            
            // draw the above filled box
            drawFilledBox(44, 22, 82, 42, 0xFF); 
        }
        
        if(LEFT_BUTTON_PRESSED){
            break;
        }
        
        #ifdef ConnectedUSB
        // Echo data from the VDIP back to the host if conected to a PC
        processVdipBuffer();
        #endif
        
        // test buttons
        test_buttons();
        
        sendSensorValues();
        
        #ifdef EnableLogging
        FillUSBBuffers();
        
        if(BuffersFull == 1){
            printUSBBUffer();  
        }   
        #endif
    }while(1);
}
Exemple #6
0
void state_machine() {
	// Spend most of the time in sleep
	switch (current_state) {
		// LEDs off, waiting for button presses
		case SLEEPING:
			next_state = SLEEPING;
			disp_time(DISABLE);

			//TODO: Go back to sleep
			sleep_proc();
			break;

		case IDLE:
			next_state = IDLE;

			if (timeout_ticks > _LED_TIMEOUT_TICKS) {
				next_state = SLEEPING;
			}

			if (SET || MODE) next_state = WAKE;

			break;

		// LEDs on, waiting for timeout
		case WAKE:
			next_state = WAKE;
			enable_pwm();
			disp_on();

			if (!SET && !MODE) {
				next_state = IDLE;
			}

			if ((debouncer_test(SET_BTN) == LONG_PRESSED) &&
			    (debouncer_test(MODE_BTN) == LONG_PRESSED)) {
				next_state = READY_TO_SET_HOURS;
			}
			break;

		case READY_TO_SET_HOURS:
			next_state = READY_TO_SET_HOURS;
			last_set_state = FALSE;

			flash_mins();
			flash_hours();

			if (!MODE && !SET) next_state = SET_HOURS;

			break;

		// Time set mode, pressing set will increment hours up to 24, then
		// roll over, pressing mode will switch to minute set mode
		case SET_HOURS:
			next_state = SET_HOURS;

			flash_mins();

			if (debouncer_test(MODE_BTN) == DEBOUNCED) {
				next_state = READY_TO_SET_MINS;
			}

			if (debouncer_test(SET_BTN) == DEBOUNCED) {
				last_set_state = TRUE;
			}
			else if (debouncer_test(SET_BTN) == LONG_PRESSED) {
				next_state = QUICK_HOURS_INC;
			}

			if ((last_set_state == TRUE) && !SET) {
				last_set_state = FALSE;
				++my_time.hours;
			}
			break;

		case QUICK_HOURS_INC:
			next_state = QUICK_HOURS_INC;

			flash_mins();

			if (!SET) next_state = SET_HOURS;

			if (quick_inc) {
				quick_inc = FALSE;
				++my_time.hours;
			}

			break;

		case READY_TO_SET_MINS:
			next_state = READY_TO_SET_MINS;
			last_set_state = FALSE;

			flash_mins();
			flash_hours();

			if (!MODE) next_state = SET_MINS;

			break;

		// Time set mode, pressing set will increment minutes up to 59, then
		// roll over, pressing mode will exit time set mode
		case SET_MINS:
			next_state = SET_MINS;

			flash_hours();

			if (debouncer_test(MODE_BTN) == DEBOUNCED) {
				next_state = WAKE;
			}

			if (debouncer_test(SET_BTN) == DEBOUNCED) {
				last_set_state = TRUE;
			}
			else if (debouncer_test(SET_BTN) == LONG_PRESSED) {
				next_state = QUICK_MINS_INC;
			}

			if ((last_set_state == TRUE) && !SET) {
				last_set_state = FALSE;
				++my_time.mins;
			}
			break;

		case QUICK_MINS_INC:
			next_state = QUICK_MINS_INC;

			flash_hours();

			if (!SET) next_state = SET_MINS;

			if (quick_inc) {
				quick_inc = FALSE;
				++my_time.mins;
			}

			break;
		default:
			next_state = IDLE;
			break;
	}

	if (current_state != SLEEPING) {
		test_buttons();
	}

	if (next_state != current_state) {
		current_state = next_state;
	}
}