Moved to other pin

This commit is contained in:
Ollo 2024-12-04 21:38:41 +01:00
parent 0795dfa0dd
commit f8c6b4d351
3 changed files with 23 additions and 10 deletions

View File

@ -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 */

View File

@ -15,4 +15,5 @@ framework = arduino
lib_deps = OneWire
DallasTemperature
adafruit/Adafruit NeoPixel
adafruit/Adafruit NeoPixel
WS2812FX

View File

@ -1,4 +1,5 @@
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <Adafruit_NeoPixel.h>
@ -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);
}