Example software for a Cyclic Executive

Dependencies:   MCP23017 SDFileSystem WattBob_TextLCD mbed

Revision:
3:c611b9bb5770
Parent:
2:22ebabd78084
Child:
4:b85bc0d810e1
diff -r 22ebabd78084 -r c611b9bb5770 Tasks.cpp
--- a/Tasks.cpp	Mon Feb 15 22:30:54 2016 +0000
+++ b/Tasks.cpp	Wed Feb 17 10:22:50 2016 +0000
@@ -29,17 +29,28 @@
     
 int Task1::MeasureFreq()
 {    
-        
+      return 0;  
 }
 
 
 /* ==================================== Task 2 ==================================== */
-
 Task2::Task2(PinName digitalInCheckPin)
 {
-    _digitialInCheck = new DigitalOut(digitalInCheckPin);
+    _digitalInCheck = new DigitalIn(digitalInCheckPin);
 }
-    
+
+bool Task2::digitalInState()
+{
+    if(_digitalInCheck -> read())
+    {
+        return TRUE;
+    }
+    else
+    {
+        return FALSE;
+    }
+}
+
 
 /* ==================================== Task 3 ==================================== */
 Task3::Task3(PinName WatchdogPin)
@@ -55,4 +66,32 @@
 }
 
 
-/* ==================================== Task 4 ==================================== */
\ No newline at end of file
+/* ==================================== Task 4 ==================================== */
+Task4::Task4(PinName Analog1Pin,PinName Analog2Pin)
+{
+    _AnalogIn1 = new AnalogIn(Analog1Pin);
+    _AnalogIn2 = new AnalogIn(Analog2Pin);
+}
+
+float *Task4::returnAnalogReadings()
+{
+    float readBuffer_1 = 0.0;
+    float readBuffer_2 = 0.0;
+    
+    float outputBuffer[2];
+    float *outputBufferPtr =&outputBuffer[0];
+       
+//    outputBuffer[0] = _AnalogIn1 -> read();
+//    outputBuffer[1] = _AnalogIn2 -> read();
+
+    for(int readCount = 0;readCount < NUM_ANALOG_SAMPLES; readCount++)
+    {
+        readBuffer_1 += _AnalogIn1 -> read();
+        readBuffer_2 += _AnalogIn2 -> read();  
+    }
+    
+    outputBuffer[0] = readBuffer_1/NUM_ANALOG_SAMPLES;
+    outputBuffer[1] = readBuffer_1/NUM_ANALOG_SAMPLES;
+    
+    return outputBufferPtr;    
+}