Umstellung auf PlatformIO
Anpassung auf Blinken der fehlenden LEDs
This commit is contained in:
parent
f266fe6a75
commit
06a9910bc6
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal 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
10
.vscode/extensions.json
vendored
Normal 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
7
platformio.ini
Normal 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
|
||||
|
|
@ -4,4 +4,5 @@
|
|||
|
||||
#define NEOPIXEL_PIN D6
|
||||
#define BRIGHTNESS 100
|
||||
#define BLINK_INTERVAL 500 // Blink interval in milliseconds (0.5 seconds)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#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
|
||||
|
|
@ -10,6 +12,8 @@ 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...");
|
||||
|
|
@ -51,10 +55,9 @@ void setup() {
|
|||
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 +69,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 +77,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);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user