[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 

is it possible to use also use the encoder in a task being executed? RSS feed
Forum Index » tcMenu Arduinio library
Author Message
markjhatch


Joined: Jun 8, 2020
Messages: 4
Offline
Thank you for making this library available.

I use the tcMenu to initiated a function that takes character coming into thru a digital pin and displays them on the screen. I create a buffer of "x" characters and had planned on using the rotary encoder to move up and down in this buffer displaying the different characters in the buffer.

Several questions. Please feel free to tell me where I should be rtfm-ing

1. Is this possible using just one encoder? While in the function, I want to process the encoder. When I exit this callback function, I want the menu to re-engage and take over the encoder input.

2. The plan would be to use the encoder switch to exit from this subtask to get back to the menu system. Is that button event something I can capture in the processing function?

3. Aside from exiting the callback function, should I be executing any tcMenu function prior to exit?

4. Can I use the same "lcd" variable for displaying the results as used by the menu system?

Thanks you for any hints pointers to investigate.
markjhatch


Joined: Jun 8, 2020
Messages: 4
Offline
Believe I found the answer to #4 with the renderer.takeOverDisplay(myDisplayCallback);

Still searching for the others. smilie

Mark
davetcc


Joined: Jan 19, 2019
Messages: 534
Offline
Hi Mark,

I assume by this we are talking about taking over the display so that you can leave the menu and render your own data.

In that case I'll discuss this in terms of the rendering function callback:

1. Is this possible using just one encoder? While in the function, I want to process the encoder. When I exit this callback function, I want the menu to re-engage and take over the encoder input.


During the take over display rendering function you are passed an integer as the first parameter and a boolean as the second, this is the current value of the rotary encoder and if it is pressed, during the setup of taking over the display, you can change the precision of the encoder to represent a different range.

2. The plan would be to use the encoder switch to exit from this subtask to get back to the menu system. Is that button event something I can capture in the processing function?


As per above the button press is captured by the second boolean parameter in the take over display call back.

3. Aside from exiting the callback function, should I be executing any tcMenu function prior to exit?


The take over display callback is actually a task from taskManager, it's repeatedly called so you should be rendering once then letting the function exit. When you're ready to give back the display to the menu, call renderer.giveBackDisplay()

4. Can I use the same "lcd" variable for displaying the results as used by the menu system?


Yes, but only in the render callback, never use it in any other task or when the display has not been taken over.

See the takeOverDisplay example that ships with TcMenu, that does most of what you're looking to do here.

Thanks,
Dave





markjhatch


Joined: Jun 8, 2020
Messages: 4
Offline
Dave,

Thanks for the very quick reply!

Two clarification and I will go dig some more.

So the task that is executed is long running (it is actually processing and displaying morse code that has been translated to characters by my rig and the rotary allows backward forward movement in the time dimension). So I need to be diligent in reading the serial line and of course displaying the received code.

1. It looks like I could schedule a task to read from the serial line every xxx ms.
2. Seems like it would not be efficient to take over the display on every character that I receive. Is that the best practice or would a different approach be advisable?

Thanks again!

Mark
davetcc


Joined: Jan 19, 2019
Messages: 534
Offline
1. It looks like I could schedule a task to read from the serial line every xxx ms.


Yes, that would probably be quite straightforward to achieve, there's lots of examples in IoAbstraction of creating tasks. Just make sure that you don't do any blocking IO in that call, IE call available() before read().


2. Seems like it would not be efficient to take over the display on every character that I receive. Is that the best practice or would a different approach be advisable?


It's up to you, many take over the display at startup and only give the menu control when a "menu" button is pressed, to help with this there's also a reset timer, that can be set up to call you back when the menu is idle for a given amount of time (defaulting to about 30 seconds).
markjhatch


Joined: Jun 8, 2020
Messages: 4
Offline
Dave,

Thank you again. Now for the fun part. smilie

Mark
patebeng


Joined: Sep 17, 2021
Messages: 5
Offline
removed
 
Forum Index » tcMenu Arduinio library
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer

This site uses cookies to analyse traffic, serve ads by Google AdSense (non-personalized in EEA/UK), and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.