error: invalid conversion from 'void (*)(boolean) {aka void (*)(bool)}' to 'void

I have this little understanding problem. I'm not a programer at all, so please, talk to me like if i was a kid.

I have this piece of code in a script :

typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = {Fired, fireblu, fire, blur, Matrix, Colorful, ease, ripple,  juggle, sinelon, twinkle, wave, balls, Drip, rainbow};
uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current

When trying to compile it, it returns the following error message :

pushbuttonmic:1748:145: error: invalid conversion from 'void (*)(boolean) {aka void (*)(bool)}' to 'void (*)()' [-fpermissive]

 SimplePatternList gPatterns = {Fired, fireblu, fire, blur, Matrix, Colorful, ease, ripple,  juggle, sinelon, twinkle, wave, balls, Drip, rainbow};

I'm quite sure this is only a syntaxic problem, so please, can you help ?

Try this instead:

typedef void (*SimplePatternList)();
SimplePatternList gPatterns[] = {Fired, fireblu, fire, blur, Matrix, Colorful, ease, ripple,  juggle, sinelon, twinkle, wave, balls, Drip, rainbow};
uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current

Depending on your IDE version, you may also need to provide your own function prototypes.

gfvalvo:
Try this instead:

typedef void (*SimplePatternList)();

SimplePatternList gPatterns = {Fired, fireblu, fire, blur, Matrix, Colorful, ease, ripple,  juggle, sinelon, twinkle, wave, balls, Drip, rainbow};
uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current




Depending on your IDE version, you may also need to provide your own function prototypes.

IDE Version is latest 189, as well as included libraries.

I’m using a LOLIN (Wemos) D1 R2 & Mini board.

All code is provided now in my message as a zip. Thank for trying to help, but it returned the following error now.

Stereovupushbuton:2265:88: error: invalid conversion from 'void (*)(boolean) {aka void (*)(bool)}' to 'SimplePatternList {aka void (*)()}' [-fpermissive]

SimplePatternList gPatterns[] = {fire, fireblu, juggle, ripple, sinelon, twinkle, balls};

                                                                                       ^

Stereovupushbuton:2283:37: error: conflicting declaration 'typedef void (* SimplePatternList [])()'

typedef void (*SimplePatternList[])();

                                    ^

Stereovupushbuton:2264:16: error: 'SimplePatternList' has a previous declaration as 'typedef void (* SimplePatternList)()'

typedef void (*SimplePatternList)();

               ^

Stereovupushbuton:2284:103: error: scalar object 'qPatterns' requires one element in initializer

SimplePatternList qPatterns = {vu, vu1, vu3, Vu4, vu2, vu10, Vu6, vu5, vu7, vu14, vu8, vu11, vu12, vu9};

                                                                                                      ^

exit status 1
invalid conversion from 'void (*)(boolean) {aka void (*)(bool)}' to 'SimplePatternList {aka void (*)()}' [-fpermissive]

Stereovupushbuton.zip (355 KB)

The pointers in your list are to functions that take no arguments. Apparently at least one of the functions that you are trying to put in the list takes a boolean argument. Either they ALL have to take a boolean argument and you should change the pointer declaration or NONE of them can take a boolean argument and you should remove the argument from the one or more that do.

johnwasser:
The pointers in your list are to functions that take no arguments. Apparently at least one of the functions that you are trying to put in the list takes a boolean argument. Either they ALL have to take a boolean argument and you should change the pointer declaration or NONE of them can take a boolean argument and you should remove the argument from the one or more that do.

I'm sorry, but as i said, i'm not a programer at all. I can fairly debug some simple stuff, but i'm way overdrived in this case :slight_smile:

How did you manage to make a program that large and not catch this problem sooner?

As @johnwasser pointed out, you lied to the compiler here:

typedef void (*SimplePatternList)();
SimplePatternList gPatterns[] = {Fired, fireblu, fire, blur, Matrix, Colorful, ease, ripple,  juggle, sinelon, twinkle, wave, balls, Drip, rainbow}

But, this is your prototype for ‘ripple’:

void ripple(boolean show_background);

lothar2048:
I’m sorry, but as i said, i’m not a programer at all. I can fairly debug some simple stuff, but i’m way overdrived in this case :slight_smile:

So where did you get the sketch from?

johnwasser:
So where did you get the sketch from?

From a guy on internet that did it and provide it as is.

I'm just able to modify some parameters, modify very simple things, copy paste some working code and understand what it's doing, but here, i'm fully overdrived. This is real programation stuff.

gfvalvo:
As @johnwasser pointed out, you lied to the compiler here:

typedef void (*SimplePatternList)();

SimplePatternList gPatterns = {Fired, fireblu, fire, blur, Matrix, Colorful, ease, ripple,  juggle, sinelon, twinkle, wave, balls, Drip, rainbow}




But, this is your prototype for 'ripple':


void ripple(boolean show_background);

Sorry, but i don't understand a word of what you said. As i said, i'm not a programmer, so if you are trying to get any programming references from me, it won't work.

I've taken this code from someone who shared it over internet, and was dedicated to another chip.

My knowledge is very limited in understanding C programming. I just understand what it does, can modify very little stuff around, and sometimes can debug it by my own. But here, it's way over my competences.

lothar2048:
From a guy on internet that did it and provide it as is.

... was dedicated to another chip.

My knowledge is very limited in understanding C programming. I just understand what it does, can modify very little stuff around, and sometimes can debug it by my own. But here, it's way over my competences.

Given the above, I don’t have a great deal of hope for the success of this endeavor. There may be an easy answer, or it may be a long, hard slog. Can’t tell without digging into the code. But, that’s a lot of code for someone to dig through as a volunteer. From a quick look, I can only suggest removing the ‘ripple’ function from the gPatterns array and getting rid of the redundant typedef.

If that doesn’t work, It might be better for you to start simple and grow the project using some of this code as building blocks.