Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Add new parameter, OFFSET #407

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Arduino/McLighting/McLighting.ino
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,26 @@ void saveConfigCallback () {
#include "custom_ws2812fx_animations.h" // Add animations in this file
#endif

#ifdef OFFSET
void OffsetShow(void) {
static uint8_t tmpPixels[NUMLEDS * 4]; // allocate space for a copy of the ADafruit pixel data
uint8_t bytesPerPixel = strip->getNumBytes() / strip->getLength(); // 3=RGB, 4=RGBW

// copy the Adafruit pixel array
memcpy(tmpPixels, strip->getPixels(), strip->getNumBytes());

// offset the data in the Adafruit pixel array
memcpy(strip->getPixels() + OFFSET * bytesPerPixel, tmpPixels, (NUMLEDS - OFFSET) * bytesPerPixel);
memcpy(strip->getPixels(), tmpPixels + (NUMLEDS - OFFSET) * bytesPerPixel, OFFSET * bytesPerPixel);

// run the standard Adafruit show() function
strip->Adafruit_NeoPixel::show();

// copy the original pixel data back to the Adafruit pixel array
memcpy(strip->getPixels(), tmpPixels, strip->getNumBytes());
}
#endif

// function to Initialize the strip
void initStrip(uint16_t stripSize = WS2812FXStripSettings.stripSize, neoPixelType RGBOrder = WS2812FXStripSettings.RGBOrder, uint8_t pin = WS2812FXStripSettings.pin){
if (strip) {
Expand Down Expand Up @@ -283,6 +303,10 @@ void initStrip(uint16_t stripSize = WS2812FXStripSettings.stripSize, neoPixelTyp
// on a live circuit...if you must, connect GND first.

strip->init();
#ifdef OFFSET
strip->setCustomShow(OffsetShow);
#endif

#if defined(USE_WS2812FX_DMA) or defined(USE_WS2812FX_UART1) or defined(USE_WS2812FX_UART2)
initDMA(stripSize);
strip->setCustomShow(DMA_Show);
Expand Down
2 changes: 2 additions & 0 deletions Arduino/McLighting/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Neopixel
#define LED_PIN 14 // LED_PIN (14 / D5) where neopixel / WS2811 strip is attached
#define NUMLEDS 24 // Number of leds in the strip
//
//#define OFFSET // If defined, first led of starting effect like dual scan,scan etc, is traslated of OFFSET number of leds. Not use this in conjuction of USE_WS2812FX_DMA,USE_WS2812FX_UART1 or USE_WS2812FX_UART2
//#define LED_TYPE_WS2811 // Uncomment if LED type uses 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
#define BUILTIN_LED 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
#define BUTTON 4 // Input pin (4 / D2) for switching the LED strip on / off, connect this PIN to ground to trigger button.
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# McLighting v2 - The ESP8266 based multi-client lighting gadget

This version, add ability to translate starting led of effect by OFFSET number of leds, respect of elettric wire of led strip.
Thanks to @moose4lord

[![Gitter](https://badges.gitter.im/mclighting/Lobby.svg)](https://gitter.im/mclighting/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Build Status](https://travis-ci.com/toblum/McLighting.svg?branch=master)](https://travis-ci.com/toblum/McLighting) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![version](https://img.shields.io/badge/version-v2.2.4-blue.svg)](https://github.com/toblum/McLighting/blob/master/Arduino/McLighting/version.h)

McLighting (the multi-client lighting gadget) is a very cheap internet-controllable lighting solution based on the famous ESP8266 microcontroller and WS2811/2812 led strips. It features among other things a web-interface, a REST-API and a websocket connector.
Expand Down