Prometheus / Mbed 2 deprecated Prom_Roebi

Dependencies:   Farbsensor IRSensorLib PID_Control Servo mbed PixyLib

Committer:
ZHAW_Prometheus
Date:
Thu May 18 09:12:46 2017 +0000
Revision:
8:077d0bb213a2
Parent:
7:5949f408b6da
Child:
12:472b26872a42
Version 18.05.2017 11:12

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ZHAW_Prometheus 1:5c44e2462a8b 1 #include "mbed.h"
ZHAW_Prometheus 1:5c44e2462a8b 2 #include "cstdlib"
ZHAW_Prometheus 1:5c44e2462a8b 3 #include "liftAnsteuerung.h"
ZHAW_Prometheus 1:5c44e2462a8b 4
ZHAW_Prometheus 1:5c44e2462a8b 5
ZHAW_Prometheus 7:5949f408b6da 6 LiftAnsteuerung::LiftAnsteuerung(int interval, int ruecklauf, Servo* servoLift)
ZHAW_Prometheus 1:5c44e2462a8b 7 {
ZHAW_Prometheus 7:5949f408b6da 8 init(interval, ruecklauf, servoLift);
ZHAW_Prometheus 1:5c44e2462a8b 9 }
ZHAW_Prometheus 1:5c44e2462a8b 10
ZHAW_Prometheus 1:5c44e2462a8b 11
ZHAW_Prometheus 1:5c44e2462a8b 12 LiftAnsteuerung::LiftAnsteuerung() {}
ZHAW_Prometheus 1:5c44e2462a8b 13
ZHAW_Prometheus 1:5c44e2462a8b 14
ZHAW_Prometheus 1:5c44e2462a8b 15 LiftAnsteuerung::~LiftAnsteuerung() {}
ZHAW_Prometheus 1:5c44e2462a8b 16
ZHAW_Prometheus 1:5c44e2462a8b 17
ZHAW_Prometheus 2:dea0bab5e45c 18 void LiftAnsteuerung::init(int interval, int ruecklauf, Servo* servoLift)
ZHAW_Prometheus 1:5c44e2462a8b 19 {
ZHAW_Prometheus 7:5949f408b6da 20 zeitinterval = interval;
ZHAW_Prometheus 2:dea0bab5e45c 21 ruecklaufzeit = ruecklauf;
ZHAW_Prometheus 1:5c44e2462a8b 22 this->servoLift = servoLift;
ZHAW_Prometheus 7:5949f408b6da 23 M1 = interval;
ZHAW_Prometheus 2:dea0bab5e45c 24 M2 = ruecklauf;
ZHAW_Prometheus 1:5c44e2462a8b 25 }
ZHAW_Prometheus 2:dea0bab5e45c 26 void LiftAnsteuerung::steuerung(){
ZHAW_Prometheus 1:5c44e2462a8b 27
ZHAW_Prometheus 8:077d0bb213a2 28 if (pc) {
ZHAW_Prometheus 7:5949f408b6da 29 pc->printf("M1: %d, M2: %d\n\r", M1, M2);
ZHAW_Prometheus 8:077d0bb213a2 30 }
ZHAW_Prometheus 7:5949f408b6da 31 if (M1>0) {
ZHAW_Prometheus 7:5949f408b6da 32 servoLift->write(1.2f);
ZHAW_Prometheus 7:5949f408b6da 33 M1--;
ZHAW_Prometheus 7:5949f408b6da 34 } else if (M2>0) {
ZHAW_Prometheus 7:5949f408b6da 35
ZHAW_Prometheus 2:dea0bab5e45c 36 servoLift->write(0.1f);
ZHAW_Prometheus 2:dea0bab5e45c 37 M2--;
ZHAW_Prometheus 2:dea0bab5e45c 38 } else {
ZHAW_Prometheus 7:5949f408b6da 39 M1 = zeitinterval;
ZHAW_Prometheus 7:5949f408b6da 40 M2 = ruecklaufzeit;
ZHAW_Prometheus 7:5949f408b6da 41 }
ZHAW_Prometheus 7:5949f408b6da 42 //pc->printf("M1: %d, M2: %d\n\r", M1, M2);
ZHAW_Prometheus 1:5c44e2462a8b 43
ZHAW_Prometheus 1:5c44e2462a8b 44 }
ZHAW_Prometheus 1:5c44e2462a8b 45 void LiftAnsteuerung::setSerialOutput(Serial *pc)
ZHAW_Prometheus 1:5c44e2462a8b 46 {
ZHAW_Prometheus 1:5c44e2462a8b 47 this->pc = pc;
ZHAW_Prometheus 1:5c44e2462a8b 48 }
ZHAW_Prometheus 1:5c44e2462a8b 49
ZHAW_Prometheus 1:5c44e2462a8b 50
ZHAW_Prometheus 1:5c44e2462a8b 51