From f8c6b4d351e01ba13d00e98bb8615d693c5bc6be Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 4 Dec 2024 21:38:41 +0100 Subject: [PATCH] Moved to other pin --- include/controller.h | 4 ++-- platformio.ini | 3 ++- src/main.cpp | 26 +++++++++++++++++++------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/controller.h b/include/controller.h index c7d0b9e..250f84d 100644 --- a/include/controller.h +++ b/include/controller.h @@ -16,10 +16,10 @@ #define GPIO_DS18B20 D2 /**< One-Wire used for Dallas temperature sensor */ -#define WS2812SINGLE_GPIO_PIN D3 +#define WS2812SINGLE_GPIO_PIN D5 #define WS2812SINGLE_LEDS 3 -#define WS2812STRIP_GPIO_PIN D4 +#define WS2812STRIP_GPIO_PIN D3 #define WS2812STRIP_LEDS 13 #endif /* End FANLEDCTL_PINS */ \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index b9e9b55..6925e4d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,4 +15,5 @@ framework = arduino lib_deps = OneWire DallasTemperature - adafruit/Adafruit NeoPixel \ No newline at end of file + adafruit/Adafruit NeoPixel + WS2812FX \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 43bb61b..e61e948 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -23,8 +24,8 @@ /****************************************************************************** * LOCAL VARIABLES ******************************************************************************/ -Adafruit_NeoPixel pixels(WS2812STRIP_LEDS, WS2812STRIP_GPIO_PIN, NEO_RGB + NEO_KHZ400); -Adafruit_NeoPixel singleLed(WS2812SINGLE_LEDS, WS2812SINGLE_GPIO_PIN, NEO_RGB + NEO_KHZ400); +Adafruit_NeoPixel pixels(WS2812STRIP_LEDS, WS2812STRIP_GPIO_PIN, NEO_RBG + NEO_KHZ400); +Adafruit_NeoPixel singleLed(WS2812SINGLE_LEDS, WS2812SINGLE_GPIO_PIN, NEO_RBG + NEO_KHZ400); OneWire oneWire(GPIO_DS18B20); DallasTemperature sensors(&oneWire); @@ -36,6 +37,12 @@ DallasTemperature sensors(&oneWire); void setup() { Serial.begin(115200); + WiFi.mode(WIFI_OFF); + if (WiFi.getMode() == WIFI_OFF) + { + Serial.println(F("\nWifi mode is WIFI_OFF")); + } + /* Setup FAN Control */ pinMode(FAN_PIN, OUTPUT); pinMode(SIGNAL_PIN, INPUT); @@ -63,6 +70,10 @@ void setup() { /* prepare LED strip pin */ singleLed.begin(); singleLed.clear(); + singleLed.setBrightness(100); + singleLed.fill(singleLed.Color(255,0,0)); + singleLed.show(); + } /** @@ -126,22 +137,23 @@ void loop() { fanSpeedPercent = (100 - MIN_FAN_SPEED_PERCENT) * (temp - MIN_TEMP) / (MAX_TEMP - MIN_TEMP) + MIN_FAN_SPEED_PERCENT; } + actualFanSpeedRpm = getFanSpeedRpm(); - pixels.fill(pixels.Color(255, 255,0)); + pixels.fill(pixels.Color(255, 0,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); - actualFanSpeedRpm = getFanSpeedRpm(); Serial.print(actualFanSpeedRpm); Serial.println("RPM"); + + singleLed.fill(singleLed.Color(0,128,128)); + singleLed.setBrightness(255 - (actualFanSpeedRpm / 10)); + singleLed.show(); delay(DELAY_TIME); }