Add LED FAN visualization
This commit is contained in:
parent
96b0d1e3bc
commit
e56a3a381d
@ -16,4 +16,7 @@
|
|||||||
|
|
||||||
#define GPIO_DS18B20 D2 /**< One-Wire used for Dallas temperature sensor */
|
#define GPIO_DS18B20 D2 /**< One-Wire used for Dallas temperature sensor */
|
||||||
|
|
||||||
|
#define GPIO_WS2812_PIN1 D3
|
||||||
|
#define WS2812_LEDS1 1
|
||||||
|
|
||||||
#endif /* End FANLEDCTL_PINS */
|
#endif /* End FANLEDCTL_PINS */
|
@ -14,4 +14,5 @@ board = d1_wroom_02
|
|||||||
framework = arduino
|
framework = arduino
|
||||||
|
|
||||||
lib_deps = OneWire
|
lib_deps = OneWire
|
||||||
DallasTemperature
|
DallasTemperature
|
||||||
|
adafruit/Adafruit NeoPixel
|
24
src/main.cpp
24
src/main.cpp
@ -1,9 +1,14 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <DallasTemperature.h>
|
#include <DallasTemperature.h>
|
||||||
#include <OneWire.h>
|
#include <OneWire.h>
|
||||||
|
#include <Adafruit_NeoPixel.h>
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* DEFINES
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
#define DELAY_TIME 1000 /**< time between measurements [ms] */
|
#define DELAY_TIME 1000 /**< time between measurements [ms] */
|
||||||
#define MIN_FAN_SPEED_PERCENT 24 /**< minimum fan speed [%] */
|
#define MIN_FAN_SPEED_PERCENT 24 /**< minimum fan speed [%] */
|
||||||
#define MIN_TEMP 25 /**< turn fan off below [deg C] */
|
#define MIN_TEMP 25 /**< turn fan off below [deg C] */
|
||||||
@ -12,6 +17,10 @@
|
|||||||
|
|
||||||
#define TEMP_SENSOR_MEASURE_SERIES 5 /**< Maximum resets */
|
#define TEMP_SENSOR_MEASURE_SERIES 5 /**< Maximum resets */
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* LOCAL VARIABLES
|
||||||
|
******************************************************************************/
|
||||||
|
Adafruit_NeoPixel* pPixels = NULL;
|
||||||
OneWire oneWire(GPIO_DS18B20);
|
OneWire oneWire(GPIO_DS18B20);
|
||||||
DallasTemperature sensors(&oneWire);
|
DallasTemperature sensors(&oneWire);
|
||||||
|
|
||||||
@ -25,6 +34,17 @@ void setup() {
|
|||||||
/* Setup FAN Control */
|
/* Setup FAN Control */
|
||||||
pinMode(FAN_PIN, OUTPUT);
|
pinMode(FAN_PIN, OUTPUT);
|
||||||
pinMode(SIGNAL_PIN, INPUT);
|
pinMode(SIGNAL_PIN, INPUT);
|
||||||
|
|
||||||
|
|
||||||
|
pPixels = 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();
|
||||||
|
|
||||||
|
|
||||||
/* Initialize Temperature sensor */
|
/* Initialize Temperature sensor */
|
||||||
sensors.begin();
|
sensors.begin();
|
||||||
for(int j=0; j < TEMP_SENSOR_MEASURE_SERIES && sensors.getDeviceCount() == 0; j++)
|
for(int j=0; j < TEMP_SENSOR_MEASURE_SERIES && sensors.getDeviceCount() == 0; j++)
|
||||||
@ -96,6 +116,10 @@ void loop() {
|
|||||||
fanSpeedPercent = (100 - MIN_FAN_SPEED_PERCENT) * (temp - MIN_TEMP) / (MAX_TEMP - MIN_TEMP) + MIN_FAN_SPEED_PERCENT;
|
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();
|
||||||
|
|
||||||
Serial.print(fanSpeedPercent);
|
Serial.print(fanSpeedPercent);
|
||||||
Serial.print("%;");
|
Serial.print("%;");
|
||||||
setFanSpeedPercent(fanSpeedPercent);
|
setFanSpeedPercent(fanSpeedPercent);
|
||||||
|
Loading…
Reference in New Issue
Block a user