auf VSCode mit PlatformIO umgestellt.

This commit is contained in:
Toberfra
2022-02-04 19:22:43 +01:00
parent 3b9117669d
commit ba5ee42fce
13 changed files with 258 additions and 149 deletions

View File

@ -0,0 +1,23 @@
#include "KlappenAblauf.h"
// Constructors/Destructors
//
KlappenAblauf::~KlappenAblauf()
{
}
//
// Methods
//
// Accessor methods
//
// Other methods
//

View File

@ -0,0 +1,52 @@
#ifndef KLAPPENABLAUF_H
#define KLAPPENABLAUF_H
#include "KlappenSteuerung.h"
/**
* class KlappenAblauf
*
*/
class KlappenAblauf : public KlappenSteuerung
{
public:
// Constructors/Destructors
//
/**
* Empty Constructor
*/
KlappenAblauf();
/**
* Empty Destructor
*/
virtual ~KlappenAblauf();
// Static Public attributes
//
// Public attributes
//
protected:
// Static Protected attributes
//
// Protected attributes
//
private:
// Static Private attributes
//
// Private attributes
//
};
#endif // KLAPPENABLAUF_H

View File

@ -0,0 +1,72 @@
#include "KlappenSteuerung.h"
// Constructors/Destructors
//
/**
* @param pinA
* @param pinB
* @param pinPwm
* @param pinSense
* @param id
*/
KlappenSteuerung::KlappenSteuerung(int pin_A, int pin_B, int pin_Pwm, int pin_Sense, int i_d)
{
initAttributes();
pinA = pin_A;
pinB = pin_B;
pinPwm = pin_Pwm;
pinSense = pin_Sense;
id = i_d;
}
KlappenSteuerung::~KlappenSteuerung()
{
}
//
// Methods
//
// Accessor methods
//
// Other methods
//
/**
*/
void KlappenSteuerung::setup()
{
}
/**
*/
void KlappenSteuerung::loop()
{
}
/**
* @param open
*/
void KlappenSteuerung::setOpen(bool open)
{
}
void KlappenSteuerung::initAttributes()
{
pinA = -1;
pinB = -1;
pinPwm = -1;
pinSense = -1;
id = -1;
status = NICHTS;
}

View File

@ -0,0 +1,88 @@
#ifndef KLAPPENSTEUERUNG_H
#define KLAPPENSTEUERUNG_H
#include "statusKlappen.h"
/**
* class KlappenSteuerung
*
*/
class KlappenSteuerung
{
public:
// Constructors/Destructors
//
/**
* Empty Constructor
*/
//KlappenSteuerung();
/**
* Empty Destructor
*/
virtual ~KlappenSteuerung();
// Static Public attributes
//
// Public attributes
//
/**
* @param pinA
* @param pinB
* @param pinPwm
* @param pinSense
* @param id
*/
KlappenSteuerung(int pinA, int pinB, int pinPwm, int pinSense, int id);
/**
*/
void setup();
/**
*/
void loop();
/**
* @param open
*/
void setOpen(bool open);
protected:
// Static Protected attributes
//
// Protected attributes
//
int pinA;
int pinB;
int pinPwm;
int pinSense;
int id;
statusKlappen status;
private:
// Static Private attributes
//
// Private attributes
//
void initAttributes();
};
#endif // KLAPPENSTEUERUNG_H

View File

@ -0,0 +1,69 @@
#include <Arduino.h>
#include "pins.h"
#include "KlappenSteuerung.h"
void Ablauf();
void AblaufSekunde();
KlappenSteuerung klappe1 (M1A , M1B , M1PWM , M1SENSE , 5 );
KlappenSteuerung klappe2 (M2A , M2B , M2PWM , M2SENSE , 2 );
KlappenSteuerung klappe3 (M3A , M3B , M3PWM , M3SENSE , 23 );
KlappenSteuerung klappe4 (M4A , M4B , M4PWM , M4SENSE , 1 );
void setup() {
// put your setup code here, to run once:
klappe1.setup();
klappe2.setup();
klappe3.setup();
klappe4.setup();
}
void loop() {
// put your main code here, to run repeatedly:
klappe1.loop();
klappe2.loop();
klappe3.loop();
klappe4.loop();
Ablauf();
}
void Ablauf(){
static unsigned long alteZeit;
static unsigned int summeZeit;
unsigned long neueZeit;
unsigned int deltaZeit;
neueZeit = millis();
deltaZeit = (unsigned int) (neueZeit - alteZeit);
alteZeit = neueZeit;
summeZeit += deltaZeit;
if(summeZeit >= 1000){ // eine Sekunde
summeZeit -= 1000;
AblaufSekunde();
}
}
void AblaufSekunde(){
static unsigned int sekunden;
sekunden ++;
switch(sekunden){
case 1:
klappe1.setOpen(true);
break;
case 11:
klappe1.setOpen(false);
break;
case 19:
sekunden = 0;
break;
}
}

28
Arduino/motor/src/pins.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef PINS_H
#define PINS_H
#define M1A 2
#define M1B 3
#define M1PWM 5
#define M1SENSE 1
#define M2A 4
#define M2B 7
#define M2PWM 6
#define M2SENSE 2
#define M3A 8
#define M3B 11
#define M3PWM 9
#define M3SENSE 3
#define M4A 12
#define M4B 13
#define M4PWM 10
#define M4SENSE 4
#endif // PINS_H

View File

@ -0,0 +1,15 @@
#ifndef STATUS_H
#define STATUS_H
typedef enum statusKlappenenum{
NICHTS,
}statusKlappen;
#endif