Giter VIP home page Giter VIP logo

luni64 / encodertool Goto Github PK

View Code? Open in Web Editor NEW
46.0 6.0 11.0 9.4 MB

The EncoderTool is a library to manage and read out rotary encoders connected either directly or via multiplexers to ARM based boards. Encoder push buttons are supported. Callback functions can be attached to encoder changes and button presses to allow for event driven applications

License: MIT License

C# 5.88% C++ 88.87% C 4.02% Python 1.23%
multiplexed-encoders rotary-encoders callback teensy polling quadrature encoder-button encoder 74165 4067

encodertool's Introduction

EncoderTool  Badge License  Badge Arduino  Badge PlatformIO

Bounce-Free Rotary Encoder Library
+Standard or Multiplexed Wiring
+Push Button Support
+Callback System



Supports



Board Compatibility


  • PJRC Teensy (Teensy-LC, Teensy 3.x, Teensy 4.x, MicroMod)

  • SAMD (SEEED XIAO, Nano33 ...)

  • 8bit Arduino AVR (UNO, Nano, Mega...)

  • ESP32

  • Fallback solution for other boards (using slow digitalRead/Write)


Features

  • Fully bounce free readout without additional hardware

  • Provides hard and cyclic count limits

  • Supports and debounces encoder push buttons

  • Modern callback system for event driven applications

  • Encoders can be connected directly (A / B / Btn connected to pins)

  • Encoder connection using various multiplexers (up to 32 encoders on only 4 control pins)

  • Schematics and Gerbers available for multiplexed encoder boards (Eagle/KiCad).

encodertool's People

Contributors

electronicsarchiver avatar ihatemornings avatar luni64 avatar lunoptics avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

encodertool's Issues

Suggestions/guideline for porting over to other boards?

Hello, excellent library.
The only one that REALLY works. I've tried them all.
Unfortunately, it's Teensy-only. Teensy is Great, but I'd like to port it to SAMD21 and RISC-V, to exploit cheaper boards.
Do you think it's feasible? Where to start, any hint?
Thanks!

MUX with single 74HC165 and 4 Encoders

Hi,

I'm unsuccessfully trying to implement the example of multiplexing encoders with a 74HC165 on an Arduino Micro, but using only one multiplexer (also setting encoderCount to 4).

Turning the first encoder (pins 6 & 7 of the IC) I'm getting the following readings:

Encoder: 0 value: 1385 delta: -1
Encoder: 1 value: 318 delta: 1
Encoder: 0 value: 1386 delta: 1
Encoder: 1 value: 317 delta: -1
Encoder: 0 value: 1385 delta: -1
Encoder: 1 value: 316 delta: -1
Encoder: 0 value: 1384 delta: -1
Encoder: 1 value: 315 delta: -1
Encoder: 0 value: 1383 delta: -1
Encoder: 0 value: 1382 delta: -1
Encoder: 0 value: 1383 delta: 1

Turning any other Encoder has no effect.

All encoders are routed directly to the IC as they are boarded with pull-up resistors.

I also tried with two ICs, because I don't fell 100% shure I can set QH_B = -1 as it is set by default for the switches' IC. Got any luck either.

Am I doing anything really silly?

Thx in advance.

EncoderTool compilation errors under 0.58.3 in Arduino IDE 2.0.3

TTT V1.2.0 generating errors under Arduino IDE 2.0.3. Also EncoderTool V3.1.0 are generating similar errors. Here is the compiler output. Teensy4.1 using PJRC 1.58.3 beta.
`In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:10:13: error: redefinition of 'void panic()'
10 | inline void panic() // could be weak to be overriden by a user error handler?
| ^~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:10:13: note: 'void panic()' previously defined here
10 | inline void panic() // could be weak to be overriden by a user error handler?
| ^~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:100:33: error: redefinition of 'constexpr const size_t stdext::inplace_function_detail::InplaceFunctionDefaultCapacity'
100 | static constexpr size_t InplaceFunctionDefaultCapacity = 32;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:100:33: note: 'constexpr const size_t stdext::inplace_function_detail::InplaceFunctionDefaultCapacity' previously defined here
100 | static constexpr size_t InplaceFunctionDefaultCapacity = 32;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:107:15: error: redefinition of 'union stdext::inplace_function_detail::aligned_storage_helper'
107 | union aligned_storage_helper
| ^~~~~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:107:15: note: previous definition of 'union stdext::inplace_function_detail::aligned_storage_helper'
107 | union aligned_storage_helper
| ^~~~~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:131:16: error: redefinition of default argument for 'unsigned int Align'
131 | struct aligned_storage
| ^~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:130:81: note: original definition appeared here
130 | template <size_t Cap, size_t Align = alignof(aligned_storage_helper)>
| ^
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:149:16: error: redefinition of 'struct stdext::inplace_function_detail::wrapper'
149 | struct wrapper
| ^~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:149:16: note: previous definition of 'struct stdext::inplace_function_detail::wrapper'
149 | struct wrapper
| ^~~~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:155:16: error: redefinition of 'struct stdext::inplace_function_detail::vtable<R, Args>'
155 | struct vtable
| ^~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:155:16: note: previous definition of 'struct stdext::inplace_function_detail::vtable<R, Args>'
155 | struct vtable
| ^~~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:202:9: error: redefinition of 'template<class R, class ... Args> stdext::inplace_function_detail::vtable<R, Args ...> stdext::inplace_function_detail::empty_vtable'
202 | empty_vtable{};
| ^~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:202:9: note: 'template<class R, class ... Args> stdext::inplace_function_detail::vtable<R, Args ...> stdext::inplace_function_detail::empty_vtable<R, Args ...>' previously declared here
202 | empty_vtable{};
| ^~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:205:8: error: redefinition of 'struct stdext::inplace_function_detail::is_valid_inplace_dst<DstCap, DstAlign, SrcCap, SrcAlign>'
205 | struct is_valid_inplace_dst : std::true_type
| ^~~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:205:8: note: previous definition of 'struct stdext::inplace_function_detail::is_valid_inplace_dst<DstCap, DstAlign, SrcCap, SrcAlign>'
205 | struct is_valid_inplace_dst : std::true_type
| ^~~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:220:8: error: redefinition of 'struct stdext::inplace_function_detail::is_invocable_r_impl< , R, F, Args>'
220 | struct is_invocable_r_impl : std::false_type
| ^~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:220:8: note: previous definition of 'struct stdext::inplace_function_detail::is_invocable_r_impl< , R, F, Args>'
220 | struct is_invocable_r_impl : std::false_type
| ^~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:225:8: error: redefinition of 'struct stdext::inplace_function_detail::is_invocable_r_impl<decltype ((declval()((declval)()...), void())), void, F, Args ...>'
225 | struct is_invocable_r_impl<
| ^~~~~~~~~~~~~~~~~~~~
226 | decltype(std::declval()(std::declval()...), void()),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
227 | void,
| ~~~~~
228 | F,
| ~~
229 | Args...> : std::true_type
| ~~~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:225:8: note: previous definition of 'struct stdext::inplace_function_detail::is_invocable_r_impl<decltype ((declval()((declval)()...), void())), void, F, Args ...>'
225 | struct is_invocable_r_impl<
| ^~~~~~~~~~~~~~~~~~~~
226 | decltype(std::declval()(std::declval()...), void()),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
227 | void,
| ~~~~~
228 | F,
| ~~
229 | Args...> : std::true_type
| ~~~~~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:234:8: error: redefinition of 'struct stdext::inplace_function_detail::is_invocable_r_impl<decltype ((declval()((declval)()...), void())), const void, F, Args ...>'
234 | struct is_invocable_r_impl<
| ^~~~~~~~~~~~~~~~~~~~
235 | decltype(std::declval()(std::declval()...), void()),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
236 | const void,
| ~~~~~~~~~~~
237 | F,
| ~~
238 | Args...> : std::true_type
| ~~~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:234:8: note: previous definition of 'struct stdext::inplace_function_detail::is_invocable_r_impl<decltype ((declval()((declval)()...), void())), const void, F, Args ...>'
234 | struct is_invocable_r_impl<
| ^~~~~~~~~~~~~~~~~~~~
235 | decltype(std::declval()(std::declval()...), void()),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
236 | const void,
| ~~~~~~~~~~~
237 | F,
| ~~
238 | Args...> : std::true_type
| ~~~~~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:243:8: error: redefinition of 'struct stdext::inplace_function_detail::is_invocable_r_impl<decltype (accept(declval()((declval)()...))), R, F, Args ...>'
243 | struct is_invocable_r_impl<
| ^~~~~~~~~~~~~~~~~~~~
244 | decltype(accept(std::declval()(std::declval()...))),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
245 | R,
| ~~
246 | F,
| ~~
247 | Args...> : std::true_type
| ~~~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:243:8: note: previous definition of 'struct stdext::inplace_function_detail::is_invocable_r_impl<decltype (accept(declval()((declval)()...))), R, F, Args ...>'
243 | struct is_invocable_r_impl<
| ^~~~~~~~~~~~~~~~~~~~
244 | decltype(accept(std::declval()(std::declval()...))),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
245 | R,
| ~~
246 | F,
| ~~
247 | Args...> : std::true_type
| ~~~~~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:263:7: error: redefinition of default argument for 'unsigned int Capacity'
263 | class inplace_function; // unspecified
| ^~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:261:49: note: original definition appeared here
261 | size_t Capacity = inplace_function_detail::InplaceFunctionDefaultCapacity,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:268:12: error: redefinition of 'struct stdext::inplace_function_detail::is_inplace_function< >'
268 | struct is_inplace_function : std::false_type
| ^~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:268:12: note: previous definition of 'struct stdext::inplace_function_detail::is_inplace_function< >'
268 | struct is_inplace_function : std::false_type
| ^~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:272:12: error: redefinition of 'struct stdext::inplace_function_detail::is_inplace_function<stdext::inplace_function<Sig, Cap, Align> >'
272 | struct is_inplace_function<inplace_function<Sig, Cap, Align>> : std::true_type
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:272:12: note: previous definition of 'struct stdext::inplace_function_detail::is_inplace_function<stdext::inplace_function<Sig, Cap, Align> >'
272 | struct is_inplace_function<inplace_function<Sig, Cap, Align>> : std::true_type
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/TeensyTimerTool/src/types.h:9,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/ITimerChannel.h:3,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/baseTimer.h:5,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/API/oneShotTimer.h:4,
from /home/bruce/Arduino/libraries/TeensyTimerTool/src/TeensyTimerTool.h:3,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:15,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/TeensyTimerTool/src/inplace_function.h:282:7: error: redefinition of 'class stdext::inplace_function<R(Args ...), Capacity, Alignment>'
282 | class inplace_function<R(Args...), Capacity, Alignment>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/bruce/Arduino/libraries/EncoderTool/src/config.h:26,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderBase.h:6,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlexBase.h:3,
from /home/bruce/Arduino/libraries/EncoderTool/src/Multiplexed/EncPlex74165.h:7,
from /home/bruce/Arduino/libraries/EncoderTool/src/EncoderTool.h:8,
from /home/bruce/Arduino/ELS_IDE2/ELS.h:14,
from /home/bruce/Arduino/ELS_IDE2/ELS_IDE2.ino:1:
/home/bruce/Arduino/libraries/EncoderTool/src/inplace_function.h:282:7: note: previous definition of 'class stdext::inplace_function<R(Args ...), Capacity, Alignment>'
282 | class inplace_function<R(Args...), Capacity, Alignment>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

exit status 1

Compilation error: exit status 1`

I do have a customer that I need to support. I am setting up a github project and wish for the customer to use IDE2, but the project won't compile now. It was 100% functional under IDE1.8.19 and the countertype branch.

Library impossible to include from two cpp files

See topic.

Due to the Encoder.h class inlining the implementation, two files using the Encoder after doig #include <EncoderTool.h> will result in a double definition error.

Minimal reproduction with PlatformIO:
platformio.ini

[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
lib_deps = https://github.com/luni64/EncoderTool.git

with src/main.cpp

#include <Arduino.h>
#include <EncoderTool.h>

using namespace EncoderTool;
Encoder enc1;
extern Encoder enc2;

void setup() {
    enc1.begin(1, 2);
    enc2.begin(3, 4);
}

void loop() {}

and src/helper.cpp

#include <Arduino.h>
#include <EncoderTool.h>

using namespace EncoderTool;
Encoder enc2;

void some_func() { }

leads to

.pio\build\teensy41\src\main.cpp.o: In function `EncoderTool::Encoder::Encoder()':
main.cpp:(.text._ZN11EncoderTool7EncoderC2Ev+0x0): multiple definition of `EncoderTool::Encoder::Encoder()'
.pio\build\teensy41\src\helper.cpp.o:helper.cpp:(.text._ZN11EncoderTool7EncoderC2Ev+0x0): first defined here
c:/users/max/.platformio/packages/[email protected]/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions        
.pio\build\teensy41\src\main.cpp.o: In function `EncoderTool::Encoder::Encoder()':
main.cpp:(.text._ZN11EncoderTool7EncoderC2Ev+0x0): multiple definition of `EncoderTool::Encoder::Encoder()'
.pio\build\teensy41\src\helper.cpp.o:helper.cpp:(.text._ZN11EncoderTool7EncoderC2Ev+0x0): first defined here
collect2.exe: error: ld returned 1 exit status

Help adapting Encoder lib sketch to EncoderTool lib

Hi @luni64,

I am a new coder and just starting to learn how to implement a rotary encoder with a button and trying to adapt the encoderTool library on this sketch:

#include <Encoder.h>

Encoder enc_one(12, 11);
int value; 

long enc_one_previous  = -999;
byte button_previous; 

void setup() {
  pinMode(2, INPUT_PULLUP); 
}



void loop() {
  value = enc_one.read();
  if(value > 127) {    enc_one.write(127);   }
  else if(value < 0) {    enc_one.write(0);  } 
  
  value = constrain(value, 0, 127);
  if (value != enc_one_previous) {    enc_one_previous = value;    usbMIDI.sendControlChange(1, value, 1);  }
  
  value = digitalRead(2); 
  if(value != button_previous) {    button_previous = value;    usbMIDI.sendControlChange(2, (1 - value) * 127, 1);    delay(3);  }
}

Using the examples in the EncoderTool library I came up with this sketch which is close but I still haven't gotten the button logic correct:

#include "EncoderTool.h"
using namespace EncoderTool;

PolledEncoder encoder; // Polling encoder, please call corresponding tick() functions as often as possible, e.g. in loop

const int pinA = 12; //encoder pin A
const int pinB = 11; // encoder pin B
const int pinBtn = 2; // encoder button pin

int value; 

long encoder_previous  = -999;
byte button_previous; 



void setup() {
  
  encoder.begin(pinA, pinB, pinBtn);
  encoder.setValue(0); // set the counter to a position
  encoder.setLimits(1, 127); // limits the count range to [1..127] add "true" arg e.g. enc.setLimits(1, 127, true) cyclic count range from [1...127] 
  
}

void loop() {

  encoder.tick();
  
  value = encoder.getValue();
  if (value != encoder_previous) {    encoder_previous = value;    usbMIDI.sendControlChange(1, value, 1);  }
  
  value = encoder.buttonChanged();
  if(value != button_previous) {    button_previous = value;    usbMIDI.sendControlChange(2, (1 - value) * 127, 1);}
  
  
}

In the 1st encoder sketch, it works as expected(Button is pressed = 127 and when released = 0).
How do I implement this logic using the EncoderTool library?

In the EncoderTool version, the values are reversed(button pressed = 0 and when released =127) and duplicated for each button state (pressed and released).

Any help is greatly appreciated. Thank you!

Some schematic explanation needed

Hi!

Thanks for such a nice project!

I want to use a Raspberry pi Pico board as a dedicated device for encoders only. The board has enough pins to use 8 encoders connected directly to it, so I've chosen the direct mux option. The encoders I wanna use are EC11 with 2 encoders pins, one switch and the ground.

Here is the problem: this schematic uses some other type of encoders: https://github.com/luni64/EncoderTool/blob/master/Resources/Extras/Boards/MATRIX/documentation/schematic.jpg

so what is the wiring for the EC11 type? Or is it EC11, but the A1 pin and A2 pin of an encoder is actually the same pin ?
Thanks!

Issue with TeensyLC

Hi luni64,

I have a strange issue with EncoderTool on TeensyLC.

Here's the MWE:

#include <EncoderTool.h>

using namespace EncoderTool;
PolledEncoder enc;

void setup() {
  Serial.begin(9600);
  enc.begin(5, 6, 4, CountMode::half, INPUT_PULLUP);
}

void loop() {
  enc.tick();
  if(enc.valueChanged())
    Serial.println(enc.getValue());
}

On Teensy 3.2 this works perfectly fine: each detent will increment/decrement by 1. On TeensyLC, however, it will keep incrementing like crazy (without turning the encoder) with each iteration of loop() - but only for every other detent. I'm using this encoder. Is there anything that comes to mind?

Cheers!

Ambiguous pin assignment comments in examples

Hi,

I found really confusing these comments in the multiplexed examples.
Is there any reason why QH_A is related to the QH pin of the B register and not the A?

Multiplex 74HC165 tutorial

constexpr unsigned QH_A = 0;   // output pin QH of shift register B
constexpr unsigned QH_B = 1;   // output pin QH of shift register A

Multiplex Callbacks tutorial

constexpr unsigned QH_A = 2;   // output pin QH of shift register B
constexpr unsigned QH_B = 3;   // output pin QH of shift register A

Any way to output debug info?

I've been trying to get EncorderTool to work for hours now. I'm trying to use it with two SN74HC165N shift registers and a few Burns PEC16 mechanical quadrature encoders (no detent). I'm using a Teensy 3.2. I've tried every possible wiring combination and code but nothing seems to work. I made sure to follow the multiplexed 74165 example as well. I guess next step is to validate if the shift registers are even working. Is there any debug info I can get from EncoderTool? Maybe like raw data or something so I can see if it's reading anything from the shift registers?

incompatibility with LCD_I2C

I'm having an issue with an incompatibility with the LCD_I2C library I can't quite put my finger on and would appreciate any insight if anyone has any....

It issue is that when the EncoderTool library is in use, the lcd.printf(...) method stops doing anything. lcd.print(...) still works. It does not interrupt code execution, it just has no impact. Take out the EncoderTool lib and it works again.

Using https://github.com/blackhack/LCD_I2C.
Hardware is teensy 3.6

Sample code that exhibits the issue:

#include <Arduino.h>
#define ENCODER_OPTIMIZE_INTERRUPTS

#include <EncoderTool.h>
#include <LCD_I2C.h>

using namespace EncoderTool;
Encoder enc1;
LCD_I2C lcd(0x27,40,2);
long lastPos;
int i = 0;

void setup() {
  lcd.begin();
  lcd.backlight();
  lcd.clear();
  enc1.begin(26, 25);
}

void loop() {
  lcd.setCursor(0, 0);
  lcd.print(i % 10);
  int32_t wheelin = enc1.getValue();
  if (wheelin != lastPos) {
    lcd.setCursor(0, 1);
    char l[50];
    sprintf(l, "%ld", wheelin);
    lcd.print(l);  // THIS WORKS

    lcd.setCursor(10, 1);
    lcd.printf("%d", wheelin); // THIS DOES NOT
    lastPos = wheelin;
  }
  i++;
}

Any thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.