Replies: 1 comment 1 reply
-
You can read out the current button state with #include "EncoderTool.h"
using namespace EncoderTool;
PolledEncoder enc;
void setup()
{
enc.begin(1, 2, 3); // encoder A= pin1, B= pin2, button = pin3
}
void loop()
{
if(enc.buttonChanged())
{
Serial.println(enc.getButton());
}
enc.tick();
}
Actually there is no hard limit. You need to make sure that each encoder is queried often enough (about 5kHz is good). Lets assume you have 100 encoders with buttons, you need to read in 3 pins per encoder and anaylze them. If we assume it takes 5µs per encoder we end up with 500µs for all encoders which gives 1/500µs = 2kHz sampling rate which is quite low. So, ultimately you are limited by the efficiency of the code and the speed of the processor.
Depends on what you want to do. Using callbacks is often more convenient since you can build a "event driven" application.
I don't quite understand what you want to show with the code? Can you elaborate on that? |
Beta Was this translation helpful? Give feedback.
-
Hi,
Ive been building the shift register encoder circuit based on 3x 74hc165 to read encoders and 8 buttons.
Ive managed to get the encoder working very nicely on full mode (96 ppr out of a 24ppr rot enc). However, Im struggling to see how I get the buttons read in. I see in one of the libs there's attachButtonCallBack but I have no idea how I should call that.
Also, Ive seen in the documentation that you can only use up to 32 encoders here. Im unsure why that is, wouldnt the shift registers just keep getting clocked for the length on the encoderCount loop? Is there really only a limit of chaining 4 banks togther? On another project ive chained 9 shift regs (AHCT595) together and clocked them at 17Mhz and theyve been fine taking 4.4uS to write to the 72 pins.
If it is something like its writing to a 32bit variable, could that be made a 64 bit variable? Or can i just use another set of pins and have something like:
I gather that callbacks is preferable over polliing. I will be incorporating this in to code that writes to i2c oleds as well.
Heres my slightly modified version of the mplexCallbacks code. Any suggestions of where to go next welcome. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions