Refactored to single instance of Adafruit_NeoPixel
This commit is contained in:
		| @@ -16,10 +16,10 @@ | ||||
|  | ||||
| #define GPIO_DS18B20    D2  /**< One-Wire used for Dallas temperature sensor */ | ||||
|  | ||||
| #define GPIO_WS2812_PIN1     D3 | ||||
| #define WS2812_LEDS1     1 | ||||
| #define WS2812SINGLE_GPIO_PIN    D3 | ||||
| #define WS2812SINGLE_LEDS        1 | ||||
|  | ||||
| #define GPIO_WS2812_PIN2    D4 | ||||
| #define WS2812_LEDS2        10 | ||||
| #define WS2812STRIP_GPIO_PIN    D4 | ||||
| #define WS2812STRIP_LEDS        10 | ||||
|  | ||||
| #endif /* End FANLEDCTL_PINS */ | ||||
							
								
								
									
										33
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								src/main.cpp
									
									
									
									
									
								
							| @@ -3,7 +3,10 @@ | ||||
| #include <OneWire.h> | ||||
| #include <Adafruit_NeoPixel.h> | ||||
| #include "controller.h" | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                                     MAKROS | ||||
|  ******************************************************************************/ | ||||
| #define MAX(x, y)   (((x) > (y)) ? (x) : (y)) | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                                     DEFINES | ||||
| @@ -20,8 +23,7 @@ | ||||
| /****************************************************************************** | ||||
|  *                            LOCAL VARIABLES | ||||
|  ******************************************************************************/ | ||||
| Adafruit_NeoPixel*  pPixelFan = NULL; | ||||
| Adafruit_NeoPixel*  pPixel    = NULL; | ||||
| Adafruit_NeoPixel  pixels(MAX(WS2812SINGLE_LEDS, WS2812STRIP_GPIO_PIN), 0, NEO_RGB + NEO_KHZ800); | ||||
|  | ||||
| OneWire oneWire(GPIO_DS18B20); | ||||
| DallasTemperature sensors(&oneWire); | ||||
| @@ -38,13 +40,13 @@ void setup() { | ||||
|   pinMode(SIGNAL_PIN, INPUT); | ||||
|  | ||||
|  | ||||
|   pPixelFan = new Adafruit_NeoPixel(WS2812_LEDS1, GPIO_WS2812_PIN1, NEO_RGB + NEO_KHZ800); | ||||
|   pixels.setPin(WS2812SINGLE_GPIO_PIN); | ||||
|   pixels.begin(); | ||||
|   pixels.clear(); | ||||
|   pixels.setBrightness(100); | ||||
|   pixels.fill(pixels.Color(255,0,0)); | ||||
|   pixels.show(); | ||||
|  | ||||
|   pPixelFan->begin(); | ||||
|   pPixelFan->clear(); | ||||
|   pPixelFan->fill(pPixelFan->Color(255,0,0)); | ||||
|   pPixelFan->setBrightness(100); | ||||
|   pPixelFan->show(); | ||||
|  | ||||
| /* Initialize Temperature sensor */ | ||||
|   sensors.begin(); | ||||
| @@ -54,6 +56,10 @@ void setup() { | ||||
|     sensors.begin(); | ||||
|     Serial.println("Reset 1-Wire Bus"); | ||||
|   } | ||||
|    | ||||
|   pixels.fill(pixels.Color(0,255,0)); | ||||
|   pixels.setBrightness(50); | ||||
|   pixels.show(); | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -117,9 +123,12 @@ void loop() { | ||||
|     fanSpeedPercent = (100 - MIN_FAN_SPEED_PERCENT) * (temp - MIN_TEMP) / (MAX_TEMP - MIN_TEMP) + MIN_FAN_SPEED_PERCENT; | ||||
|   } | ||||
|  | ||||
|   pPixelFan->fill(pPixelFan->Color(0,255,0)); | ||||
|   pPixelFan->setBrightness(fanSpeedPercent); | ||||
|   pPixelFan->show(); | ||||
|   pixels.setPin(WS2812STRIP_GPIO_PIN); | ||||
|   pixels.begin(); | ||||
|   pixels.clear(); | ||||
|   pixels.fill(pixels.Color(0,255,0)); | ||||
|   pixels.setBrightness(fanSpeedPercent); | ||||
|   pixels.show(); | ||||
|  | ||||
|   Serial.print(fanSpeedPercent); | ||||
|   Serial.print("%;"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user