"We are back" « oc.at

LED mit Mic steuern - Code issue

slateSC 16.08.2020 - 14:12 11206 45
Posts

wergor

connoisseur de mimi
Avatar
Registered: Jul 2005
Location: vulkanland
Posts: 4137
also ich seh das von vinci eher als pseudocode ;) aber vielleicht kenne ich auch einfach nur konstrukte wie
Code: C++
uint32_t then{};
nicht.
wie auch immer, sein code würde alle 200 us ein analogRead machen (also 5 kHz sampling rate), der wert müsste dann in ein array o.ä. gepusht werden auf das dann die FFT angewendet wird.
Bearbeitet von wergor am 17.08.2020, 23:05

Vinci

hatin' on summer
Registered: Jan 2003
Location: Wien
Posts: 5842
"uniform initialization"

Ja kenn mich mit Arduino nicht genug aus um da direkt was runtertipseln zu können. Aber das Prinzip sollte klar sein. Ich vermute jedoch, dass die 200µs nicht annähernd erreicht werden.

slateSC

The Suntoucher
Avatar
Registered: Jul 2004
Location: oö
Posts: 1256
Hmokay. Und wie hilft mir das alles jetzt weiter? :confused:

wergor

connoisseur de mimi
Avatar
Registered: Jul 2005
Location: vulkanland
Posts: 4137
ich hab mit meinem esp8266 mal was getestet:
Code: C++
uint16_t arr[1001];
uint16_t i = 0;


void setup() {
  // put your setup code here, to run once:
  pinMode(A0, INPUT);
  Serial.begin(9600);
}

void loop() {
  uint32_t t_start = millis();
  // put your main code here, to run repeatedly:
  i = 0;
  
for (uint16_t i = 0; i < 1000; i++) {
  arr[i++] = analogRead(A0);
  arr[i++] = analogRead(A0);
  arr[i++] = analogRead(A0);
  arr[i++] = analogRead(A0);
  arr[i++] = analogRead(A0);
  arr[i++] = analogRead(A0);
  arr[i++] = analogRead(A0);
  arr[i++] = analogRead(A0);
  arr[i++] = analogRead(A0);
  arr[i++] = analogRead(A0);
  
  arr[i++] = analogRead(A0);
  //...
  // insgesamt 1000 analogReads
}

 uint32_t t = millis() - t_start;

 Serial.println(t);
}
10^6 analogRead() brauchen 97-98 ms, also schafft der ADC ca 10Ms/s.

also dürfte sowas schon gehen:
Code: C++
uint16_t arr[5001];
uint16_t i = 0;

uint32_t us_last = 0;

void setup() {
  // put your setup code here, to run once:
  pinMode(A0, INPUT);
  Serial.begin(9600);
}

void loop() {
  uint32_t t_start = millis();
  // put your main code here, to run repeatedly:

  if (micros() - us_last >= 200) {
    us_last = micros();

    arr[i++] = analogRead(A0);
  }
  
  if (i == 5000) {
    //FFT auf das array
  
    //raussschreiben an die leds
  
    i = 0;  
  }
}

slateSC

The Suntoucher
Avatar
Registered: Jul 2004
Location: oö
Posts: 1256
An dieser Stelle noch mal vielen Dank für die Geduld ;)

Hab jetzt den zweiten Code in den von dir integriert.
Beim Compilen wehrt er sich aber gegen das: "if (i == 5000)"

Siehe Screenshot:
click to enlarge

wergor

connoisseur de mimi
Avatar
Registered: Jul 2005
Location: vulkanland
Posts: 4137
Was steht denn vor dem if? Magst deinen aktuellen Code Posten?

slateSC

The Suntoucher
Avatar
Registered: Jul 2004
Location: oö
Posts: 1256
Klar doch:

Code:
#include <FastLED.h>

#define LED_PIN     3
#define NUM_LEDS    60
#define BRIGHTNESS  64
#define LED_TYPE    WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];

#define UPDATES_PER_SECOND 100


CRGBPalette16 currentPalette;
TBlendType    currentBlending;

extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;


uint16_t arr[5001];
uint16_t i = 0;

uint32_t us_last = 0;

void setup() {
  // put your setup code here, to run once:
      delay( 3000 ); // power-up safety delay
    FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
    FastLED.setBrightness(  BRIGHTNESS );
    
    currentPalette = RainbowColors_p;
    currentBlending = LINEARBLEND;

  pinMode(A0, INPUT);
  Serial.begin(9600);
}

void loop() {
  uint32_t t_start = millis();
  // put your main code here, to run repeatedly:

    ChangePalettePeriodically();
    
    static uint8_t startIndex = 0;
    startIndex = startIndex + 1; /* motion speed */
    
    FillLEDsFromPaletteColors( startIndex);
    
    FastLED.show();
    FastLED.delay(1000 / UPDATES_PER_SECOND);
}

void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
    uint8_t brightness = 255;
    
    for( int i = 0; i < NUM_LEDS; i++) {
        leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
        colorIndex += 3;
    }
}
void ChangePalettePeriodically()
{
    uint8_t secondHand = (millis() / 1000) % 60;
    static uint8_t lastSecond = 99;
    
    if( lastSecond != secondHand) {
        lastSecond = secondHand;
        if( secondHand ==  0)  { currentPalette = RainbowColors_p;         currentBlending = LINEARBLEND; }
        if( secondHand == 10)  { currentPalette = RainbowStripeColors_p;   currentBlending = NOBLEND;  }
        if( secondHand == 15)  { currentPalette = RainbowStripeColors_p;   currentBlending = LINEARBLEND; }
        if( secondHand == 20)  { SetupPurpleAndGreenPalette();             currentBlending = LINEARBLEND; }
        if( secondHand == 25)  { SetupTotallyRandomPalette();              currentBlending = LINEARBLEND; }
        if( secondHand == 30)  { SetupBlackAndWhiteStripedPalette();       currentBlending = NOBLEND; }
        if( secondHand == 35)  { SetupBlackAndWhiteStripedPalette();       currentBlending = LINEARBLEND; }
        if( secondHand == 40)  { currentPalette = CloudColors_p;           currentBlending = LINEARBLEND; }
        if( secondHand == 45)  { currentPalette = PartyColors_p;           currentBlending = LINEARBLEND; }
        if( secondHand == 50)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND;  }
        if( secondHand == 55)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; }
    }
}
// This function fills the palette with totally random colors.
void SetupTotallyRandomPalette()
{
    for( int i = 0; i < 16; i++) {
        currentPalette[i] = CHSV( random8(), 255, random8());
    }
}

// This function sets up a palette of black and white stripes,
// using code.  Since the palette is effectively an array of
// sixteen CRGB colors, the various fill_* functions can be used
// to set them up.
void SetupBlackAndWhiteStripedPalette()
{
    // 'black out' all 16 palette entries...
    fill_solid( currentPalette, 16, CRGB::Black);
    // and set every fourth one to white.
    currentPalette[0] = CRGB::White;
    currentPalette[4] = CRGB::White;
    currentPalette[8] = CRGB::White;
    currentPalette[12] = CRGB::White;
    
}

// This function sets up a palette of purple and green stripes.
void SetupPurpleAndGreenPalette()
{
    CRGB purple = CHSV( HUE_PURPLE, 255, 255);
    CRGB green  = CHSV( HUE_GREEN, 255, 255);
    CRGB black  = CRGB::Black;
    
    currentPalette = CRGBPalette16(
                                   green,  green,  black,  black,
                                   purple, purple, black,  black,
                                   green,  green,  black,  black,
                                   purple, purple, black,  black );
}


// This example shows how to set up a static color palette
// which is stored in PROGMEM (flash), which is almost always more
// plentiful than RAM.  A static PROGMEM palette like this
// takes up 64 bytes of flash.
const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
{
    CRGB::Red,
    CRGB::Gray, // 'white' is too bright compared to red and blue
    CRGB::Blue,
    CRGB::Black,
    
    CRGB::Red,
    CRGB::Gray,
    CRGB::Blue,
    CRGB::Black,
    
    CRGB::Red,
    CRGB::Red,
    CRGB::Gray,
    CRGB::Gray,
    CRGB::Blue,
    CRGB::Blue,
    CRGB::Black,
    CRGB::Black
};
  if (micros() - us_last >= 200) {
    us_last = micros();

    arr[i++] = analogRead(A0);
  }
  
  if (i == 5000) {
    //FFT auf das array
  
    //raussschreiben an die leds
  
    i = 0;  
  }
}

wergor

connoisseur de mimi
Avatar
Registered: Jul 2005
Location: vulkanland
Posts: 4137
du hattest da einen copy-paste fehler. alles ab zeile 146 deines codes gehört in den function body von loop().
das kompiliert:
Code: C++
#include <FastLED.h>

#define LED_PIN     3
#define NUM_LEDS    60
#define BRIGHTNESS  64
#define LED_TYPE    WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];

#define UPDATES_PER_SECOND 100


CRGBPalette16 currentPalette;
TBlendType    currentBlending;

extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;


uint16_t arr[5001];
uint16_t i = 0;

uint32_t us_last = 0;

void setup() {
  // put your setup code here, to run once:
      delay( 3000 ); // power-up safety delay
    FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
    FastLED.setBrightness(  BRIGHTNESS );
    
    currentPalette = RainbowColors_p;
    currentBlending = LINEARBLEND;

  pinMode(A0, INPUT);
  Serial.begin(9600);
}

void loop() {
  uint32_t t_start = millis();
  // put your main code here, to run repeatedly:

  if (micros() - us_last >= 200) {
    us_last = micros();

    arr[i++] = analogRead(A0);
  }
  
  if (i == 5000) {
    //FFT auf das array
  
    //raussschreiben an die leds
  
    i = 0;  
  }

    ChangePalettePeriodically();
    
    static uint8_t startIndex = 0;
    startIndex = startIndex + 1; /* motion speed */
    
    FillLEDsFromPaletteColors( startIndex);
    
    FastLED.show();
    FastLED.delay(1000 / UPDATES_PER_SECOND);
}

void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
    uint8_t brightness = 255;
    
    for( int i = 0; i < NUM_LEDS; i++) {
        leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
        colorIndex += 3;
    }
}
void ChangePalettePeriodically()
{
    uint8_t secondHand = (millis() / 1000) % 60;
    static uint8_t lastSecond = 99;
    
    if( lastSecond != secondHand) {
        lastSecond = secondHand;
        if( secondHand ==  0)  { currentPalette = RainbowColors_p;         currentBlending = LINEARBLEND; }
        if( secondHand == 10)  { currentPalette = RainbowStripeColors_p;   currentBlending = NOBLEND;  }
        if( secondHand == 15)  { currentPalette = RainbowStripeColors_p;   currentBlending = LINEARBLEND; }
        if( secondHand == 20)  { SetupPurpleAndGreenPalette();             currentBlending = LINEARBLEND; }
        if( secondHand == 25)  { SetupTotallyRandomPalette();              currentBlending = LINEARBLEND; }
        if( secondHand == 30)  { SetupBlackAndWhiteStripedPalette();       currentBlending = NOBLEND; }
        if( secondHand == 35)  { SetupBlackAndWhiteStripedPalette();       currentBlending = LINEARBLEND; }
        if( secondHand == 40)  { currentPalette = CloudColors_p;           currentBlending = LINEARBLEND; }
        if( secondHand == 45)  { currentPalette = PartyColors_p;           currentBlending = LINEARBLEND; }
        if( secondHand == 50)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND;  }
        if( secondHand == 55)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; }
    }
}
// This function fills the palette with totally random colors.
void SetupTotallyRandomPalette()
{
    for( int i = 0; i < 16; i++) {
        currentPalette[i] = CHSV( random8(), 255, random8());
    }
}

// This function sets up a palette of black and white stripes,
// using code.  Since the palette is effectively an array of
// sixteen CRGB colors, the various fill_* functions can be used
// to set them up.
void SetupBlackAndWhiteStripedPalette()
{
    // 'black out' all 16 palette entries...
    fill_solid( currentPalette, 16, CRGB::Black);
    // and set every fourth one to white.
    currentPalette[0] = CRGB::White;
    currentPalette[4] = CRGB::White;
    currentPalette[8] = CRGB::White;
    currentPalette[12] = CRGB::White;
    
}

// This function sets up a palette of purple and green stripes.
void SetupPurpleAndGreenPalette()
{
    CRGB purple = CHSV( HUE_PURPLE, 255, 255);
    CRGB green  = CHSV( HUE_GREEN, 255, 255);
    CRGB black  = CRGB::Black;
    
    currentPalette = CRGBPalette16(
                                   green,  green,  black,  black,
                                   purple, purple, black,  black,
                                   green,  green,  black,  black,
                                   purple, purple, black,  black );
}


// This example shows how to set up a static color palette
// which is stored in PROGMEM (flash), which is almost always more
// plentiful than RAM.  A static PROGMEM palette like this
// takes up 64 bytes of flash.
const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
{
    CRGB::Red,
    CRGB::Gray, // 'white' is too bright compared to red and blue
    CRGB::Blue,
    CRGB::Black,
    
    CRGB::Red,
    CRGB::Gray,
    CRGB::Blue,
    CRGB::Black,
    
    CRGB::Red,
    CRGB::Red,
    CRGB::Gray,
    CRGB::Gray,
    CRGB::Blue,
    CRGB::Blue,
    CRGB::Black,
    CRGB::Black
};

ich habe kurz nach fft libraries gesucht. es gibt arduinoFFT, die mit gleitkommazahlen arbeitet. das wird sich am esp8266 mit 5ks aber nicht ausgehen, der hat zu wenig ram. fix_fft dürfte sich aber ausgehen. dann wäre der code aber ein bisschen anzupassen:
Code: C++
int8_t real[5001];    //statt arr[5001]
int8_t imag[5001];
//[...]

void setup() {
//[...]
memset(real, 5001, 0);
memset(imag, 5001, 0);
}

und
Code: C++
real[i] = static_cast<int8_t>(analogRead(A0) >> 3);
imag[i] = 0;
i++;
hintergrund: fix_fft rechnet mit 8-bit singed integers (also 7 bits + 1 bit sign) darum muss man die 3 least significant bits von den analogen daten abziehen. das ist beim esp8266 aber eh kein großer verlust. imag[] muss auch immer genullt werden, weil die fix_fft library die ergebnisse in die arrays reinschreibt die man ihr übergibt.
Bearbeitet von wergor am 21.08.2020, 16:41

slateSC

The Suntoucher
Avatar
Registered: Jul 2004
Location: oö
Posts: 1256
Hmm, jetzt schmeckt ihm das "arr[i++] = analogRead(A0);" nicht

Code:
#include <FastLED.h>
#include <fix_fft.h>

#define LED_PIN     3
#define NUM_LEDS    60
#define BRIGHTNESS  64
#define LED_TYPE    WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];

#define UPDATES_PER_SECOND 100


CRGBPalette16 currentPalette;
TBlendType    currentBlending;

extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;

int8_t real[5001];    //statt arr[5001]
int8_t imag[5001];
//uint16_t arr[5001];
uint16_t i = 0;

uint32_t us_last = 0;

void setup() {
  // put your setup code here, to run once:
    delay( 3000 ); // power-up safety delay
    FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
    FastLED.setBrightness(  BRIGHTNESS );
    
    currentPalette = RainbowColors_p;
    currentBlending = LINEARBLEND;

  pinMode(A0, INPUT);
  Serial.begin(9600);

  memset(real, 5001, 0);
  memset(imag, 5001, 0);

  real[i] = static_cast<int8_t>(analogRead(A0) >> 3);
  imag[i] = 0;
  i++;
}

void loop() {
  uint32_t t_start = millis();
  // put your main code here, to run repeatedly:

  if (micros() - us_last >= 200) {
    us_last = micros();

    arr[i++] = analogRead(A0);
  }
  
  if (i == 5000) {
    //FFT auf das array
  
    //raussschreiben an die leds
  
    i = 0;  
  }

    ChangePalettePeriodically();
    
    static uint8_t startIndex = 0;
    startIndex = startIndex + 1; /* motion speed */
    
    FillLEDsFromPaletteColors( startIndex);
    
    FastLED.show();
    FastLED.delay(1000 / UPDATES_PER_SECOND);
}

void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
    uint8_t brightness = 255;
    
    for( int i = 0; i < NUM_LEDS; i++) {
        leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
        colorIndex += 3;
    }
}
void ChangePalettePeriodically()
{
    uint8_t secondHand = (millis() / 1000) % 60;
    static uint8_t lastSecond = 99;
    
    if( lastSecond != secondHand) {
        lastSecond = secondHand;
        if( secondHand ==  0)  { currentPalette = RainbowColors_p;         currentBlending = LINEARBLEND; }
        if( secondHand == 10)  { currentPalette = RainbowStripeColors_p;   currentBlending = NOBLEND;  }
        if( secondHand == 15)  { currentPalette = RainbowStripeColors_p;   currentBlending = LINEARBLEND; }
        if( secondHand == 20)  { SetupPurpleAndGreenPalette();             currentBlending = LINEARBLEND; }
        if( secondHand == 25)  { SetupTotallyRandomPalette();              currentBlending = LINEARBLEND; }
        if( secondHand == 30)  { SetupBlackAndWhiteStripedPalette();       currentBlending = NOBLEND; }
        if( secondHand == 35)  { SetupBlackAndWhiteStripedPalette();       currentBlending = LINEARBLEND; }
        if( secondHand == 40)  { currentPalette = CloudColors_p;           currentBlending = LINEARBLEND; }
        if( secondHand == 45)  { currentPalette = PartyColors_p;           currentBlending = LINEARBLEND; }
        if( secondHand == 50)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND;  }
        if( secondHand == 55)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; }
    }
}
// This function fills the palette with totally random colors.
void SetupTotallyRandomPalette()
{
    for( int i = 0; i < 16; i++) {
        currentPalette[i] = CHSV( random8(), 255, random8());
    }
}

// This function sets up a palette of black and white stripes,
// using code.  Since the palette is effectively an array of
// sixteen CRGB colors, the various fill_* functions can be used
// to set them up.
void SetupBlackAndWhiteStripedPalette()
{
    // 'black out' all 16 palette entries...
    fill_solid( currentPalette, 16, CRGB::Black);
    // and set every fourth one to white.
    currentPalette[0] = CRGB::White;
    currentPalette[4] = CRGB::White;
    currentPalette[8] = CRGB::White;
    currentPalette[12] = CRGB::White;
    
}

// This function sets up a palette of purple and green stripes.
void SetupPurpleAndGreenPalette()
{
    CRGB purple = CHSV( HUE_PURPLE, 255, 255);
    CRGB green  = CHSV( HUE_GREEN, 255, 255);
    CRGB black  = CRGB::Black;
    
    currentPalette = CRGBPalette16(
                                   green,  green,  black,  black,
                                   purple, purple, black,  black,
                                   green,  green,  black,  black,
                                   purple, purple, black,  black );
}


// This example shows how to set up a static color palette
// which is stored in PROGMEM (flash), which is almost always more
// plentiful than RAM.  A static PROGMEM palette like this
// takes up 64 bytes of flash.
const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
{
    CRGB::Red,
    CRGB::Gray, // 'white' is too bright compared to red and blue
    CRGB::Blue,
    CRGB::Black,
    
    CRGB::Red,
    CRGB::Gray,
    CRGB::Blue,
    CRGB::Black,
    
    CRGB::Red,
    CRGB::Red,
    CRGB::Gray,
    CRGB::Gray,
    CRGB::Blue,
    CRGB::Blue,
    CRGB::Black,
    CRGB::Black
};

wergor

connoisseur de mimi
Avatar
Registered: Jul 2005
Location: vulkanland
Posts: 4137
Der Teil
Code:
real[i] = static_cast<int8_t>(analogRead(A0) >> 3);
  imag[i] = 0;
  i++;
gehört in die Loop()! Statt arr[...

slateSC

The Suntoucher
Avatar
Registered: Jul 2004
Location: oö
Posts: 1256
okay jetzt bekomm ich es compiled und kanns auch hochladen, allerdings läuft nur die animationsfolge ab.

wergor

connoisseur de mimi
Avatar
Registered: Jul 2005
Location: vulkanland
Posts: 4137
ich habe die fft noch nicht eingebaut ;)
wie willst du das spektrum auf deinem led streifen visualisiert haben?

slateSC

The Suntoucher
Avatar
Registered: Jul 2004
Location: oö
Posts: 1256
Von der Mitte nach außen :ghug:

wergor

connoisseur de mimi
Avatar
Registered: Jul 2005
Location: vulkanland
Posts: 4137
probier mal das:
Code: C++
#include <FastLED.h>
#include "arduinoFFT.h"

#define LED_PIN     3
#define NUM_LEDS    60
#define BRIGHTNESS  64
#define LED_TYPE    WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];

#define NUM_SAMPLES 256

#define UPDATES_PER_SECOND 100

arduinoFFT FFT = arduinoFFT();

double real[NUM_SAMPLES];
double imag[NUM_SAMPLES];
uint16_t i = 0;

uint32_t us_last = 0;

void setup() {
  // put your setup code here, to run once:
  delay( 3000 ); // power-up safety delay
  FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  FastLED.setBrightness(  BRIGHTNESS );

  pinMode(A0, INPUT);
  Serial.begin(9600);

  memset(real, NUM_SAMPLES, 0);
  memset(imag, NUM_SAMPLES, 0);
}

void loop() {
  // put your main code here, to run repeatedly:

  //samples aufnehmen
  if (micros() - us_last >= 100) {
    us_last = micros();

    real[i] = static_cast<double>(analogRead(A0));
    imag[i] = 0;
    i++;
  }

  //wenn genug samples gesammelt wurden
  if (i == NUM_SAMPLES) {
    i = 0;
    
    //FFT auf das array
    FFT.Windowing(real, NUM_SAMPLES, FFT_WIN_TYP_HAMMING, FFT_FORWARD);
    FFT.Compute(real, imag, NUM_SAMPLES, FFT_FORWARD);
    FFT.ComplexToMagnitude(real, imag, NUM_SAMPLES);

    //256 samples, davon die ersten 128 nutzbar
    //sample 0 nicht benutzen (=DC)
    //60 leds = 2x 30 LEDS
    // --> samples 4 - 123 (=120 samples) / 30 = 4 samples / LED
    double led_values[30];
    for (uint8_t j = 0; j < 30; j++) {
      led_values[j] = 0.0;
      for (uint8_t k = 0; k < 4; k++)
        led_values[j] += real[j * 4 + k + 4];
    }

    //skalieren auf 0...255 und rausschreiben an die leds
    for (uint8_t j = 0; j < 30; j++) {
      led_values[j] = led_values[j] / 4095.0 * 255.0;

      //raussschreiben an die leds
      leds[30 + j] = CRGB(static_cast<uint32_t>(led_values[j]), static_cast<uint32_t>(led_values[j]), static_cast<uint32_t>(led_values[j]));
      leds[29 - j] = CRGB(static_cast<uint32_t>(led_values[j]), static_cast<uint32_t>(led_values[j]), static_cast<uint32_t>(led_values[j]));
    } 
  }
}
(teilweise kopiert von hier)

in zeile 70 musst du dich wahrscheinlich mit dem faktor 4095.0 spielen, um den ganzen helligkeitsumfang ausnutzen zu können.
Bearbeitet von wergor am 21.08.2020, 18:55

slateSC

The Suntoucher
Avatar
Registered: Jul 2004
Location: oö
Posts: 1256
Edit: also sollte da jetzt schon etwas passieren? Oder muss ich den basis Code wieder reinpacken.
So bleibt er nämlich finster, trotz ausschlag vom MIC.
Bearbeitet von slateSC am 21.08.2020, 19:06
Kontakt | Unser Forum | Über overclockers.at | Impressum | Datenschutz