Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #19 from SciLor/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
SciLor authored Nov 24, 2016
2 parents c788116 + 0591659 commit 11fbc91
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 21 deletions.
8 changes: 6 additions & 2 deletions HyperionRGB/ConfigStatic.h.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@
#define CONFIG_LED_SPI_CHIPSET WS2801 //Comment out for clockless
//#define CONFIG_LED_CLOCKLESS_CHIPSET WS2812B //Comment in for clockless
//#define FASTLED_ALLOW_INTERRUPTS 0 //Comment in if clockless stripe (ex. WS2812B) is flickering
//#define CONFIG_LED_PWM 1 //Comment in if PWM Stripe

#define CONFIG_LED_DATAPIN D1
#define CONFIG_LED_CLOCKPIN D2 //Comment out for clockless
#define CONFIG_LED_DATAPIN D1 //Comment out for PWM
#define CONFIG_LED_CLOCKPIN D2 //Comment out for clockless / PWM
//#define CONFIG_LED_PWM_RED D1 //Comment in for PWM
//#define CONFIG_LED_PWM_GREEN D2 //Comment in for PWM
//#define CONFIG_LED_PWM_BLUE D3 //Comment in for PWM

//Pin order, see FastLED doc. NodeMCU should work with FASTLED_ESP8266_RAW_PIN_ORDER
#define FASTLED_ESP8266_RAW_PIN_ORDER
Expand Down
6 changes: 3 additions & 3 deletions HyperionRGB/HyperionRGB.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "WrapperWiFi.h"
#include "WrapperOTA.h"
#include "WrapperFastLed.h"
#include "WrapperLedControl.h"
#include "WrapperUdpLed.h"
#include "WrapperJsonServer.h"

Expand All @@ -23,7 +23,7 @@ LoggerInit loggerInit;
WrapperWiFi wifi;
WrapperOTA ota;

WrapperFastLed ledStrip;
WrapperLedControl ledStrip;

WrapperUdpLed udpLed;
WrapperJsonServer jsonServer;
Expand Down Expand Up @@ -186,7 +186,7 @@ void setup(void) {

initConfig();
ota = WrapperOTA();
ledStrip = WrapperFastLed();
ledStrip = WrapperLedControl();

statusThread.onRun(statusInfo);
statusThread.setInterval(5000);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#include "WrapperFastLed.h"
#include "WrapperLedControl.h"

void WrapperFastLed::begin() {
void WrapperLedControl::begin() {
#ifdef CONFIG_LED_CLOCKLESS_CHIPSET
Log.debug("Chipset=%s, dataPin=%i, clockPin=%s, colorOrder=%i, ledCount=%i", "Clockless", CONFIG_LED_DATAPIN, "NONE", CONFIG_LED_COLOR_ORDER, CONFIG_LED_COUNT);
#elif defined CONFIG_LED_PWM
Log.debug("Chipset=%s, redPin=%i, greenPin=%i, bluePin=%i, ledCount=%i", "PWM", CONFIG_LED_PWM_RED, CONFIG_LED_PWM_GREEN, CONFIG_LED_PWM_BLUE, CONFIG_LED_COUNT);
#if CONFIG_LED_COUNT != 1
#error "PWM only supports LED count set to one (even if you have multiple LEDs on your strip, they will all show the same color)"
#endif
#else
Log.debug("Chipset=%i, dataPin=%i, clockPin=%i, colorOrder=%i, ledCount=%i", CONFIG_LED_SPI_CHIPSET, CONFIG_LED_DATAPIN, CONFIG_LED_CLOCKPIN, CONFIG_LED_COLOR_ORDER, CONFIG_LED_COUNT);
#endif
Expand All @@ -13,29 +18,41 @@ void WrapperFastLed::begin() {

#ifdef CONFIG_LED_CLOCKLESS_CHIPSET
FastLED.addLeds<CONFIG_LED_CLOCKLESS_CHIPSET, CONFIG_LED_DATAPIN, CONFIG_LED_COLOR_ORDER>(leds, _ledCount);
#elif defined CONFIG_LED_PWM
//Nothing to to
#else
FastLED.addLeds<CONFIG_LED_SPI_CHIPSET, CONFIG_LED_DATAPIN, CONFIG_LED_CLOCKPIN, CONFIG_LED_COLOR_ORDER>(leds, _ledCount);
#endif
}

void WrapperFastLed::show(void) {
FastLED.show();
void WrapperLedControl::show(void) {
#if defined CONFIG_LED_PWM
analogWrite(CONFIG_LED_PWM_RED, map(leds[0].red, 0, 255, 0, PWMRANGE));
analogWrite(CONFIG_LED_PWM_GREEN, map(leds[0].green, 0, 255, 0, PWMRANGE));
analogWrite(CONFIG_LED_PWM_BLUE, map(leds[0].blue, 0, 255, 0, PWMRANGE));
#else
FastLED.show();
#endif
}

void WrapperFastLed::clear(void) {
FastLED.clear();
void WrapperLedControl::clear(void) {
#if defined CONFIG_LED_PWM
leds[0] = CRGB::Black;
#else
FastLED.clear();
#endif
}

void WrapperFastLed::fillSolid(CRGB color) {
void WrapperLedControl::fillSolid(CRGB color) {
fill_solid(leds, _ledCount, color);
show();
}

void WrapperFastLed::fillSolid(byte r, byte g, byte b) {
void WrapperLedControl::fillSolid(byte r, byte g, byte b) {
fillSolid(CRGB(r, g, b));
}

void WrapperFastLed::rainbowStep(void) {
void WrapperLedControl::rainbowStep(void) {
for (int i=0; i < _ledCount; i++) {
leds[i] = wheel((i + _rainbowStepState) % 255);
}
Expand All @@ -48,7 +65,7 @@ void WrapperFastLed::rainbowStep(void) {
}
}

CRGB WrapperFastLed::wheel(byte wheelPos) {
CRGB WrapperLedControl::wheel(byte wheelPos) {
CRGB color = CRGB();
if (wheelPos < 85) {
return color.setRGB(wheelPos * 3, 255 - wheelPos * 3, 0);
Expand All @@ -75,7 +92,7 @@ CRGB WrapperFastLed::wheel(byte wheelPos) {
// Default 120, suggested range 50-200.
#define SPARKING 120

void WrapperFastLed::fire2012Step(void) {
void WrapperLedControl::fire2012Step(void) {
// Step 1. Cool down every cell a little
for( int i = 0; i < _ledCount; i++) {
_fire2012Heat[i] = qsub8( _fire2012Heat[i], random8(0, ((COOLING * 10) / _ledCount) + 2));
Expand All @@ -88,7 +105,7 @@ void WrapperFastLed::fire2012Step(void) {

// Step 3. Randomly ignite new 'sparks' of _fire2012Heat near the bottom
if( random8() < SPARKING ) {
int y = random8(7);
int y = random8(min(7, _ledCount - 1));
_fire2012Heat[y] = qadd8(_fire2012Heat[y], random8(160,255));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef WrapperFastLed_h
#define WrapperFastLed_h
#ifndef WrapperLedControl_h
#define WrapperLedControl_h

#include "BaseHeader.h"

#include <FastLED.h>

class WrapperFastLed {
class WrapperLedControl {
public:
void
begin(),
Expand Down
1 change: 0 additions & 1 deletion HyperionRGB/WrapperWebconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "BaseHeader.h"

#include <ESP8266WebServer.h>
#include "WrapperFastLed.h"
#include <LinkedList.h>

class SelectEntryBase {
Expand Down

0 comments on commit 11fbc91

Please sign in to comment.