Coder Social home page Coder Social logo

smartleds's Introduction

RobotikaBrno

Chceš mít přehled o tom co se u nás děje? Pak jsi tu správně!

Do you want to have an overview of our activity? If so, this is the right place. However, we keep track of our projects only in Czech, sorry.

Probíhající projekty

2017

2016

  • SmartGlass (Honza Mrázek) - svítící skleničky, rychlý projekt z RoboTáboru

smartleds's People

Contributors

cednik avatar grantrolls avatar haberturdeur avatar jarekparal avatar kyklas avatar snijderc avatar tasssadar avatar thomasahlendorf avatar yaqwsx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smartleds's Issues

Dumping Hsv to console

What is the most sensible or elegant way to dump the (calculated) Hsv instance to serial console for e.g. verification?

Hsv color = Hsv(Rgb{ r, g, b });
log_d("Converted '%s' to RGB: %u, %u, %u.", inputColorHex, r, g, b);

// -> what to do about Hsv? there's no `toString()` or similar

Compiler warnings for missing return statement in Color.h

With Color.h i get two compiler warnings concerning missing return statements. Not sure if this may cause problems, the software is running for me.

Line 15
Rgb& operator=( Rgb r ) { swap( r ); }

no return statement in function returning non-void [-Wreturn-type]

Line 52
Hsv& operator=( Hsv h ) { swap( h ); }

no return statement in function returning non-void [-Wreturn-type]

No output on gpio

I try the example code on a Nodemcu-32s with a Wrooom32 modul. There was no output, but the RTM seemed to be working (added gpio signals watched with oscilloscope).

Finally, the issue was, that "gpio_set_direction" (Smartleds.h,113) modifyes (recently?) the pin-matrix set one line before - so line 112 becomes ineffective.

Switching Line 113 and 112 will fix the problem.

Color Structure/Union Initialization

When using the RGB union, using the value is nice to determine if there is any color or not.
However the value has its MSB uninitialized and are random causing issue in the comparison.

Adding an additional variable in the structure allows to initialized the MSB of the union.

Crash if setting hue value to 255

My code crashes if I use the HSV method for setting colors and set hue to 255 with full saturation/brightness. Right now my only workaround is to check if hue 255 and if so set to 0 before calling the function.

array of leds with a point method

Hello ! Thanks for the job you did.
I tried severals library, and yours is the only one I found, working with 19,18,26,23,5 pins, at the same time. I tried to use the implement of RMT of Fastled, but it didn't work so I wanted to use yours. I'm just facing one problem, I don't find a way to work with the library with a pointer array of smartleds. (It's not a necessity, but just more convenient). There is something too "high-level" for me. how is possible than a Instance of a class can be igual to a another instance of another class? (Smartled class = rgb class?)
Thanks for your help and the good job you did !

This is the code I used :

#include <Arduino.h>
#include <SmartLeds.h>

#define NB_STRIPS 4
#define NB_LEDS_PER_STRIP 6
byte leds_pins[]={19,18,26,23,5};

// SmartLed -> RMT driver (WS2812/WS2812B/SK6812/WS2813)
SmartLed *leds[3];


void setup() {
  Serial.begin(9600);  
  for(int i=0;i<NB_STRIPS;i++){
    leds[i]= new SmartLed ( LED_WS2812, NB_LEDS_PER_STRIP, leds_pins[i], i, DoubleBuffer );
}
}

uint8_t hue;
void showGradient() {
    hue++;
    // Use HSV to create nice gradient
   for(int i=0;i<NB_STRIPS;i++){
   for ( int j = 0; j != NB_LEDS_PER_STRIP; j++ ){
        //leds[i][ j ] = Hsv{ static_cast< uint8_t >( hue + 30 * j ), 255, 255 }; NOT WORKING !
        //(*leds)[i][ j ] = Hsv{ static_cast< uint8_t >( hue + 30 * j ), 255, 255 }; // NOT WORKING ! CRASH THE ESP32
        //(*leds)[i][ j ] = Rgb{ 255, 0, 0 }; NOT WORKING !
        }
    leds[i]->show();
    }
}

void loop() {
    Serial.println("New loop");
    showGradient();
    delay( 20 );
}

shouldn't wait() give back the semaphore ?

Hi,
The public wait() method (SmartLeds.h // line 157) try to Take the semaphore in order
to ensure that transmission ended.

But once wait() took the semaphore, shouldn't it give it back immediately ?

As i understand it right now if you call the wait() method,
then once the transmission is over, the semaphore is taken but never given back which freeze the whole system, right ?

If i am correct, in SmartLeds.h // line 158

xSemaphoreTake( _finishedFlag, portMAX_DELAY );

should be followed with

xSemaphoreGive( _finishedFlag );

Thanks !

Best,

Assert statement causes compilation error with default ESP32 build in platformIO

Assert statement causes compilation error with default ESP32 build in platformIO

In file included from C:/Users/Grant/.platformio/packages/framework-espidf/components/newlib/platform_include/assert.h:22,
                 from c:\users\grant\.platformio\packages\toolchain-xtensa32\xtensa-esp32-elf\include\c++\8.4.0\cassert:44,
                 from lib/SmartLeds/src/Color.cpp:4:
lib/SmartLeds/src/Color.cpp: In function 'int iRgbSqrt(int)':
lib/SmartLeds/src/Color.cpp:15:57: error: left operand of comma operator has no effect 
[-Werror=unused-value]
     assert(("sqrt input should be non-negative", num >= 0));
                                                         ^
lib/SmartLeds/src/Color.cpp:16:59: error: left operand of comma operator has no effect 
[-Werror=unused-value]
     assert(("sqrt input should no exceed 16 bits", num <= 0xFFFF));
                                                           ^~~~~~
cc1plus.exe: some warnings being treated as errors
*** [.pio\build\esp32-evb\lib287\SmartLeds\Color.o] Error 1

Invalid Pixel in data stream

Hi,

I am using this library with https://github.com/OttoWinter/esphomelib to control WS2812B LED strip.

I am facing a particular case where every 4th and 5th LED in the strip show different colors. The funny thing is that the pattern repeats.

00FF00 00FF00 00FF00 00FF00 80FF00 0007F00 00FF00 00FF00 80FF00 0007F00 00FF00 0FF00

I have used a Saleae logic analyzer and a custom analyser to decode the pulses. The timing are correct, I updated them based on https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/ and what I have sampled from the WS2812B chip.

The invalid pixel does not always show.

I am attaching the output of the ESP32, the intended color is 00FF00. I configured for 85 pixel but 88 are generated, I am guessing that the additional 3 pixel are to complete a 32 block of pulses.
output.log

Why APA?

I 'm not using apa method, just an single led connection with 3 "+ data -" wires.
Yet, there are some errors on compilation.

Missing include <soc/dport_reg.h> on arduino-esp32-v4.0

If building with

platform_packages =
    [email protected]
    framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#idf-release/v4.0

it wont compile because of:

SmartLeds.h:111:34: error: 'DPORT_PERIP_CLK_EN_REG' was not declared in this scope

it seems that v4.0 is missing libraries. To fix it you need to add:

#include <soc/dport_reg.h>

to the Arduino-if.

Compiller error: 'bb' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Compilation log:

Processing esp32doit-devkit-v1 (platform: espressif32; board: esp32doit-devkit-v1; framework: espidf)
--------------------------------------------------------------------------------------------------------------

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 1.11.2 > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-espidf 3.30300.190916 (3.3.0)
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <SmartLeds> 1.1.6
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\liba34\SmartLeds_ID1740\Color.o
.pio\libdeps\esp32doit-devkit-v1\SmartLeds_ID1740\src\Color.cpp: In constructor 'Rgb::Rgb(Hsv)':
.pio\libdeps\esp32doit-devkit-v1\SmartLeds_ID1740\src\Color.cpp:13:39: error: 'bb' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 int down2( int x ) { return x / 255 / 255; }
                                       ^
.pio\libdeps\esp32doit-devkit-v1\SmartLeds_ID1740\src\Color.cpp:26:17: note: 'bb' was declared here
     int rr, gg, bb;
                 ^
.pio\libdeps\esp32doit-devkit-v1\SmartLeds_ID1740\src\Color.cpp:13:39: error: 'gg' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 int down2( int x ) { return x / 255 / 255; }
                                       ^
.pio\libdeps\esp32doit-devkit-v1\SmartLeds_ID1740\src\Color.cpp:26:13: note: 'gg' was declared here
     int rr, gg, bb;
             ^
.pio\libdeps\esp32doit-devkit-v1\SmartLeds_ID1740\src\Color.cpp:13:39: error: 'rr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 int down2( int x ) { return x / 255 / 255; }
                                       ^
.pio\libdeps\esp32doit-devkit-v1\SmartLeds_ID1740\src\Color.cpp:26:9: note: 'rr' was declared here
     int rr, gg, bb;
         ^
.pio\libdeps\esp32doit-devkit-v1\SmartLeds_ID1740\src\Color.cpp: At global scope:
.pio\libdeps\esp32doit-devkit-v1\SmartLeds_ID1740\src\Color.cpp:10:5: warning: 'int {anonymous}::up3(int)' defined but not used [-Wunused-function]
 int up3( int x ) { return x * 255 * 255 * 255; }
     ^
.pio\libdeps\esp32doit-devkit-v1\SmartLeds_ID1740\src\Color.cpp:14:5: warning: 'int {anonymous}::down3(int)' defined but not used [-Wunused-function]
 int down3( int x ) { return x / 255 / 255 / 255; }
     ^
cc1plus.exe: some warnings being treated as errors
*** [.pio\build\esp32doit-devkit-v1\liba34\SmartLeds_ID1740\Color.o] Error 1

Problem with multiple ledstrip

Hi,

I have a problem when I want to use 2 (or more) ledstrip, for example with :

#include "LearningKit.h"
#include <SmartLeds.h>

const int LED_COUNT = 72;
const int DATA_PIN1 = 12;
const int DATA_PIN2 = 13;
const int CHANNEL1 = 0;
const int CHANNEL2 = 1;

SmartLed leds1( LED_WS2812B, LED_COUNT, DATA_PIN1, CHANNEL1, DoubleBuffer );
SmartLed leds2( LED_WS2812B, LED_COUNT, DATA_PIN2, CHANNEL2, DoubleBuffer );

void setup() {
        Serial.begin(921600);
        delay(200);
        //Initialize the led pin
        pinMode(LED_BUILTIN, OUTPUT);
}

uint8_t hue;
void showGradient() {
        hue++;
        // Use HSV to create nice gradient
        for ( int i = 0; i != LED_COUNT; i++ ) {
                leds1[ i ] = Hsv { static_cast< uint8_t >( hue + 30 * i ), 255, 255 };
                leds2[ i ] = Hsv { static_cast< uint8_t >( hue + 30 * i ), 255, 255 };
        }
        leds1.show();
        leds2.show();
        // Show is asynchronous; if we need to wait for the end of transmission,
        // we can use leds.wait(); however we use double buffered mode, so we
        // can start drawing right after showing.
}

void showRgb() {
        for ( int i = 0; i != LED_COUNT; i++ ) {
                leds1[ i ] = Rgb { 255, 0, 0 };
                leds1.show();
                leds2[ i ] = Rgb { 255, 0, 0 };
                leds2.show();
        }
        delay(500);
        for ( int i = 0; i != LED_COUNT; i++ ) {
                leds1[ i ] = Rgb { 0, 255, 0 };
                leds1.show();
                leds2[ i ] = Rgb { 0, 255, 0 };
                leds2.show();
        }
        delay(500);
        for ( int i = 0; i != LED_COUNT; i++ ) {
                leds1[ i ] = Rgb { 0, 0, 255 };
                leds1.show();
                leds2[ i ] = Rgb { 0, 0, 255 };
                leds2.show();
        }
        delay(500);
}

void loop() {
        Serial.write("Hello2!\n");
        digitalWrite(LED_BUILTIN, HIGH);
        if ( millis() % 10000 < 5000 )
                showGradient();
        else
                showRgb();
        delay( 500 );
        digitalWrite(LED_BUILTIN, LOW);
        delay( 50 );
}

the board crash on the show() call

Hello2!
Guru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0)
Register dump:
PC      : 0x40081ac5  PS      : 0x00050034  A0      : 0x00040021  A1      : 0x3ffc0600
A2      : 0x8302304c  A3      : 0x3ffc0cd0  A4      : 0x40081b05  A5      : 0x3ffc05e0
A6      : 0x3ffc1c8c  A7      : 0x3ff56000  A8      : 0x00000001  A9      : 0x400855a8
A10     : 0x00000000  A11     : 0x00060e20  A12     : 0x00000003  A13     : 0x01000000
A14     : 0x00000001  A15     : 0x00000000  SAR     : 0x00000007  EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000  LBEG    : 0x400d1b4c  LEND    : 0x400d1b6b  LCOUNT  : 0x00000000

Backtrace: 0x40081ac5:0x3ffc0600 0x00040021:0x00000000

CPU halted.```

compile error in arduino

WARNING: library SmartLeds-master claims to run on (espressif32) architecture(s) and may be incompatible with your current board which runs on (esp32) architecture(s).
In file included from /home/fleeky/Arduino/sketch_jan18a/sketch_jan18a.ino:2:0:
/home/fleeky/Arduino/libraries/SmartLeds-master/src/SmartLeds.h: In member function 'void Apa102::startTransmission()':
/home/fleeky/Arduino/libraries/SmartLeds-master/src/SmartLeds.h:363:32: error: 'spi_transaction_t {aka struct spi_transaction_t}' has no member named 'command'
_transactions[ i ].command = 0;
^
/home/fleeky/Arduino/libraries/SmartLeds-master/src/SmartLeds.h:364:32: error: 'spi_transaction_t {aka struct spi_transaction_t}' has no member named 'address'
_transactions[ i ].address = 0;
^
exit status 1
Error compiling for board Node32s.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.