Register / Login  |  Desktop view  |  Jump to bottom of page

tcMenu Arduinio library » Encoder - 40 detents, 20 pulses.

Author: ScubaSteve
22/05/2021 01:48:36
I suspect you know where this is headed, Dave..

Found a package of 40 detent/20 pulse encoders in a bin of randomness ... obviously every other detent is unrecognized. Is there an option in tcMenu that I missed?

Thanks!

Steve

Author: davetcc
22/05/2021 04:13:19
Yes there is a recently closed pull request in IoAbstraction on this, I’ll make sure it’s documented properly but take a look at the quarter cycle pull request or the IoAbstraction front page.

Answering on my phone at the moment but will reply again later.

Author: davetcc
22/05/2021 04:30:41
For now just hack the extra parameter on the end of the encoder setup in your project _menu.cpp

I’ll change and release the input plugin before the 2.1 library goes out tomorrow.

Author: davetcc
22/05/2021 08:57:57
Take a look at https://www.thecoderscorner.com/products/arduino-libraries/io-abstraction/switches-rotary-encoder-documentation/ where it has a section on rotary encoders. In summary there is a new optional parameter at the end of the set up method below:

void setupRotaryEncoderWithInterrupt(pinA, pinB, myCallback, QUARTER_CYCLE);


For now, go into your _menu.cpp file, and add that extra parameter. We've already raised an issue to add this as a checkbox in the rotary encoder plugin in the next release.

You'll have to be on a very recent IoAbstraction for this to work, as it's only just been kindly submitted and tested by ddd999

Author: ScubaSteve
22/05/2021 10:39:31
Thank you, Dave! I'm out-of-pocket most of today -- will report back tomorrow morning!

Author: ScubaSteve
22/05/2021 11:33:50
Yikes. I updated to 2.1 Beta via the Arduino IDE. My code compiled, but is too big for the Arduino. I think it might be time to look at ESP32.. This will take a while.

Author: davetcc
23/05/2021 06:21:07
 
My code compiled, but is too big for the Arduino.


Are you using an AVR with 32K FLASH?

If so, you can select "Uno" mode in the LCD driver settings and save about 8K of flash. The old size for the dfRobot sketch was 22K and the new size with Uno ticked is around 24K.

If you're using an OLED, the SSD1306Ascii driver also fits well, almost unchanged to before. We have an example with two custom fonts and it uses about 25K FLASH.

[Thumb - lcd-uno-mode.jpg]
Filename lcd-uno-mode.jpg
Description No description given
Filesize 36 Kbytes
Downloaded 54069 time(s)
[Disk] Download


Author: ScubaSteve
23/05/2021 14:10:36
I already had that option. I'm using an Uno. This project is just quickly outgrowing the platform.

Author: ScubaSteve
23/05/2021 16:08:46
Trying to get an ESP32 working with a simple menu (only) and having compilation errors. I've upgraded to the latest Designer, tcMenu 2.1.0. Familiar with using this under Arduino, first time with ESP32.

I get the following errors at compilation:

sketch/tcMenuLiquidCrystal.cpp: In member function 'virtual void LiquidCrystalRenderer::drawMenuItem(tcgfx::GridPositionRowCacheEntry*, tcgfx::Coord, tcgfx::Coord, bool)':
tcMenuLiquidCrystal.cpp:119:46: error: no matching function for call to 'min(int, uint8_t& smilie'
buffer[min(areaSize.x + 1, bufferSize)] = 0;
^
In file included from /Users/steve/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/include/c++/5.2.0/algorithm:62:0,
from /Users/steve/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/cores/esp32/Arduino.h:142,
from /Users/steve/Documents/Arduino/libraries/IoAbstraction/src/PlatformDetermination.h:33,
from /Users/steve/Documents/Arduino/libraries/IoAbstraction/src/IoAbstraction.h:17,
from /Users/steve/Documents/Arduino/libraries/tcMenu/src/tcMenu.h:9,
from sketch/tcMenuLiquidCrystal.h:20,
from sketch/tcMenuLiquidCrystal.cpp:15:
/Users/steve/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_algo.h:3451:5: note: candidate: template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)
min(initializer_list<_Tp> __l, _Compare __comp)
^
/Users/steve/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_algo.h:3451:5: note: template argument deduction/substitution failed:
sketch/tcMenuLiquidCrystal.cpp:119:46: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
buffer[min(areaSize.x + 1, bufferSize)] = 0;
^
In file included from /Users/steve/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/include/c++/5.2.0/algorithm:62:0,
from /Users/steve/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/cores/esp32/Arduino.h:142,
from /Users/steve/Documents/Arduino/libraries/IoAbstraction/src/PlatformDetermination.h:33,
from /Users/steve/Documents/Arduino/libraries/IoAbstraction/src/IoAbstraction.h:17,
from /Users/steve/Documents/Arduino/libraries/tcMenu/src/tcMenu.h:9,
from sketch/tcMenuLiquidCrystal.h:20,
from sketch/tcMenuLiquidCrystal.cpp:15:
/Users/steve/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_algo.h:3445:5: note: candidate: template<class _Tp> _Tp std::min(std::initializer_list<_Tp> smilie
min(initializer_list<_Tp> __l)
^
/Users/steve/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_algo.h:3445:5: note: template argument deduction/substitution failed:
sketch/tcMenuLiquidCrystal.cpp:119:46: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
buffer[min(areaSize.x + 1, bufferSize)] = 0;
^
In file included from /Users/steve/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/include/c++/5.2.0/algorithm:61:0,
from /Users/steve/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/cores/esp32/Arduino.h:142,
from /Users/steve/Documents/Arduino/libraries/IoAbstraction/src/PlatformDetermination.h:33,
from /Users/steve/Documents/Arduino/libraries/IoAbstraction/src/IoAbstraction.h:17,
from /Users/steve/Documents/Arduino/libraries/tcMenu/src/tcMenu.h:9,
from sketch/tcMenuLiquidCrystal.h:20,
from sketch/tcMenuLiquidCrystal.cpp:15:
/Users/steve/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
/Users/steve/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_algobase.h:243:5: note: template argument deduction/substitution failed:
sketch/tcMenuLiquidCrystal.cpp:119:46: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'uint8_t {aka unsigned char}')
buffer[min(areaSize.x + 1, bufferSize)] = 0;
^
In file included from /Users/steve/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/include/c++/5.2.0/algorithm:61:0,
from /Users/steve/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/cores/esp32/Arduino.h:142,
from /Users/steve/Documents/Arduino/libraries/IoAbstraction/src/PlatformDetermination.h:33,
from /Users/steve/Documents/Arduino/libraries/IoAbstraction/src/IoAbstraction.h:17,
from /Users/steve/Documents/Arduino/libraries/tcMenu/src/tcMenu.h:9,
from sketch/tcMenuLiquidCrystal.h:20,
from sketch/tcMenuLiquidCrystal.cpp:15:
/Users/steve/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp& smilie
min(const _Tp& __a, const _Tp& __b)
^
/Users/steve/Library/Arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-97-gc752ad5-5.2.0/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_algobase.h:195:5: note: template argument deduction/substitution failed:
sketch/tcMenuLiquidCrystal.cpp:119:46: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'uint8_t {aka unsigned char}')
buffer[min(areaSize.x + 1, bufferSize)] = 0;
^
exit status 1
no matching function for call to 'min(int, uint8_t& smilie'

Author: davetcc
23/05/2021 17:39:32
Ah, looks like there's an oversight for ESP boards in the liquid crystal renderer, not many use LCDs on ESP boards.

If you open LiquidCrystalRenderer.cpp and change line 119 to look as follows:

buffer[min(uint8_t(areaSize.x + 1), bufferSize)] = 0;


I think that should fix it. I'll include this patch in the 2.1.3 release, which will be tomorrow at this point. It will also include quarter-turn encoders. In fact I'll create a simple menu with LCD on my ESP32 board with my I2C LCD display. Normally we test ESP boards with OLEDs and TFTs.

Author: davetcc
23/05/2021 17:41:43
Thanks for letting us know about it too, so we can fix it.

Author: ScubaSteve
23/05/2021 21:51:23
Glad to help!

It's compiling now, although I'm not seeing life signs from the display (removed from the Arduino, so I know it works and I know the I2C address). I've gone through various iterations for pin layout. I'm assuming you're expecting SCL on GPIO22, SDA on 21?

Author: ScubaSteve
23/05/2021 22:07:12
I've got it functioning using the "Uno" (memory conserving) LCD feature. Selecting the "Full" library results in line 0 showing full blocks in each character position, with line 1 entirely blank.

I'll stick with the Uno option for now, and will try and migrate to a 1306 over time.

Author: davetcc
24/05/2021 06:45:08
 
I'm assuming you're expecting SCL on GPIO22, SDA on 21?


You have to call begin yourself providing the right pins before calling setupMenu(). Take a look at the ESP32 code below, begin takes two parameters that can be defaulted if you use the hardware mapped pins.

We do test ESP32 with an LCD for our LiquidCrystalIO library, but we've never really built a menu with one as it doesn't seem that common. However, I'll build one today and ensure everything is good.

https://github.com/espressif/arduino-esp32/blob/a1d8b959b05e3fb1391883ce6f9f2ed87af7da0f/libraries/Wire/src/Wire.h#L74

- slight edit to include url

Author: davetcc
24/05/2021 06:53:56
 
I've got it functioning using the "Uno" (memory conserving) LCD feature. Selecting the "Full" library results in line 0 showing full blocks in each character position, with line 1 entirely blank.


I imagine the board is running out of memory, to be honest, and the sketch crashing. You can't even enable serial to debug the menu on an Uno, as you risk overflowing the available memory.

We really don't recommend full mode on Uno because it needs a bit more RAM and FLASH. It's designed for MEGA2560 and upwards basically.




Register / Login  |  Desktop view  |  Jump to top of page