From ba5ee42fce516d15c539d46c6d123e8a2fd4ceef Mon Sep 17 00:00:00 2001 From: Toberfra Date: Fri, 4 Feb 2022 19:22:43 +0100 Subject: [PATCH] auf VSCode mit PlatformIO umgestellt. --- Arduino/motor/.gitignore | 5 + Arduino/motor/include/README | 39 ++++++ Arduino/motor/lib/README | 46 +++++++ Arduino/motor/platformio.ini | 14 ++ Arduino/motor/src/KlappenAblauf.cpp | 23 ++++ Arduino/motor/src/KlappenAblauf.h | 52 +++++++ .../src}/KlappenSteuerung.cpp | 35 +++-- .../{sketch => motor/src}/KlappenSteuerung.h | 20 ++- .../{sketch/sketch.ino => motor/src/main.cpp} | 18 ++- Arduino/{sketch => motor/src}/pins.h | 0 Arduino/motor/src/statusKlappen.h | 15 ++ Arduino/motor/test/README | 11 ++ Arduino/uml/Klappensteuerung.xmi | 129 ------------------ 13 files changed, 258 insertions(+), 149 deletions(-) create mode 100644 Arduino/motor/.gitignore create mode 100644 Arduino/motor/include/README create mode 100644 Arduino/motor/lib/README create mode 100644 Arduino/motor/platformio.ini create mode 100644 Arduino/motor/src/KlappenAblauf.cpp create mode 100644 Arduino/motor/src/KlappenAblauf.h rename Arduino/{sketch => motor/src}/KlappenSteuerung.cpp (55%) rename Arduino/{sketch => motor/src}/KlappenSteuerung.h (79%) rename Arduino/{sketch/sketch.ino => motor/src/main.cpp} (74%) rename Arduino/{sketch => motor/src}/pins.h (100%) create mode 100644 Arduino/motor/src/statusKlappen.h create mode 100644 Arduino/motor/test/README delete mode 100644 Arduino/uml/Klappensteuerung.xmi diff --git a/Arduino/motor/.gitignore b/Arduino/motor/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/Arduino/motor/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/Arduino/motor/include/README b/Arduino/motor/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/Arduino/motor/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/Arduino/motor/lib/README b/Arduino/motor/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/Arduino/motor/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/Arduino/motor/platformio.ini b/Arduino/motor/platformio.ini new file mode 100644 index 0000000..96febe7 --- /dev/null +++ b/Arduino/motor/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:nanoatmega328] +platform = atmelavr +board = nanoatmega328 +framework = arduino diff --git a/Arduino/motor/src/KlappenAblauf.cpp b/Arduino/motor/src/KlappenAblauf.cpp new file mode 100644 index 0000000..79a52ab --- /dev/null +++ b/Arduino/motor/src/KlappenAblauf.cpp @@ -0,0 +1,23 @@ +#include "KlappenAblauf.h" + +// Constructors/Destructors +// + + +KlappenAblauf::~KlappenAblauf() +{ +} + +// +// Methods +// + + +// Accessor methods +// + + +// Other methods +// + + diff --git a/Arduino/motor/src/KlappenAblauf.h b/Arduino/motor/src/KlappenAblauf.h new file mode 100644 index 0000000..e9bc953 --- /dev/null +++ b/Arduino/motor/src/KlappenAblauf.h @@ -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 diff --git a/Arduino/sketch/KlappenSteuerung.cpp b/Arduino/motor/src/KlappenSteuerung.cpp similarity index 55% rename from Arduino/sketch/KlappenSteuerung.cpp rename to Arduino/motor/src/KlappenSteuerung.cpp index e10335b..85189ed 100644 --- a/Arduino/sketch/KlappenSteuerung.cpp +++ b/Arduino/motor/src/KlappenSteuerung.cpp @@ -3,8 +3,22 @@ // Constructors/Destructors // -KlappenSteuerung::KlappenSteuerung() + +/** + * @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() @@ -24,16 +38,6 @@ KlappenSteuerung::~KlappenSteuerung() // -/** - * @param pinA - * @param pinB - * @param pinPwm - * @param pinSense - */ - KlappenSteuerung::KlappenSteuerung(int pinA, int pinB, int pinPwm, int pinSense) -{ -} - /** */ @@ -56,4 +60,13 @@ void KlappenSteuerung::setOpen(bool open) { } +void KlappenSteuerung::initAttributes() +{ + pinA = -1; + pinB = -1; + pinPwm = -1; + pinSense = -1; + id = -1; + status = NICHTS; +} diff --git a/Arduino/sketch/KlappenSteuerung.h b/Arduino/motor/src/KlappenSteuerung.h similarity index 79% rename from Arduino/sketch/KlappenSteuerung.h rename to Arduino/motor/src/KlappenSteuerung.h index d9c512e..cae37be 100644 --- a/Arduino/sketch/KlappenSteuerung.h +++ b/Arduino/motor/src/KlappenSteuerung.h @@ -2,6 +2,7 @@ #ifndef KLAPPENSTEUERUNG_H #define KLAPPENSTEUERUNG_H +#include "statusKlappen.h" /** * class KlappenSteuerung @@ -18,7 +19,7 @@ public: /** * Empty Constructor */ - KlappenSteuerung(); + //KlappenSteuerung(); /** * Empty Destructor @@ -38,8 +39,9 @@ public: * @param pinB * @param pinPwm * @param pinSense + * @param id */ - KlappenSteuerung(int pinA, int pinB, int pinPwm, int pinSense); + KlappenSteuerung(int pinA, int pinB, int pinPwm, int pinSense, int id); /** @@ -62,14 +64,24 @@ protected: // // Protected attributes - // + // + + int pinA; + int pinB; + int pinPwm; + int pinSense; + int id; + statusKlappen status; private: // Static Private attributes // // Private attributes - // + // + + + void initAttributes(); }; diff --git a/Arduino/sketch/sketch.ino b/Arduino/motor/src/main.cpp similarity index 74% rename from Arduino/sketch/sketch.ino rename to Arduino/motor/src/main.cpp index db05bfa..6451912 100644 --- a/Arduino/sketch/sketch.ino +++ b/Arduino/motor/src/main.cpp @@ -1,10 +1,18 @@ +#include + #include "pins.h" #include "KlappenSteuerung.h" -KlappenSteuerung klappe1 (M1A , M1B , M1PWM , M1SENSE); -KlappenSteuerung klappe2 (M2A , M2B , M2PWM , M2SENSE); -KlappenSteuerung klappe3 (M3A , M3B , M3PWM , M3SENSE); -KlappenSteuerung klappe4 (M4A , M4B , M4PWM , M4SENSE); + +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: @@ -54,7 +62,7 @@ void AblaufSekunde(){ klappe1.setOpen(false); break; - case19: + case 19: sekunden = 0; break; } diff --git a/Arduino/sketch/pins.h b/Arduino/motor/src/pins.h similarity index 100% rename from Arduino/sketch/pins.h rename to Arduino/motor/src/pins.h diff --git a/Arduino/motor/src/statusKlappen.h b/Arduino/motor/src/statusKlappen.h new file mode 100644 index 0000000..1b91be4 --- /dev/null +++ b/Arduino/motor/src/statusKlappen.h @@ -0,0 +1,15 @@ +#ifndef STATUS_H +#define STATUS_H + +typedef enum statusKlappenenum{ +NICHTS, + +}statusKlappen; + + + + + +#endif + + diff --git a/Arduino/motor/test/README b/Arduino/motor/test/README new file mode 100644 index 0000000..b94d089 --- /dev/null +++ b/Arduino/motor/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/Arduino/uml/Klappensteuerung.xmi b/Arduino/uml/Klappensteuerung.xmi deleted file mode 100644 index c25d574..0000000 --- a/Arduino/uml/Klappensteuerung.xmi +++ /dev/null @@ -1,129 +0,0 @@ - - - - - umbrello uml modeller 2.32.0 http://umbrello.kde.org - 1.7.3 - UnicodeUTF8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -