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

Correct syntax for callback mode in version 2 #25

Closed
ghost opened this issue Mar 12, 2022 · 4 comments
Closed

Correct syntax for callback mode in version 2 #25

ghost opened this issue Mar 12, 2022 · 4 comments

Comments

@ghost
Copy link

ghost commented Mar 12, 2022

What is the correct syntax to enable the callbacks in version2?

#define  EB_FAST  30    
#define  EB_BETTER_ENC  
#define  EB_HALFSTEP_ENC

#define  EB_DEB  50      
#define  EB_STEP  100    
#define  EB_CLICK  400   
#define  EB_HOLD  1000   

#include <EncButton2.h>
EncButton2<EB_CALLBACK> enc(11, 9, 10);

void myRight() {
  Serial.println("RIGHT_HANDLER");
}
void myLeft() {
  Serial.println("LEFT_HANDLER");
}

void setup() 
{
  Serial.begin(115200);
  while(!Serial);

  enc.attach(RIGHT_HANDLER, myRight);
  enc.attach(LEFT_HANDLER, myLeft);
}
 
void loop() 
{
  enc.tick();
}

This leads to a "crash" of the firmware, the USB port disappear and nothing works.
Instead, using version 1 of the library:

#include <EncButton.h>
EncButton<EB_CALLBACK, 11, 9, 10> enc;

Works fine.
I'm using an Arduino Leonardo-based board.

@GyverLibs
Copy link
Owner

what board are you using? I have stable work EncButton2 + EB_CALLBACK on ATmega328 now

@ghost
Copy link
Author

ghost commented Mar 12, 2022

As said I'm using an Arduino Leonardo compatible board, so it's an ATmega32U4

@GyverLibs
Copy link
Owner

I confirm, there is a problem with 32U4, will try to fix it today

@GyverLibs
Copy link
Owner

Done, v1.21 works correctly!

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

No branches or pull requests

1 participant