ArduinoDuPPaLib icon indicating copy to clipboard operation
ArduinoDuPPaLib copied to clipboard

Launch All state reactions(interrupt ) if a second encoder is not connected

Open fixus971 opened this issue 4 years ago • 4 comments

Hi. There is a bug whereby if an encoder is missing(optional) and I call updateStatus(). In this case All interrupt routines are launched for Encoder is released! Encoder is pushed!
Encoder is long pushed!
Encoder is double pushed! .. all this because this function does not check the error reported by the I2C bus _stat = readEncoderByte(REG_ESTATUS); receive -1 = 255

in lib i don't see a test function to check the connection.

I would add a "connected" boolean during setup or reset or begin

For the rest I am fine .. thanks -Federico

fixus971 avatar Dec 01 '21 20:12 fixus971

Hi, What you mean "missing"? The I2C bus is not a plug & play bus, also if you disconnect and reconnect the board you need to re-configure the register.

Thank you

DuPPadotnet avatar Dec 02 '21 12:12 DuPPadotnet

Hi,

What you mean "missing"?

I mean that the same program works with multiple hardware configurations: 2 or 4 encoders. Where I have only 2 encoders mounted, the software of the absent ones triggers all the interrupts because the internal status read function does not return the value of the state but -1 as an error.. only that it is not managed and continuing the state 255 has all the event bits active.

fixus971 avatar Dec 02 '21 20:12 fixus971

Well in that case you can make the program that when it start check if the encoders are connected or no, and maybe save in some EEPROM if the configuration is 2 or 4. You can use the ID register for checking. Looks more optimized than checking every time the errors.

DuPPadotnet avatar Dec 03 '21 08:12 DuPPadotnet

Hi, I agree to have to do the initial configuration test. I would need a bit of memory in the class. I already use the ID register to hold the previous CVal value .. It would be useful to also have this data in the class: last value read. However, I am of the opinion that an if would be fine for the reception check after reading the status. Put that an encoder gets damaged or comes off .. the CPU will get 100% clogged. Thanks, -Faith

fixus971 avatar Dec 03 '21 15:12 fixus971