I have a little problem with the GFButton library, with the advanced configuration of the button it keeps telling me that 'button_on_release' is not declared and I don't know what it could be, here I leave the complete code
#include <Arduino.h>
#include "GFButton.h"
//Estas variables son para detectar el estado del boton
GFButton secP = GFButton(2);
GFButton secM = GFButton(3);
int sec = 1;
int oPins[]= {4, 5, 6, 7, 8, 9, 10, 11};
void setup()
{
secP.setReleaseHandler(button_on_release);
secM.setReleaseHandler(button_on_release);
Serial.begin(9600);
//esta funcion inicializa de forma corta todos los pines del array como output
for(int i=0; i<8; i++){
pinMode(oPins[i], OUTPUT);
}
}
void loop()
{
//este if detecta cual boton se apreta y añade o sustrae segun el caso
/*if(secP.wasPressed()){
if(sec==4){
sec=1;
}else{
sec++;
}
}else if(secM.wasPressed()){
if(sec==1){
sec=4;
}else{
sec--;
}
}*/
secP.process();
secM.process();
if(sec==1){
int i = 0, j=0;
for ( i = 0; i < 256; i++)
{
for ( j = 0; j < 8; j++)
{
if ( ( (i >> j) & 1 ) == 1 )
digitalWrite(oPins[j], HIGH);
else digitalWrite(oPins[j], LOW);
}
delay(250);
}
}
}
void button_on_release(GFButton & secP)
{
}
If they see things that they do not understand such as the if(secP.wasPressed()), it is part of a test nothing more, the important thing is that it throws me that error
Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.
I installed the GFButton library through the library manager and attempted to verify your code. The code compiled with no errors, but a few warnings. My system is Win 10, IDE 1.8.12.
I suggest that you try to delete and re-install the library.
src\main.cpp: In function 'void setup()':
src\main.cpp:15:26: error: 'button_on_releaseP' was not declared in this scope
secP.setReleaseHandler(button_on_releaseP);
^~~~~~~~~~~~~~~~~~
src\main.cpp:15:26: note: suggested alternative: 'buttonmodes'
secP.setReleaseHandler(button_on_releaseP);
^~~~~~~~~~~~~~~~~~
buttonmodes
src\main.cpp:16:26: error: 'button_on_releaseM' was not declared in this scope
secM.setReleaseHandler(button_on_releaseM);
^~~~~~~~~~~~~~~~~~
src\main.cpp:16:26: note: suggested alternative: 'buttonmodes'
secM.setReleaseHandler(button_on_releaseM);
^~~~~~~~~~~~~~~~~~
buttonmodes
*** [.pio\build\nanoatmega328\src\main.cpp.o] Error 1
I don't know for sure, but I wonder if this is one of those cases where you need the function prototype to be declared before you can reference the function.
The Arduino IDE automatically defines function prototypes. Perhaps your environment requires them.