Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastLed VU and VPotRing ( ws2812 ) #944

Open
Jhenesson opened this issue Jul 26, 2023 · 3 comments
Open

FastLed VU and VPotRing ( ws2812 ) #944

Jhenesson opened this issue Jul 26, 2023 · 3 comments

Comments

@Jhenesson
Copy link

Jhenesson commented Jul 26, 2023

Hi @tttapa ! I want to thank you for the great work, it's all excellent.

After a long time testing and planning my controller, I'm close to success.

But only one function is missing: VPotRing using a ws2812 led ring (to read the MCU position and represent the potentiometer position)

I'm not a programming expert, I've been gathering user codes here and trying to assemble, this was the last code I got.
The VU is working, but I was not successful in VPotRing.

If you can help me, I would be grateful (I imagine that several other users are also interested in this)

#include <FastLED.h>
#include <Control_Surface.h>

#define F_PIN1  3
#define F_PIN2  4
#define F_PIN3  5
#define NUM_LEDS_RING  12
#define NUM_LEDS    12
#define LED_TYPE    WS2812
#define COLOR_ORDER GRB
#define BANKS 4 
 
 
USBMIDI_Interface midi;
const int tracks = 8/BANKS;

// Banks conf.
Bank<BANKS> bank(8/BANKS);  
IncrementDecrementSelector<BANKS> bankselector = {bank, {7, 8}, Wrap::Wrap};



// VU meters
unsigned int decayTime = MCU::VUDecay::Default ;
MCU::Bankable::VU<BANKS> vu[] = {
  {bank, 1,decayTime},
  {bank, 2,decayTime},
}; 

// Vpot
MCU::Bankable::VPotRing<BANKS> vpot[] = {
  {bank, 1},
  {bank, 2},
}; 

//---- FastLED config. ---//

DEFINE_GRADIENT_PALETTE(bgyr_gp)         // Gradient Palette for FastLED
{
    0,   0,  0,200,
   80,   0,200,  0,
  176,  80, 80,  0,
  230, 200,  0,  0, 
  255, 220,  0,  0  
};

CRGB leds1[NUM_LEDS];
CRGB leds2[NUM_LEDS];
CRGB ledsRing[NUM_LEDS_RING];
uint8_t gBrightness = 70;
CRGBPalette16 currentPalette;
TBlendType    currentBlending;

void FastLEDsetup() {  
 FastLED.addLeds<LED_TYPE, F_PIN1, COLOR_ORDER>(leds1, NUM_LEDS).setCorrection(TypicalLEDStrip);

  FastLED.addLeds<LED_TYPE, F_PIN2, COLOR_ORDER>(leds2, NUM_LEDS).setCorrection(TypicalLEDStrip);

 FastLED.addLeds<LED_TYPE, F_PIN3, COLOR_ORDER>(ledsRing, NUM_LEDS_RING).setCorrection(TypicalLEDStrip);


  FastLED.setBrightness(gBrightness);
  currentBlending = LINEARBLEND;
  currentPalette = bgyr_gp;
} 



void updateVU(){
  FastLED.clear();
  for (int i = 0; i < tracks; i++)
  {
    if (vu[i].getDirty()) 
    {
        for(int pix = 0; pix < vu[0].getValue(); pix++) 
        { 
          leds1 [pix] = ColorFromPalette( currentPalette, pix*(255/NUM_LEDS), gBrightness, currentBlending);                       
        }
        for(int pix = 0; pix < vu[1].getValue(); pix++) 
        { 
          leds2 [pix] = ColorFromPalette( currentPalette, pix*(255/NUM_LEDS), gBrightness, currentBlending);                                    
        }
      vu[i].clearDirty();      
      FastLED.show();
    }
  }   
}








void updateVPotRing(){
  
  for (uint8_t i = 0; i < tracks; i++)
  {
    if (vpot[i].getDirty()) 
    {      
        for(uint8_t seg = 0; seg < NUM_LEDS_RING ; seg++) 
        { 
          if ( seg >= vpot[i].getStartOn() && seg < vpot[i].getStartOff() )
          {
            ledsRing[i] [seg] = CRGB::Red ; 
          }
          else 
          {
            ledsRing[i] [seg] = CRGB::Black; 
          }
        }
      vpot[i].clearDirty();      
      FastLED.show();
    }
  }   
}


void setup() {  
  FastLEDsetup();
  Control_Surface.begin();
}

 
void loop() {
  Control_Surface.loop();
  
  updateVU(); 
}

@Jhenesson Jhenesson changed the title FastLed VU and VPotRing ( ws2811 ) FastLed VU and VPotRing ( ws2812 ) Jul 26, 2023
@tttapa
Copy link
Owner

tttapa commented Jul 27, 2023

Could it be because the updateVPotRing function is never called?

@Jhenesson
Copy link
Author

I really do not know. I'm not a programmer and I have only light notions. The code I got from some user who posted it here.

#335

Could you help me with this?

@tttapa
Copy link
Owner

tttapa commented Jul 28, 2023

I'm afraid that general programming support is beyond the scope of this issue tracker.

I'd recommend writing up a specific question on https://forum.arduino.cc (be sure to read the guidelines and include your code - in code tags - and a link to the source where you got it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants