From 0795dfa0dd7f61917b50a67e86aa97114e806e8f Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 4 Dec 2024 20:01:57 +0100 Subject: [PATCH] Change frequency to 400kHz without improvments --- include/controller.h | 4 ++-- src/main.cpp | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/controller.h b/include/controller.h index 614ad39..c7d0b9e 100644 --- a/include/controller.h +++ b/include/controller.h @@ -17,9 +17,9 @@ #define GPIO_DS18B20 D2 /**< One-Wire used for Dallas temperature sensor */ #define WS2812SINGLE_GPIO_PIN D3 -#define WS2812SINGLE_LEDS 1 +#define WS2812SINGLE_LEDS 3 #define WS2812STRIP_GPIO_PIN D4 -#define WS2812STRIP_LEDS 10 +#define WS2812STRIP_LEDS 13 #endif /* End FANLEDCTL_PINS */ \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 0646faa..43bb61b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,7 +6,7 @@ /****************************************************************************** * MAKROS ******************************************************************************/ -#define MAX(x, y) (((x) > (y)) ? (x) : (y)) + /****************************************************************************** * DEFINES @@ -23,7 +23,8 @@ /****************************************************************************** * LOCAL VARIABLES ******************************************************************************/ -Adafruit_NeoPixel pixels(MAX(WS2812SINGLE_LEDS, WS2812STRIP_GPIO_PIN), 0, NEO_RGB + NEO_KHZ800); +Adafruit_NeoPixel pixels(WS2812STRIP_LEDS, WS2812STRIP_GPIO_PIN, NEO_RGB + NEO_KHZ400); +Adafruit_NeoPixel singleLed(WS2812SINGLE_LEDS, WS2812SINGLE_GPIO_PIN, NEO_RGB + NEO_KHZ400); OneWire oneWire(GPIO_DS18B20); DallasTemperature sensors(&oneWire); @@ -40,7 +41,6 @@ void setup() { pinMode(SIGNAL_PIN, INPUT); - pixels.setPin(WS2812SINGLE_GPIO_PIN); pixels.begin(); pixels.clear(); pixels.setBrightness(100); @@ -60,6 +60,9 @@ void setup() { pixels.fill(pixels.Color(0,255,0)); pixels.setBrightness(50); pixels.show(); + /* prepare LED strip pin */ + singleLed.begin(); + singleLed.clear(); } /** @@ -123,13 +126,15 @@ void loop() { fanSpeedPercent = (100 - MIN_FAN_SPEED_PERCENT) * (temp - MIN_TEMP) / (MAX_TEMP - MIN_TEMP) + MIN_FAN_SPEED_PERCENT; } - pixels.setPin(WS2812STRIP_GPIO_PIN); - pixels.begin(); - pixels.clear(); - pixels.fill(pixels.Color(0,255,0)); + + pixels.fill(pixels.Color(255, 255,0)); pixels.setBrightness(fanSpeedPercent); pixels.show(); + singleLed.fill(pixels.Color(0,255,0)); + singleLed.setBrightness((fanSpeedPercent / 10) % 100); + singleLed.show(); + Serial.print(fanSpeedPercent); Serial.print("%;"); setFanSpeedPercent(fanSpeedPercent);