Beispiel #1
0
main(){
	DDRD = 0x3E;	// set keypad I/O data direction register

	NewKey = 0; 	// reset key variables
	LastKey = 0xFF;

	// Initialize the LCD
    LCD_Command(0x3C);                 // initialize command
    LCD_Command(0x0C);                 // display on, cursor off
    LCD_Command(0x06);
    LCD_Command(0x01);

    // Display Header Information on LCD
    LCD_Command(LINE_1);               // goto lcd line 1
    LCDprint("Keypad Test");
    LCD_Command(LINE_2);               // goto lcd line 2
    LCDprint("Press Keys");
    LCD_Command(LINE_3);               // goto lcd line 3

	// main loop .. endless
	for( ; ;){

		if(kbhit()){				// if new key pressed
			cprint(NewKey);			// display it
		}

	}
}
Beispiel #2
0
void showCredits(void){
    clearLCD();
    // go to position 1, 1
    // print 'Credits:'
    goToLine(1);
    LCDprint("Credits: ");
    
    goToLine(2);
    LCDprint("-Francis Papienau");
    
    goToLine(3);
    LCDprint("-Thai Nguyen");
}
Beispiel #3
0
void initMenusThroughMenus(void){
    clearLCD();
    goToLine(1);
    // install the menus in memory
    LCDprint("Menus init(); OK");
    delay(100);
}
Beispiel #4
0
void attachInterrupts(void){

// ----- ISR #1 STARTUP PROCEDURES ------
    
    // Installing Power Supply ISR
    // NEEDED TO DETERMINE IF A POWER
    // FAILURE HAS OCCURED
    
#ifdef PWRFailDetect
    // Interrupt triggered by falling voltage on power supply input
    LCDprintln(" * Attaching powerfail ISR      ");
    attachInterrupt(0, powerFail, FALLING);
    LCDprintln("   [OK]    ");
#endif
 
// ----- ISR #2 STARTUP PROCEDURES ------
    
    // Installing Loggin On/Off ISR
    // NEEDED TO START OR STOP THE LOGGING
    // ON THE VDIP.
    
#ifdef EnableLogging
    LCDprintln(" * Attaching logging ISR        ");
    // Interrupt triggered by pressing "log on/off" button
    attachInterrupt(2, LoggingChange, FALLING);
    LCDprint("  [OK]    ");
#endif
    LCDprintln("Start. Complete!");    
}
Beispiel #5
0
static void drawRxChannel(uint8_t channelIndex, uint8_t width)
{
    LCDprint(rcChannelLetters[channelIndex]);

    const uint32_t percentage = (constrain(rcData[channelIndex], PWM_RANGE_MIN, PWM_RANGE_MAX) - PWM_RANGE_MIN) * 100 / (PWM_RANGE_MAX - PWM_RANGE_MIN);
    drawHorizonalPercentageBar(width - 1, percentage);
}
Beispiel #6
0
void openNewFiles(void){

  // open new files to store values in. Using the EEPROM
  // to print the titles of the files, and the folders

  // make dir;
  // ‘MKD’<sp><name><cr>

  HOSTUSB.print("MKD ");
  HOSTUSB.print(SessionFolder);
  HOSTUSB.print(SessionID);
  HOSTUSB.print(13, BYTE);
  delay(100);

  HOSTUSB.print("CD ");
  HOSTUSB.print(SessionFolder);
  HOSTUSB.print(SessionID);
  HOSTUSB.print(13, BYTE);
  delay(100);

  // command for USB FTDI: OTW<sp>NAME<cr>
  // Creating files

  HOSTUSB.print("OPW TempData");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  HOSTUSB.print("OPW Vitals");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  HOSTUSB.print("OPW Others");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  HOSTUSB.print("OPW System");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".txt");
  HOSTUSB.print(13, BYTE);
  delay(100);

  HOSTUSB.print("OPW Acknowledge");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".txt");
  HOSTUSB.print(13, BYTE);
  delay(100);

  // sending through USB the new File System
  goToLine(1);
  LCDprint("New files opened");
  delay(1000);

}
Beispiel #7
0
// LCDbar(n,v) : draw a bar graph - n number of chars for width, v value in % to display
void drawHorizonalPercentageBar(uint8_t width,uint8_t percent) {
    uint8_t i, j;

    if (percent > 100)
        percent = 100;

    j = (width * percent) / 100;

    for (i = 0; i < j; i++)
        LCDprint(159); // full

    if (j < width)
        LCDprint(154 + (percent * width * 5 / 100 - 5 * j)); // partial fill

    for (i = j + 1; i < width; i++)
        LCDprint(154); // empty
}
Beispiel #8
0
int askforUSB(void){
    int continueFlag = 0, choice = 0;
    
    clearLCD();
    
    // print the prompt
    goToLine(1);
    LCDprint("***************");
    
    goToLine(2);
    LCDprint("Record?");
    
    goToLine(3);
    LCDprint("-> YES  [Left]");
    
    goToLine(4);
    LCDprint("-> NO   [Right]");
    
    goToLine(5);
    LCDprint("***************");
    
    //resetting the buttons to up position
    reset_buttons();
    
    do{
        // if left is pushed
        if(LEFT_BUTTON_PRESSED){ 
            // Yes record
            choice = 1;
            continueFlag = 1;
            // if the right is pushed
        }else if(RIGHT_BUTTON_PRESSED){
            // no do not record
            choice = 0;
            continueFlag = 1;
            // if the middle is pushed
        }
        //do while an input is noticed
    }while(continueFlag == 0);
    
    // reset the buttons again
    reset_buttons();
    
    // return the choice
    return choice;
}
void main (void) 
{
	float period;
	
	PCA0MD &= ~0x40; // WDTE = 0 (clear watchdog timer enable)
	PORT_Init();     // Initialize Port I/O
	SYSCLK_Init ();  // Initialize Oscillator
	UART0_Init();    // Initialize UART0
	TIMER0_Init();

	printf("\x1b[2J"); // Clear screen using ANSI escape sequence.

	printf ("Period measurement at pin P0.1 using Timer 0.\n"
	        "File: %s\n"
	        "Compiled: %s, %s\n\n",
	        __FILE__, __DATE__, __TIME__);

    while (1)
    {
    	// Reset the counter
		TL0=0; 
		TH0=0;
		TF0=0;
		overflow_count=0;
		
		while(P0_1!=0); // Wait for the signal to be zero
		while(P0_1!=1); // Wait for the signal to be one
		TR0=1; // Start the timer
		while(P0_1!=0) // Wait for the signal to be zero
		{
			if(TF0==1) // Did the 16-bit timer overflow?
			{
				TF0=0;
				overflow_count++;
			}
		}
		while(P0_1!=1) // Wait for the signal to be one
		{
			if(TF0==1) // Did the 16-bit timer overflow?
			{
				TF0=0;
				overflow_count++;
			}
		}
		TR0=0; // Stop timer 0, the 24-bit number [overflow_count-TH0-TL0] has the period!
		period=(overflow_count*65536.0+TH0*256.0+TL0)*(12.0/SYSCLK);
		// Send the period to the serial port
		printf( "\rf=%fs" , period);
		
		heart_rate = 1.0/(period/60.0); 
		bpm = (int) heart_rate; 
		
		LCDprint(bpm, 1, 5); //print heart rate bpm to LCD display
		
    }
  
	
}
Beispiel #10
0
void processTerminalCommands(void){
    
#ifdef USBConnected
    
    
    
#else
    LCDprint("***ERROR*** (Xbee)");
#endif
   
}
Beispiel #11
0
void deleteFiles(void){

  // delete the specific files written in the root directory

  // command for FTDI : DLF<sp>NAME<cr>
  // deleting files

  HOSTUSB.print("DLF TempData");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  HOSTUSB.print("DLF Vitals");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  HOSTUSB.print("DLF Others");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  HOSTUSB.print("DLF System");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".txt");
  HOSTUSB.print(13, BYTE);
  delay(100);

  HOSTUSB.print("DLF Acknowledge");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".txt");
  HOSTUSB.print(13, BYTE);
  delay(100);

  // go back to root
  HOSTUSB.print("CD ..");
  HOSTUSB.print(13, BYTE);
  delay(100);

  // delete dir
  HOSTUSB.print("DLD "+SessionFolder);
  HOSTUSB.print(13, BYTE);
  delay(100);

  // sending through USB the new File System
  goToLine(1);
  LCDprint("Files/Dir Deleted");
  delay(1000);

}
Beispiel #12
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);
}
Beispiel #13
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);
}
Beispiel #14
0
static void showRxPage(void)
{
    for (int channelIndex = 0; channelIndex < rxRuntimeConfig.channelCount && channelIndex < RX_CHANNELS_PER_PAGE_COUNT; channelIndex += 2) {
        i2c_OLED_set_line(bus, (channelIndex / 2) + PAGE_TITLE_LINE_COUNT);

        drawRxChannel(channelIndex, HALF_SCREEN_CHARACTER_COLUMN_COUNT);

        if (channelIndex >= rxRuntimeConfig.channelCount) {
            continue;
        }

        if (IS_SCREEN_CHARACTER_COLUMN_COUNT_ODD) {
            LCDprint(' ');
        }

        drawRxChannel(channelIndex + PAGE_TITLE_LINE_COUNT, HALF_SCREEN_CHARACTER_COLUMN_COUNT);
    }
}
Beispiel #15
0
void closeAllFiles(void){

  // Close all files for writting

  // command for USB FTDI: CLF<sp>NAME<cr>

  HOSTUSB.print("CLF TempData");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  HOSTUSB.print("CLF Vitals");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  HOSTUSB.print("CLF Others");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  HOSTUSB.print("CLF System");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".txt");
  HOSTUSB.print(13, BYTE);
  delay(100);

  HOSTUSB.print("CLF Acknowledge");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".txt");
  HOSTUSB.print(13, BYTE);
  delay(100);

  goToLine(1);
  LCDprint("Files Closed");
  delay(1000);
}
Beispiel #16
0
void printBattLevel(void){
    
    // go to x=123, y=1 and print the battery level sprite
    goToPosition(123,1);
    
    if((tempBat/9.0)*100.00 < 10.0){
        LCDprint(Batt10);
    }else if((tempBat/9.0)*100.00 >= 10.0 ||(tempBat/9.0)*100.00 <30.0){
        LCDprint(Batt30);
    }else if((tempBat/9.0)*100.00 >= 30.0 ||(tempBat/9.0)*100.00 <45.0){
        LCDprint(Batt45);
    }else if((tempBat/9.0)*100.00 >= 45.0 ||(tempBat/9.0)*100.00 <60.0){
        LCDprint(Batt60);
    }else if((tempBat/9.0)*100.00 >= 60.0 ||(tempBat/9.0)*100.00 <75.0){
        LCDprint(Batt75);
    }else if((tempBat/9.0)*100.00 >= 75.0){
        LCDprint(FullBatt);  
    }
    
}
Beispiel #17
0
void printNUll(void){
    
    // Print NULL
    LCDprint(" ");
}
Beispiel #18
0
void printHeaders(void){

  // print the headers for the CSV files

  // 1. open the file, 
  // 2. send the print command
  // 3. send the length 
  // 4. send data to be written
  // 5. close the file

  // ========== Temperature File =============

  //1.
  HOSTUSB.print("OPW TempData");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  //2.
  HOSTUSB.print("WRF ");

  //3.
  HOSTUSB.print(TempHeader.length());
  HOSTUSB.print(13, BYTE);

  //4.
  HOSTUSB.print(TempHeader);
  HOSTUSB.print(13, BYTE);

  //6.
  HOSTUSB.print("CLF TempData");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  // ========== Vital Signs File =============

  //1.
  HOSTUSB.print("OPW Vitals");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  //2.
  HOSTUSB.print("WRF ");

  //3.
  HOSTUSB.print(VitalsHeader.length());
  HOSTUSB.print(13, BYTE);

  //4.
  HOSTUSB.print(VitalsHeader);
  HOSTUSB.print(13, BYTE);

  //5.
  HOSTUSB.print("CLF Vitals");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  // ========== Other Parameters File =============

  //1.
  HOSTUSB.print("OPW Others");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  //2.
  HOSTUSB.print("WRF ");

  //3.
  HOSTUSB.print(OthersHeader.length());
  HOSTUSB.print(13, BYTE);

  //4.
  HOSTUSB.print(OthersHeader);
  HOSTUSB.print(13, BYTE);

  //5.
  HOSTUSB.print("CLF Others");
  HOSTUSB.print(SessionID);
  HOSTUSB.print(".CSV");
  HOSTUSB.print(13, BYTE);
  delay(100);

  goToLine(1);
  LCDprint("Headers Printed!");
  delay(1000);

}
Beispiel #19
0
void printXbeeSymbol(void){
    // Print the XBee symbol
    goToPosition(117,1);
    LCDprint(Connected_XBee_Symbol);
}
Beispiel #20
0
void printPCSymbol(void){
    
    // Print the PC symbol
    goToPosition(117,1);
    LCDprint(Connected_PC_Symbol);
}
Beispiel #21
0
void printACK_Sys_files(void){

  // ========== Print ACK FILE =============

  // print an acknoledgment that the system is OK
  // and running with no issues.

  // OPEN ACK FILE
  HOSTUSB.print("OPW Acknowledge.txt");
  HOSTUSB.print(13, BYTE);
  delay(100);

  // SEND print COMMAND
  HOSTUSB.print("WRF ");

  // SEND THE LENGTH OF THE STRING
  StartTime = millis();

  HOSTUSB.print(ACK.length());
  HOSTUSB.print(13, BYTE);
  delay(100);

  // SEND DATA
  HOSTUSB.print(ACK);
  HOSTUSB.print(13, BYTE);
  delay(100);

  // CLOSE FILE
  HOSTUSB.print("CLF Acknowledge.txt");
  HOSTUSB.print(13, BYTE);
  delay(100);

  // ========== Print SYSTEM INFO File =============

  // Print the system file with:
  //  -> Fimware Ver.
  //  -> Drive Info
  //  -> Drive Info Extended
  //  -> Free Mem.
  //  -> Current DIR

  HOSTUSB.print("OPW System.txt");
  HOSTUSB.print(13, BYTE);
  delay(100);

  // ========== frimware version =============

  //get
  HOSTUSB.print("FWV");
  HOSTUSB.print(13, BYTE);

  String buffer, printString;
  while(HOSTUSB.available() > 0){
    buffer = buffer + HOSTUSB.read();
  }

  printString = "This is the system file. It is used to allow for\n"
    "Debugging perposes. It shows the follwing:\n"
    "\t-> firmware version: "+ buffer + "\n\n";

  HOSTUSB.print("WRF ");
  HOSTUSB.print(printString.length());
  HOSTUSB.print(13, BYTE);

  // print
  HOSTUSB.print(printString);
  HOSTUSB.print(13, BYTE);
  delay(100);

  // ========== free space =============

  //get
  HOSTUSB.print("FSE");
  HOSTUSB.print(13, BYTE);

  buffer = NULL;
  printString =NULL;

  while(HOSTUSB.available() > 0){
    buffer = buffer + HOSTUSB.read();
  }

  printString = "\t-> free space on USB: " + buffer + "\n\n";

  HOSTUSB.print("WRF ");
  HOSTUSB.print(printString.length());
  HOSTUSB.print(13, BYTE);

  // print
  HOSTUSB.print(printString);
  HOSTUSB.print(13, BYTE);
  delay(100);

  // ========== current directory =============

  // get
  HOSTUSB.print("DIR");
  HOSTUSB.print(13, BYTE);

  buffer = NULL;
  printString =NULL;

  while(HOSTUSB.available() > 0){
    buffer = buffer + HOSTUSB.read();
  }

  printString = "\t-> Current Directory: " + buffer + "\n\n";

  HOSTUSB.print("WRF ");
  HOSTUSB.print(printString.length());
  HOSTUSB.print(13, BYTE);

  // print
  HOSTUSB.print(printString);
  HOSTUSB.print(13, BYTE);
  delay(100);

  // ========== device information =============

  //get
  HOSTUSB.print("IDDE");
  HOSTUSB.print(13, BYTE);

  buffer = NULL;
  printString =NULL;

  while(HOSTUSB.available() > 0){
    buffer = buffer + HOSTUSB.read();
  }

  printString = "\t-> Additionnal Info: \n" + buffer + "\n\n" +
    "*********************************************\n" +
    "This file is for debugging purposes only and\n" +
    "should not be taken as the end all of all.\n" +
    "*********************************************\n" +
    "This process took approximetly: " + millis() + "\n";

  HOSTUSB.print("WRF ");
  HOSTUSB.print(printString.length());
  HOSTUSB.print(13, BYTE);

  // print
  HOSTUSB.print(printString);
  HOSTUSB.print(13, BYTE);
  delay(100);

  // LCD ACK of printing done!
  goToLine(1);
  LCDprint("System/ACK printed!!!");
  delay(1000);

}
Beispiel #22
0
void printDebugSymbol(void){
    
    // Print the Debug Symbol
    goToPosition(117,1);
    LCDprint('D');
}
Beispiel #23
0
void printUSBSTORE(void){
    goToPosition(111,1);
    LCDprint(USB_Store_Symbol);
}
Beispiel #24
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);
    
}
Beispiel #25
0
void processTerminalCommands(void){
    clearLCD();
   
    // if the user decided to Store info
    // to the USB drive.
    
    #ifdef StoreUSB
    // Check the logging flag,
    // if the logging flag is 1
    if(LoggingState && !ON){
        LoggingState = 0;
        
        //Stop Logging
        closeAllFiles();
        
        //Print to LCD
        goToLine(1);
        LCDprint("Stop logging");
    }
    
    // if the logging flag is 0
    if(!LoggingState && ON){
        LoggingState = 1;
        
        //Start Logging
        openNewFiles();
        
        //Print to LCD
        goToLine(1);
        LCDprint("Start logging");
    } 
    #endif
    
    #ifdef USB
    
    if(HOSTXbee.available() > 0){
        
        char readChar = HOSTXbee.read();
        
        // Options from Terminal:
        //  1 -> start Logging
        //  2 -> stop Logging
        //  3 -> silent Mode
        //       lights off but logging ON
        //  4 -> display files
        //  5 -> delete files
        //  6 -> directory listing
        //  7 -> suspend the VDIP
        //  8 -> set the VDIP to ASCII mode
        //  else -> Error in the input,
        //  Not a recognized input
        
        if(readChar == '1'){
            
            // Start Logging to USB
            goToLine(1);
            LCDprint("Started Logging");
            LoggingState = 1;
            ON = 1;
            
            openNewFiles();
            goToLine(2);
            LCDprint(">");
            
        }else if(readChar == '2'){
            
            // Stop Logging to USB
            goToLine(1);
            LCDprint("Stopped Logging");
            LoggingState = 0;
            ON = 0;
            
            closeAllFiles();
            
            goToLine(2);
            LCDprint(">");
            
        }else if(readChar == '3'){
            
            // Put in silent mode
            goToLine(1);
            LCDprint("Silent mode");
            turnOffBacklight();
            
            goToLine(2);
            LCDprint(">");
            
        }else if(readChar == '4'){
            
            goToLine(1);
            // Print File System
            LCDprint("Files are written to:");
           
            goToLine(2);
            LCDprint("~\\");        
            
            goToLine(3);
            LCDprint("TempData.CSV");
            
            goToLine(4);
            LCDprint("Vitals.CSV");
            
            goToLine(5);
            LCDprint("Others.CSV");
            
            goToLine(6);
            LCDprint("System.txt");
            
            goToLine(7);
            LCDprint("Acknowledge.txt");
            
            goToLine(8);
            LCDprint(">");
            
        }else if(readChar == '5'){
            
            // Delete files
            goToLine(1);
            LCDprint("Deleting files");
            deleteFiles();
            
            goToLine(2);
            LCDprint(">");
            
        }else if(readChar == '6'){
            
            // Show the directory
            goToLine(1);
            LCDprint("DIR:");
            
            goToLine(2);
            readLineFromVDIP();
            
            goToLine(3);
            LCDprint(">");

        }else if(readChar == '7'){
            
            // Suspend the VDIP
            goToLine(1);
            LCDprint("Suspending:");
            putInSuspendMode();
            
            goToLine(2);
            LCDprint(">");            
            
        }else if(readChar == '8'){

            // Set ASCII mode
            setToASCIIMode();
            
            goToLine(1);
            LCDprint("[OK]");
            
            goToLine(2);
            LCDprint("> ");
            
        }else{
            
            // Print Help Menu
            goToLine(1);
            LCDprint("Unrecognised command '");
            LCDprintChar(readChar);
            LCDprint("'");
            
            delay(1000);
            
            goToLine(1);
            LCDprint("1 - Start logging");
            
            goToLine(2);
            LCDprint("2 - Stop logging");
            
            goToLine(3);
            LCDprint("3 - Silent Mode");
            
            goToLine(4);
            LCDprint("4 - Display Logfiles");
            
            goToLine(5);
            LCDprint("5 - Delete Logfiles");
            
            goToLine(6);
            LCDprint("6 - Directory listing");
            
            goToLine(7);
            LCDprint("7 - Suspend VDIP");
            
            goToLine(8);
            LCDprint("8 - Set to ASCII mode");
            
            delay(1000);
            
            goToLine(1);
            LCDprint("> ");
        }
    }
    #else
    
    // Can't print to Serial since we are using the
    // XBee layer, and we can only send AT Commands.
    // Unless the XBee is in API mode we cannot send
    // Serial Commands directly to the Board...
    
    clearLCD();
    
    goToLine(1);
    LCDprint("***ERROR***");
    #endif
}
//Displays the titles on the LCD screen
void display_titles(void)
{
	dsp(2,0,0);
	LCDprint("Period:  ");
	dsp(2,0,11);
	LCDprint(".");
	dsp(2,0,14);
	LCDprint(" ms");
	
	dsp(2,1,0);
	LCDprint("Freq:");
	dsp(2,1,11);
	LCDprint(".");
	dsp(2,1,14);
	LCDprint(" hz");
	
	dsp(2,2,0);
	LCDprint("HV: ");
	dsp(2,2,4);
	LCDprint(".");
	dsp(2,2,7);
	LCDprint("V");
	
	dsp(2,3,0);
	LCDprint("LV: ");
	dsp(2,3,4);
	LCDprint(".");
	dsp(2,3,7);
	LCDprint("V");
	
	dsp(2,3,10);
	LCDprint("AVG:");
	dsp(2,3,16);
	LCDprint(".");
	dsp(2,3,19);
	LCDprint("V");
	
	dsp(2,2,11);
	LCDprint("DC:");
	dsp(2,2,18);
	LCDprint("%");
}
Beispiel #27
0
void main (void)
{
	float period;
   	float bpm;
   	unsigned int intbpm;
   	char stringbpm[3]; 
	// Configure the LCD
	LCD_4BIT();
	//initialize string
	stringbpm[2] = '\0';
   
	//PCA0MD &= ~0x40; // WDTE = 0 (clear watchdog timer enable)
	PORT_Init();     // Initialize Port I/O
	//SYSCLK_Init ();  // Initialize Oscillator
	//UART0_Init();    // Initialize UART0
	TIMER0_Init();

	printf("\x1b[2J"); // Clear screen using ANSI escape sequence.

	printf ("Period measurement at pin P0.1 using Timer 0.\n"
	        "File: %s\n"
	        "Compiled: %s, %s\n\n",
	        __FILE__, __DATE__, __TIME__);

    while (1)
    {
    	// Reset the counter
		TL0=0; 
		TH0=0;
		TF0=0;
		overflow_count=0;
		
		while(P0_1!=0); // Wait for the signal to be zero
		while(P0_1!=1); // Wait for the signal to be one
		TR0=1; // Start the timer
		while(P0_1!=0) // Wait for the signal to be zero
		{
			if(TF0==1) // Did the 16-bit timer overflow?
			{
				TF0=0;
				overflow_count++;
			}
		}
		while(P0_1!=1) // Wait for the signal to be one
		{
			if(TF0==1) // Did the 16-bit timer overflow?
			{
				TF0=0;
				overflow_count++;
			}
		}
		TR0=0; // Stop timer 0, the 24-bit number [overflow_count-TH0-TL0] has the period!
		period=(overflow_count*65536.0+TH0*256.0+TL0)*(12.0/SYSCLK);
		// Send the period to the serial port
		printf( "\rf=%fs" , period);
		bpm = 1.0/(period/60.0);
		intbpm = bpm;
		//printf("\nbpm=%d\n", intbpm);
		LCDprint("BPM:",1,1);
		int2char(stringbpm, intbpm, 2);
		LCDprint(stringbpm,2,1);
	}
	
}