Function not declared in scope: used to work and now stopped working (?)


hello,

i use lot of sample files learn , have been using arduino web editor, great. now, of sudden, of programs had complain functions not being declared. these used work fine , of them borrowed people share sample code of higher quality own coding. looked @ arduino cookbook , doesn't declaring function. happened? doing wrong? i'll post code 1 grabbed right off of git hub of samples fastled.

i using arduino yun.

error: 'changepaletteperiodically' not declared in scope. (again, i've used before , worked)

what heck changed?

code:
code: [select]
#include <fastled.h>

#define led_pin     5
#define num_leds    10
#define brightness  64
#define led_type    ws2811
#define color_order grb
crgb leds[num_leds];

#define updates_per_second 100

// example shows several ways set , use 'palettes' of colors
// fastled.
//
// these compact palettes provide easy way re-colorize your
// animation on fly, quickly, easily, , low overhead.
//
// using palettes simpler in practice in theory, first just
// run sketch, , watch pretty lights read through
// code.  although sketch has 8 (or more) different color schemes,
// entire sketch compiles down 6.5k on avr.
//
// fastled provides few pre-configured color palettes, , makes it
// extremely easy make own color schemes palettes.
//
// notes on more abstract 'theory , practice' of
// fastled compact palettes @ bottom of file.



crgbpalette16 currentpalette;
tblendtype    currentblending;

extern crgbpalette16 myredwhitebluepalette;
extern const tprogmempalette16 myredwhitebluepalette_p progmem;


void setup() {
    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;
}


void loop()
{
    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 = 0; < num_leds; i++) {
        leds[i] = colorfrompalette( currentpalette, colorindex, brightness, currentblending);
        colorindex += 3;
    }
}


// there several different palettes of colors demonstrated here.
//
// fastled provides several 'preset' palettes: rainbowcolors_p, rainbowstripecolors_p,
// oceancolors_p, cloudcolors_p, lavacolors_p, forestcolors_p, , partycolors_p.
//
// additionally, can manually define own color palettes, or can write
// code creates color palettes on fly.  shown here.

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; }
    }
}

// function fills palette totally random colors.
void setuptotallyrandompalette()
{
    for( int = 0; < 16; i++) {
        currentpalette[i] = chsv( random8(), 255, random8());
    }
}

// function sets palette of black , white stripes,
// using code.  since palette array of
// sixteen crgb colors, various fill_* functions can used
// set them up.
void setupblackandwhitestripedpalette()
{
    // 'black out' 16 palette entries...
    fill_solid( currentpalette, 16, crgb::black);
    // , set every fourth 1 white.
    currentpalette[0] = crgb::white;
    currentpalette[4] = crgb::white;
    currentpalette[8] = crgb::white;
    currentpalette[12] = crgb::white;
   
}

// function sets palette of purple , 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 );
}


// example shows how set static color palette
// stored in progmem (flash), more
// plentiful ram.  static progmem palette this
// takes 64 bytes of flash.
const tprogmempalette16 myredwhitebluepalette_p progmem =
{
    crgb::red,
    crgb::gray, // 'white' bright compared red , 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
};



// additionl notes on fastled compact palettes:
//
// normally, in computer graphics, palette (or "color lookup table")
// has 256 entries, each containing specific 24-bit rgb color.  can then
// index color palette using simple 8-bit (one byte) value.
// 256-entry color palette takes 768 bytes of ram, on arduino
// quite possibly "too many" bytes.
//
// fastled offer traditional 256-element palettes, setups that
// can afford 768-byte cost in ram.
//
// however, fastled offers compact alternative.  fastled offers
// palettes store 16 distinct entries, can accessed if
// have 256 entries; accomplished interpolating
// between 16 explicit entries create fifteen intermediate palette
// entries between each pair.
//
// example, if set first 2 explicit entries of compact
// palette green (0,255,0) , blue (0,0,255), , retrieved
// first sixteen entries virtual palette (of 256), you'd get
// green, followed smooth gradient green-to-blue, , blue.

i can verify issue. seems there fastled library breaks prototype generation. here's minimal code reproduce problem:
code: [select]
#include <fastled.h>
void setup() {
  foo();
}

void loop() {}

void foo() {}

the issue occurs in arduino ide beta build 25 it's nothing specific arduino web editor.

the issue not occur arduino ide 1.8.5 if can use ide workaround or can add prototypes functions in sketch.

the issue not occur every library. example:
code: [select]
#include <ethernet.h>
void setup() {
  foo();
}

void loop() {}

void foo() {}

will compile.

it breaks prototype generation rather putting prototype in wrong place.

i have reported arduino developers here:
https://github.com/arduino/arduino-preprocessor/issues/3


Arduino Forum > Using Arduino > Programming Questions > Function not declared in scope: used to work and now stopped working (?)


arduino

Comments

Popular posts from this blog

Error compiling for board Arduino/Genuino Uno.

Installation database is corrupt

esp8266 (nodemcu 0.9) client.write très lent ???