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_WS2812_PIN1 D3
|
||||
#define WS2812_LEDS1 1
|
||||
|
||||
#endif /* End FANLEDCTL_PINS */
|
@ -15,3 +15,4 @@ framework = arduino
|
||||
|
||||
lib_deps = OneWire
|
||||
DallasTemperature
|
||||
adafruit/Adafruit NeoPixel
|
24
src/main.cpp
24
src/main.cpp
@ -1,9 +1,14 @@
|
||||
#include <Arduino.h>
|
||||
#include <DallasTemperature.h>
|
||||
#include <OneWire.h>
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#include "controller.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* DEFINES
|
||||
******************************************************************************/
|
||||
|
||||
#define DELAY_TIME 1000 /**< time between measurements [ms] */
|
||||
#define MIN_FAN_SPEED_PERCENT 24 /**< minimum fan speed [%] */
|
||||
#define MIN_TEMP 25 /**< turn fan off below [deg C] */
|
||||
@ -12,6 +17,10 @@
|
||||
|
||||
#define TEMP_SENSOR_MEASURE_SERIES 5 /**< Maximum resets */
|
||||
|
||||
/******************************************************************************
|
||||
* LOCAL VARIABLES
|
||||
******************************************************************************/
|
||||
Adafruit_NeoPixel* pPixels = NULL;
|
||||
OneWire oneWire(GPIO_DS18B20);
|
||||
DallasTemperature sensors(&oneWire);
|
||||
|
||||
@ -25,6 +34,17 @@ void setup() {
|
||||
/* Setup FAN Control */
|
||||
pinMode(FAN_PIN, OUTPUT);
|
||||
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 */
|
||||
sensors.begin();
|
||||
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;
|
||||
}
|
||||
|
||||
pPixels->fill(pPixels->Color(255,0,0));
|
||||
pPixels->setBrightness(fanSpeedPercent);
|
||||
pPixels->show();
|
||||
|
||||
Serial.print(fanSpeedPercent);
|
||||
Serial.print("%;");
|
||||
setFanSpeedPercent(fanSpeedPercent);
|
||||
|
Loading…
Reference in New Issue
Block a user