![](/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: main.cpp
- Revision:
- 4:b85bc0d810e1
- Parent:
- 3:c611b9bb5770
- Child:
- 5:250f51c80ac1
--- a/main.cpp Wed Feb 17 10:22:50 2016 +0000 +++ b/main.cpp Fri Feb 26 10:36:23 2016 +0000 @@ -1,40 +1,68 @@ -/* ############################################################################### -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -############################################################################### */ +/* ##################################################################### + main.cpp + --------- + + Embedded Software - Assignment 2 + -------------------------------- + + Written by: Steven Kay + + Date: February 2016 + + Function: This + + Version: 1.0 + + Version History + --------------- + + 1.1 rgdfgdfgdfggdfgdg + + 1.0 gdgddfdddgd + + ##################################################################### */ #include "mbed.h" #include "Tasks.h" +#include "MCP23017.h" +#include "WattBob_TextLCD.h" +#define BACK_LIGHT_ON(INTERFACE) INTERFACE->write_bit(1,BL_BIT) +#define BACK_LIGHT_OFF(INTERFACE) INTERFACE->write_bit(0,BL_BIT) + +MCP23017 *par_port; +WattBob_TextLCD *lcd; DigitalOut myled(LED1); -Task1 task1(p5); // Square wave Measurement -Task2 task2_switch1(p6); // Read digital Output -Task3 task3(p7); // Watchdog Pulse -Task4 task4(p15,p16); // Read analog Inputs +Task1 task1(p11); // Square wave Measurement +Task2 task2_switch1(p12); // Read digital Output +Task3 task3(p13); // Watchdog Pulse +Task4 task4(p15,p16); // Read analog Inputs +void updateDisplay(int task1Param,int task2Param, float task4Channel1, float task4Channel2); int main() { - task1.MeasureFreq(); - int switch1State = task2_switch1.digitalInState(); + par_port = new MCP23017(p9,p10,0x40); + lcd = new WattBob_TextLCD(par_port); + par_port -> write_bit(1,BL_BIT); + + + int task1Frequency = task1.ReadFrequency(); + printf("Task 1 Frequency %d Hz\r\n",task1Frequency); + + int task2SwitchState = task2_switch1.digitalInState(); + printf("Switch 1 State: %d\r\n",task2SwitchState); + task3.OutputWatchdogPulse(); + float *analogReading = task4.returnAnalogReadings(); + float channel1 = *(analogReading); + float channel2 = *(analogReading+1); + printf("Analog Readings:\r\nChannel 1-%f\r\nChannel 2-%f\r\n",channel1,channel2); + updateDisplay(task1Frequency,task2SwitchState,channel1,channel2); while(1) { myled = 1; wait(0.2); @@ -42,3 +70,12 @@ wait(0.2); } } + +void updateDisplay(int task1Param,int task2Param, float task4Channel1, float task4Channel2) +{ + lcd -> cls(); + lcd -> locate(0,0); + lcd -> printf("F-%4dHz S1-%d ",task1Param,task2Param); + lcd -> locate(1,0); + lcd -> printf("C1-%1.2f C2-%1.2f ",task4Channel1,task4Channel2); +} \ No newline at end of file