Embedded software Assessment 2
Dependencies: MCP23017 SDFileSystem USBDevice WattBob_TextLCD mbed
Diff: Function.h
- Revision:
- 17:dba09fb3f508
- Parent:
- 16:0a2138a18f26
- Child:
- 18:f485d46a7acb
--- a/Function.h Wed Feb 26 22:09:17 2014 +0000 +++ b/Function.h Fri Feb 28 10:29:29 2014 +0000 @@ -3,8 +3,8 @@ #include "mbed.h" #include "SDFileSystem.h" -MCP23017 Port(p9,p10,0x40) ; // 16-bit parallel I/O object -WattBob_TextLCD LCD(&Port); // Varaible to 2*16 chacater LCD object +MCP23017 Port(p9,p10,0x40) ; // 16-bit object with I2C Chip MCP23017 +WattBob_TextLCD LCD(&Port); // A 2*16 chacater LCD object BusOut BinLed(LED4, LED3, LED2, LED1); @@ -12,7 +12,13 @@ DigitalIn FrequencyIn(p15); DigitalIn Switch1(p17); DigitalIn Switch2(p18); +/* + These pins are used to show the time between every execution. +Because of the execution time is very small I used the pins to flip +high and low with every time the functions are called. Consequently, +the period of high or of low represent the complete time. +*/ DigitalOut ReadDigitalinPin(p21); DigitalOut ReadAnaloginPin(p22); DigitalOut FreqMsurPin(p23); @@ -70,10 +76,7 @@ Intialise the LCD to be ready to writ on ***************************************************************************/ void Init_LCD(){ - Port.write_bit(1,BL_BIT); - Write_LCD("Muaiyd Al-Zandi",0,4,1); - Write_LCD("Heriot-Watt Uni.",1,0,0); - wait(1.5); + Port.write_bit(1,BL_BIT); Write_LCD("F=",0,0,1); Write_LCD("A1=",1,0,0); Write_LCD("A2=",1,7,0); @@ -230,14 +233,12 @@ Initialising the SD card file *****************************************************************/ void InitFile(){ - fp = fopen( "/sd/LogDir/LogHistory.txt" , "a"); + fp = fopen( "/sd/LogDir/LogHistory.csv" , "a"); if(fp == NULL) { Write_LCD("SD Card Error",0,0,1); Write_LCD("Try Reset",1,0,0); } - fprintf(fp,"%s","**************************************************************\r\n"); - fprintf(fp,"%s","Time Freq Sw1 Sw2 An1 An2 ;\r\n"); - fprintf(fp,"%s","**************************************************************\r\n"); + fprintf(fp,"Time;Freq;Sw1;Sw2;An1;An2\r\n"); fclose(fp); } /************************************************************** @@ -248,18 +249,18 @@ ***************************************************************/ void LogFile(){ LogFilePin = ! (LogFilePin); - fp = fopen( "/sd/LogDir/LogHistory.txt" , "a"); - fprintf(fp,"%i ",(LogTimer.read_ms()/1000)); + fp = fopen( "/sd/LogDir/LogHistory.csv" , "a"); + fprintf(fp,"%i;",(LogTimer.read_ms()/1000)); if (Freq !=0xffff){ - fprintf(fp," %i ,",Freq); + fprintf(fp,"%i;",Freq); } else{ - fprintf(fp,"Err "); + fprintf(fp,"%s;","Err"); } - fprintf(fp," %i ,",Swch1); - fprintf(fp," %i ,",Swch2); - fprintf(fp," %d%3 ,",Analug1_valu[4]); - fprintf(fp," %d%3 ",Analug2_valu[4]); + fprintf(fp,"%i;",Swch1); + fprintf(fp,"%i;",Swch2); + fprintf(fp,"%d%3;",Analug1_valu[4]); + fprintf(fp,"%d%3;",Analug2_valu[4]); fprintf(fp," %s","\r\n"); fclose(fp); } \ No newline at end of file