See graph

Dependencies:   MCP23017 SDFileSystem WattBob_TextLCD mbed

Fork of Embedded_Software_Assignment_2 by Steven Kay

Committer:
sk398
Date:
Fri Feb 26 10:44:38 2016 +0000
Revision:
5:250f51c80ac1
Parent:
4:b85bc0d810e1
Child:
6:ceda53939eb8
LCD output now successfully contained within class definition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sk398 4:b85bc0d810e1 1 /* #####################################################################
sk398 4:b85bc0d810e1 2 main.cpp
sk398 4:b85bc0d810e1 3 ---------
sk398 4:b85bc0d810e1 4
sk398 4:b85bc0d810e1 5 Embedded Software - Assignment 2
sk398 4:b85bc0d810e1 6 --------------------------------
sk398 4:b85bc0d810e1 7
sk398 4:b85bc0d810e1 8 Written by: Steven Kay
sk398 4:b85bc0d810e1 9
sk398 4:b85bc0d810e1 10 Date: February 2016
sk398 4:b85bc0d810e1 11
sk398 4:b85bc0d810e1 12 Function: This
sk398 4:b85bc0d810e1 13
sk398 4:b85bc0d810e1 14 Version: 1.0
sk398 4:b85bc0d810e1 15
sk398 4:b85bc0d810e1 16 Version History
sk398 4:b85bc0d810e1 17 ---------------
sk398 4:b85bc0d810e1 18
sk398 4:b85bc0d810e1 19 1.1 rgdfgdfgdfggdfgdg
sk398 4:b85bc0d810e1 20
sk398 4:b85bc0d810e1 21 1.0 gdgddfdddgd
sk398 4:b85bc0d810e1 22
sk398 4:b85bc0d810e1 23 ##################################################################### */
sk398 2:22ebabd78084 24
sk398 0:5989ac10c4d3 25 #include "mbed.h"
sk398 1:221d677fe0d3 26 #include "Tasks.h"
sk398 4:b85bc0d810e1 27 #include "MCP23017.h"
sk398 4:b85bc0d810e1 28 #include "WattBob_TextLCD.h"
sk398 0:5989ac10c4d3 29
sk398 4:b85bc0d810e1 30 #define BACK_LIGHT_ON(INTERFACE) INTERFACE->write_bit(1,BL_BIT)
sk398 4:b85bc0d810e1 31 #define BACK_LIGHT_OFF(INTERFACE) INTERFACE->write_bit(0,BL_BIT)
sk398 4:b85bc0d810e1 32
sk398 0:5989ac10c4d3 33 DigitalOut myled(LED1);
sk398 0:5989ac10c4d3 34
sk398 4:b85bc0d810e1 35 Task1 task1(p11); // Square wave Measurement
sk398 4:b85bc0d810e1 36 Task2 task2_switch1(p12); // Read digital Output
sk398 4:b85bc0d810e1 37 Task3 task3(p13); // Watchdog Pulse
sk398 4:b85bc0d810e1 38 Task4 task4(p15,p16); // Read analog Inputs
sk398 5:250f51c80ac1 39 Task5 task5(p9,p10,0x40); // Output to LCD Display
sk398 0:5989ac10c4d3 40
sk398 0:5989ac10c4d3 41 int main() {
sk398 4:b85bc0d810e1 42
sk398 4:b85bc0d810e1 43 int task1Frequency = task1.ReadFrequency();
sk398 4:b85bc0d810e1 44 printf("Task 1 Frequency %d Hz\r\n",task1Frequency);
sk398 4:b85bc0d810e1 45
sk398 4:b85bc0d810e1 46 int task2SwitchState = task2_switch1.digitalInState();
sk398 4:b85bc0d810e1 47 printf("Switch 1 State: %d\r\n",task2SwitchState);
sk398 4:b85bc0d810e1 48
sk398 3:c611b9bb5770 49 task3.OutputWatchdogPulse();
sk398 4:b85bc0d810e1 50
sk398 3:c611b9bb5770 51 float *analogReading = task4.returnAnalogReadings();
sk398 4:b85bc0d810e1 52 float channel1 = *(analogReading);
sk398 4:b85bc0d810e1 53 float channel2 = *(analogReading+1);
sk398 4:b85bc0d810e1 54 printf("Analog Readings:\r\nChannel 1-%f\r\nChannel 2-%f\r\n",channel1,channel2);
sk398 3:c611b9bb5770 55
sk398 5:250f51c80ac1 56 task5.updateDisplay(task1Frequency,task2SwitchState,channel1,channel2);
sk398 5:250f51c80ac1 57
sk398 0:5989ac10c4d3 58 while(1) {
sk398 0:5989ac10c4d3 59 myled = 1;
sk398 0:5989ac10c4d3 60 wait(0.2);
sk398 0:5989ac10c4d3 61 myled = 0;
sk398 0:5989ac10c4d3 62 wait(0.2);
sk398 0:5989ac10c4d3 63 }
sk398 4:b85bc0d810e1 64 }