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: Farbsensor IRSensorLib PID_Control Servo mbed PixyLib
Diff: liftAnsteuerung.cpp
- Revision:
- 12:472b26872a42
- Parent:
- 8:077d0bb213a2
- Child:
- 14:bee8101aad45
--- a/liftAnsteuerung.cpp Sat May 20 12:02:51 2017 +0000
+++ b/liftAnsteuerung.cpp Sat May 20 21:47:11 2017 +0000
@@ -1,50 +1,35 @@
#include "mbed.h"
#include "cstdlib"
#include "liftAnsteuerung.h"
-
-
-LiftAnsteuerung::LiftAnsteuerung(int interval, int ruecklauf, Servo* servoLift)
-{
- init(interval, ruecklauf, servoLift);
-}
-
-
-LiftAnsteuerung::LiftAnsteuerung() {}
-
-LiftAnsteuerung::~LiftAnsteuerung() {}
-
-
-void LiftAnsteuerung::init(int interval, int ruecklauf, Servo* servoLift)
+//Konstruktor
+LiftAnsteuerung::LiftAnsteuerung(int interval, int ruecklauf, Servo& _servoLift, Button& _onoff) : servoLift(_servoLift), onoff(_onoff)
{
zeitinterval = interval;
ruecklaufzeit = ruecklauf;
- this->servoLift = servoLift;
M1 = interval;
M2 = ruecklauf;
}
+//Destruktor
+LiftAnsteuerung::~LiftAnsteuerung() {}
+
void LiftAnsteuerung::steuerung(){
-
- if (pc) {
- pc->printf("M1: %d, M2: %d\n\r", M1, M2);
- }
- if (M1>0) {
- servoLift->write(1.2f);
- M1--;
+ if (onoff.getState() != 0) {
+ if (M1>0) {
+ servoLift = 1.2f;
+ M1--;
} else if (M2>0) {
- servoLift->write(0.1f);
+ servoLift = 0.1f;
M2--;
- } else {
- M1 = zeitinterval;
- M2 = ruecklaufzeit;
+ } else {
+ M1 = zeitinterval;
+ M2 = ruecklaufzeit;
+ }
}
- //pc->printf("M1: %d, M2: %d\n\r", M1, M2);
-
-}
-void LiftAnsteuerung::setSerialOutput(Serial *pc)
-{
- this->pc = pc;
+ else {
+ servoLift = 0.74f;
+ }
}