From c0f53831718960bcb3c7c7521e1da443de01e99d Mon Sep 17 00:00:00 2001 From: Mal Date: Mon, 4 Aug 2025 20:51:08 +0200 Subject: [PATCH] Init --- GuniorPIO.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++ GuniorPIO.h | 52 +++++++++++++++++++++++++++++++++++++++++++ library.properties | 9 ++++++++ 3 files changed, 116 insertions(+) create mode 100644 GuniorPIO.cpp create mode 100644 GuniorPIO.h create mode 100644 library.properties diff --git a/GuniorPIO.cpp b/GuniorPIO.cpp new file mode 100644 index 0000000..96c917b --- /dev/null +++ b/GuniorPIO.cpp @@ -0,0 +1,55 @@ +#include "GuniorPIO.h" + +RGB_LED::RGB_LED(const uint8_t& pin_rot, const uint8_t& pin_gruen, const uint8_t pin_blau) + : red(pin_rot), green(pin_gruen), blue(pin_blau) +{ +} + +void RGB_LED::start() +{ + pinMode(red, OUTPUT); + pinMode(green, OUTPUT); + pinMode(blue, OUTPUT); +} + +void RGB_LED::stell_farbe_ein(const Farbe& farbe) +{ + stell_farbe_ein(farbe.rot, farbe.gruen, farbe.blau); +} + +void RGB_LED::stell_farbe_ein(const uint8_t& rot, const uint8_t& gruen, const uint8_t& blau) +{ + analogWrite(red, rot); + analogWrite(green, gruen); + analogWrite(blue, blau); +} + +void schalte_pin_an(const uint8_t& pin) +{ + digitalWrite(pin, HIGH); +} + +void schalte_pin_aus(const uint8_t& pin) +{ + digitalWrite(pin, LOW); +} + +void mache_pin_zu_schalter(const uint8_t& pin) +{ + pinMode(pin, OUTPUT); +} + +void mache_pin_zu_sensor(const uint8_t& pin) +{ + pinMode(pin, INPUT_PULLUP); +} + +void warte(const float& millisekunden) +{ + delay((int)millisekunden); +} + +void regel_pin(const uint8_t& pin, const float& staerke) +{ + analogWrite(pin, (uint8_t)(255 * staerke) % 256); +} diff --git a/GuniorPIO.h b/GuniorPIO.h new file mode 100644 index 0000000..653da00 --- /dev/null +++ b/GuniorPIO.h @@ -0,0 +1,52 @@ +#ifndef __GUNIOR_PIO +#define __GUNIOR_PIO + +#include + +#define SEKUNDE * 1000.0 +#define SEKUNDEN * 1000.0 + +#define ROT {255, 0, 0} +#define GRUEN {0, 255, 0} +#define BLAU {0, 0, 255} +#define GELB {255, 255, 0} +#define ORANGE {255, 64, 0} +#define LILA {255, 0, 255} +#define CYAN {0, 255, 255} +#define WEISS {255, 255, 255} + +typedef struct { + uint8_t rot; + uint8_t gruen; + uint8_t blau; +} Farbe; + +class RGB_LED +{ + const uint8_t red; + const uint8_t green; + const uint8_t blue; + + public: + RGB_LED(const uint8_t& pin_rot, const uint8_t& pin_gruen, const uint8_t pin_blau); + + void start(); + + void stell_farbe_ein(const Farbe& farbe); + + void stell_farbe_ein(const uint8_t& rot, const uint8_t& gruen, const uint8_t& blau); +}; + +void schalte_pin_an(const uint8_t& pin); + +void schalte_pin_aus(const uint8_t& pin); + +void mache_pin_zu_schalter(const uint8_t& pin); + +void mache_pin_zu_sensor(const uint8_t& pin); + +void warte(const float& millisekunden); + +void regel_pin(const uint8_t& pin, const float& staerke); + +#endif diff --git a/library.properties b/library.properties new file mode 100644 index 0000000..e2a30ea --- /dev/null +++ b/library.properties @@ -0,0 +1,9 @@ +name=GuniorPIO +version=1.0.0 +author=Mal +maintainer=Mal +sentence=Simplifies the basic functions especially the naming +paragraph=Defines self explanatory functions that replace the basic functions. +category=Signal Input/Output +url=https://git.leinelab.org/Mal/guniorpio +architectures=*