Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MCP23017 SDFileSystem WattBob_TextLCD mbed
Revision 5:250f51c80ac1, committed 2016-02-26
- Comitter:
- sk398
- Date:
- Fri Feb 26 10:44:38 2016 +0000
- Parent:
- 4:b85bc0d810e1
- Child:
- 6:ceda53939eb8
- Commit message:
- LCD output now successfully contained within class definition
Changed in this revision
--- a/Tasks.cpp Fri Feb 26 10:36:23 2016 +0000
+++ b/Tasks.cpp Fri Feb 26 10:44:38 2016 +0000
@@ -122,9 +122,18 @@
}
/* ==================================== Task 5 ==================================== */
-Task5::Task5()
+Task5::Task5(PinName sda, PinName scl, int address)
{
-
-
+ _par_port = new MCP23017(sda,scl,address);
+ _lcd = new WattBob_TextLCD(_par_port);
+ _par_port -> write_bit(1,BL_BIT);
}
+void Task5::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);
+}
--- a/Tasks.h Fri Feb 26 10:36:23 2016 +0000
+++ b/Tasks.h Fri Feb 26 10:44:38 2016 +0000
@@ -25,6 +25,9 @@
#ifndef _TASKS_H_
#define _TASKS_H_
+#include "MCP23017.h"
+#include "WattBob_TextLCD.h"
+
// Global definitions
#define HIGH 1
#define LOW 0
@@ -110,18 +113,24 @@
AnalogIn *_AnalogIn2;
};
-//
-///* ==================================== Task 5 ==================================== */
-//// Display outputs to LCD
-//class Task5
-//{
-//public:
-// Task5();
-//
-//private:
-//
-//
-//};
+//* ==================================== Task 5 ==================================== */
+// Display outputs to LCD
+class Task5
+{
+public:
+ Task5(PinName sda, PinName scl, int address);
+ void updateDisplay(int task1Param,int task2Param, float task4Channel1, float task4Channel2);
+
+
+private:
+
+
+protected:
+ MCP23017 *_par_port;
+ WattBob_TextLCD *_lcd;
+
+
+};
//
///* ==================================== Task 6 ==================================== */
//// Logical checks
--- a/main.cpp Fri Feb 26 10:36:23 2016 +0000
+++ b/main.cpp Fri Feb 26 10:44:38 2016 +0000
@@ -30,25 +30,16 @@
#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(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);
+Task5 task5(p9,p10,0x40); // Output to LCD Display
int main() {
-
- 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);
@@ -62,20 +53,12 @@
float channel2 = *(analogReading+1);
printf("Analog Readings:\r\nChannel 1-%f\r\nChannel 2-%f\r\n",channel1,channel2);
- updateDisplay(task1Frequency,task2SwitchState,channel1,channel2);
+ task5.updateDisplay(task1Frequency,task2SwitchState,channel1,channel2);
+
while(1) {
myled = 1;
wait(0.2);
myled = 0;
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