Compare commits

...

2 Commits

Author SHA1 Message Date
toptah
a1de1924e7 angepasst 2026-03-06 22:03:44 +01:00
toptah
06a9910bc6 Umstellung auf PlatformIO
Anpassung auf Blinken der fehlenden LEDs
2026-03-06 21:51:39 +01:00
5 changed files with 42 additions and 11 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch

10
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

7
platformio.ini Normal file
View File

@ -0,0 +1,7 @@
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps =
adafruit/Adafruit NeoPixel @ ^1.11.0
https://github.com/RobTillaart/PCF8575

View File

@ -4,4 +4,5 @@
#define NEOPIXEL_PIN D6
#define BRIGHTNESS 100
#define BLINK_INTERVAL 500 // Blink interval in milliseconds (0.5 seconds)

View File

@ -1,15 +1,18 @@
#include <Wire.h>
#include <PCF8575.h>
#include <Adafruit_NeoPixel.h>
#include "Config.ino"
#define AMOUNTOFPORTS 8 // currently max 16 ports are supported
#define EXPANDER1ADDRESS 0x21 // address of expander 1
PCF8575 expander1(EXPANDER1ADDRESS);
uint8_t portStates[AMOUNTOFPORTS];
uint8_t lastStates[AMOUNTOFPORTS] = {0};
byte number=0;
extern Adafruit_NeoPixel* pixels;
void setup() {
Serial.begin(9600);
Serial.println("Starte 16-Port IO Erweiterung...");
@ -44,18 +47,15 @@ void setup() {
{
Serial.println(" => connected!!");
}
//Setup NeoPixel
NeoPixel_init(AMOUNTOFPORTS); // Initialisierung der NeoPixel
for (uint8_t i = 0; i < AMOUNTOFPORTS; i++) {
portStates[i] = 0;
lastStates[i] = 0;
NeoPixel_setState(i,1);
delay(10);
NeoPixel_setState(i,0);
pixels->setPixelColor(i, pixels->Color(0, 0, 0)); // aus
};
pixels->show();
Serial.println("Setup End...");
}
@ -66,7 +66,6 @@ void loop() {
portStates[i] = expander1.read(i);
}
static uint8_t lastStates[AMOUNTOFPORTS] = {0};
for (uint8_t i = 0; i < AMOUNTOFPORTS; i++) {
if (portStates[i] != lastStates[i]) {
// Ausgabe: geänderte Ports melden
@ -75,10 +74,19 @@ void loop() {
Serial.print(" hat sich geändert -> ");
Serial.println(portStates[i]);
lastStates[i] = portStates[i];
// Bei änderung LED anpassen
NeoPixel_setState(i, portStates[i]); // Jede LED pro Pin aktualisieren
}
// LED aktualisieren
if (portStates[i] == 0) {
pixels->setPixelColor(i, pixels->Color(0, 150, 0)); // grün
} else {
bool globalBlinkState = (millis() / BLINK_INTERVAL) % 2;
if (globalBlinkState) {
pixels->setPixelColor(i, pixels->Color(150, 0, 0)); // rot
} else {
pixels->setPixelColor(i, pixels->Color(0, 0, 0)); // aus
}
}
}
pixels->show();
delay(50);
}