ManualController

Dependents:   ConfigurationVerifier

Files at this revision

API Documentation at this revision

Comitter:
lmarketin
Date:
Fri May 07 13:51:00 2021 +0000
Commit message:
ManuallController

Changed in this revision

manualController.cc Show annotated file Show diff for this revision Revisions of this file
manualController.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r abed7d1e329c manualController.cc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/manualController.cc	Fri May 07 13:51:00 2021 +0000
@@ -0,0 +1,28 @@
+#include "manualController.h"
+
+ManualController::ManualController(PinName pinDistance, Serial* pc, SRF05* ranger, PwmOut* rangerServo, PwmOut* fan,PwmOut* fanServo, DigitalOut* greenLed, DigitalOut* redLed):
+        m_interruptDistance(pinDistance, PullDown), m_pc(pc), m_ranger(ranger), m_rangerServo(rangerServo), m_fan(fan), m_fanServo(fanServo),
+        m_greenLed(greenLed), m_redLed(redLed)
+{
+    m_interruptDistance.rise(this, &ManualController::hwInterruptReadDistance);
+}
+
+void ManualController::executeManualControll()
+{
+    AnalogIn servoRangerAIn(A1);
+    AnalogIn servoFanAIn(A2);
+    AnalogIn fanAIn(A3);
+    
+    while(1) {
+        m_rangerServo->pulsewidth_us(500+(2000*servoRangerAIn));
+        wait(0.15);
+        m_fanServo->pulsewidth_us(500+(2000*servoFanAIn));
+        wait(0.15);
+        m_fan->pulsewidth_us(20000*fanAIn);
+        wait(0.15);
+    }   
+}
+
+void ManualController::hwInterruptReadDistance() {
+    m_pc->printf("Distance: %f\r", m_ranger->read());
+}
\ No newline at end of file
diff -r 000000000000 -r abed7d1e329c manualController.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/manualController.h	Fri May 07 13:51:00 2021 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+#include "SRF05.h"
+
+class ManualController
+{
+public:
+    ManualController(PinName pinDistance, Serial* pc, SRF05* ranger, PwmOut* rangerServo, PwmOut* fan, PwmOut* fanServo, DigitalOut* greenLed, DigitalOut* redLed);
+    
+    void executeManualControll();
+    
+private:
+    void hwInterruptReadDistance();
+    
+    InterruptIn m_interruptDistance;
+    Serial* m_pc;
+    SRF05* m_ranger;
+    PwmOut* m_rangerServo;
+    PwmOut* m_fan;
+    PwmOut* m_fanServo ;
+    DigitalOut* m_greenLed ;
+    DigitalOut* m_redLed ;
+};
\ No newline at end of file