![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
See graph
Dependencies: MCP23017 SDFileSystem WattBob_TextLCD mbed
Fork of Embedded_Software_Assignment_2 by
Diff: Tasks.cpp
- Revision:
- 6:ceda53939eb8
- Parent:
- 5:250f51c80ac1
- Child:
- 9:46408a8dea0c
diff -r 250f51c80ac1 -r ceda53939eb8 Tasks.cpp --- a/Tasks.cpp Fri Feb 26 10:44:38 2016 +0000 +++ b/Tasks.cpp Mon Feb 29 11:20:48 2016 +0000 @@ -24,8 +24,6 @@ #include "mbed.h" #include "Tasks.h" -#include "MCP23017.h" -#include "WattBob_TextLCD.h" /* ==================================== Task 1 ==================================== */ Task1::Task1(PinName squareWaveInPin) @@ -129,11 +127,61 @@ _par_port -> write_bit(1,BL_BIT); } -void Task5::updateDisplay(int task1Param,int task2Param, float task4Channel1, float task4Channel2) +void Task5::updateDisplay( int task1Param, + int task2Param, + int errorState, + float task4Channel1, + float task4Channel2 ) { _lcd -> cls(); _lcd -> locate(0,0); - _lcd -> printf("F-%4dHz S1-%d ",task1Param,task2Param); + _lcd -> printf("F-%4dHz S1-%d E%d",task1Param,task2Param,errorState); _lcd -> locate(1,0); _lcd -> printf("C1-%1.2f C2-%1.2f ",task4Channel1,task4Channel2); } + +/* ==================================== Task 6 ==================================== */ +int Task6::updateErrorCode(int switch_1, float analog1, float analog2) +{ + if(switch_1 == 1 && (analog1 > analog2)) + return ERROR_CODE_CDTN_MET; + else + return ERROR_CODE_CDTN_FAIL; +} + +/* ==================================== Task 5 ==================================== */ +Task7::Task7( PinName mosi, + PinName miso, + PinName sck, + PinName cs, + const char *SDName, + const char *dir ) +{ + _sd = new SDFileSystem(mosi,miso,sck,cs, SDName); + makeDirectory(dir); +} + +void Task7::makeDirectory(const char *dir) +{ + mkdir(dir,0777); +} + +int Task7::openFile(const char *dirFile,const char *accessType) +{ + fp = fopen(dirFile,accessType); + if(fp == NULL) + { + return 1; + } + return 0; +} + +void Task7::writeData(const char *dataStream) +{ + fprintf(fp,dataStream); +} + +void Task7::closeFile() +{ + fclose(fp); +} \ No newline at end of file