From c48d977f42994c41b0acca58d5cf8b3830a01262 Mon Sep 17 00:00:00 2001 From: Ollo Date: Fri, 29 Nov 2024 23:13:53 +0100 Subject: [PATCH] Added second LED library --- include/controller.h | 3 +++ src/main.cpp | 26 ++++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/include/controller.h b/include/controller.h index eba3a75..d8fb967 100644 --- a/include/controller.h +++ b/include/controller.h @@ -19,4 +19,7 @@ #define GPIO_WS2812_PIN1 D3 #define WS2812_LEDS1 1 +#define GPIO_WS2812_PIN2 D4 +#define WS2812_LEDS2 10 + #endif /* End FANLEDCTL_PINS */ \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index effc824..75f6fa9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,7 +20,9 @@ /****************************************************************************** * LOCAL VARIABLES ******************************************************************************/ -Adafruit_NeoPixel* pPixels = NULL; +Adafruit_NeoPixel* pPixelFan = NULL; +Adafruit_NeoPixel* pPixel = NULL; + OneWire oneWire(GPIO_DS18B20); DallasTemperature sensors(&oneWire); @@ -36,16 +38,15 @@ void setup() { pinMode(SIGNAL_PIN, INPUT); - pPixels = new Adafruit_NeoPixel(WS2812_LEDS1, GPIO_WS2812_PIN1, NEO_RGB + NEO_KHZ800); + pPixelFan = new Adafruit_NeoPixel(WS2812_LEDS1, GPIO_WS2812_PIN1, NEO_RGB + NEO_KHZ800); - pPixels->begin(); - pPixels->clear(); - pPixels->fill(pPixels->Color(255,0,0)); - pPixels->setBrightness(100); - pPixels->show(); + pPixelFan->begin(); + pPixelFan->clear(); + pPixelFan->fill(pPixelFan->Color(255,0,0)); + pPixelFan->setBrightness(100); + pPixelFan->show(); - - /* Initialize Temperature sensor */ +/* Initialize Temperature sensor */ sensors.begin(); for(int j=0; j < TEMP_SENSOR_MEASURE_SERIES && sensors.getDeviceCount() == 0; j++) { @@ -116,9 +117,9 @@ void loop() { fanSpeedPercent = (100 - MIN_FAN_SPEED_PERCENT) * (temp - MIN_TEMP) / (MAX_TEMP - MIN_TEMP) + MIN_FAN_SPEED_PERCENT; } - pPixels->fill(pPixels->Color(255,0,0)); - pPixels->setBrightness(fanSpeedPercent); - pPixels->show(); + pPixelFan->fill(pPixelFan->Color(0,255,0)); + pPixelFan->setBrightness(fanSpeedPercent); + pPixelFan->show(); Serial.print(fanSpeedPercent); Serial.print("%;"); @@ -127,5 +128,6 @@ void loop() { actualFanSpeedRpm = getFanSpeedRpm(); Serial.print(actualFanSpeedRpm); Serial.println("RPM"); + delay(DELAY_TIME); }