[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 

Questions about Large Numbers and Margins RSS feed
Forum Index » tcMenu Arduinio library
Author Message
milesg


Joined: Oct 8, 2021
Messages: 17
Offline
Hello all!

I just ran into a couple of concerns and I was wondering if anyone knows a workaround or further options that I haven't been able to find in the documentation/forums:

I just setup some "Very large numeric values" in the tcMenu designer, but I'm noticing that they don't function the same way that normal int/float items work.

Primarily, I see that if I set them to "0", they aren't displayed in the menu at all. Once I set them to anything larger, I can see the value in the menu items list as normal. Is there a way to display "0" values?

Also, I would like to set a limited range of values that these items can take (similar to int/float items,) Example: 0-1,000,000. However, if I set the item to have 7 digits, there's no way to limit the user from inputting a number larger than 1 on the left-most digit. In this case, I'm actually okay setting the limit to 6 digits (999,999 is close enough), but it would be nice to have such a feature if possible.

When working with these items, just using a setCurrentValue(int) would make this much more intuitive. I'm not sure why we have to use strings, but it works, so no big deal.

----

Regarding margins, I have found some properties while digging through the source code regarding position of menu values, but I can't seem to get anything to work by changing these values. What I'd like to do, is push the menu item values a pixel or 2 off the right edge of the screen (ili9341 in this case) so that they have a little breathing room. This is just an aesthetic preference, but some characters with long vertical lines (M, I, etc.) on right side do appear to be slightly cut off/crowded at the moment.

As always any insight and advice is greatly appreciated.

Thank you so much!

davetcc


Joined: Jan 19, 2019
Messages: 636
Offline
Hi there for the first question it may be that nobody has yet tried to display zero in one of those. Let me try it myself and see what happens.

For the limit, if you need to prevent values within the range then you could handle this using a menu manager observer. It allows you to prevent commit IIRC. See:

http://thecoderscorner.com/products/arduino-libraries/tc-menu/menumanager-and-iteration/#listening-for-changes-on-menu-manager

In terms of drawing you can set your own margins at many levels. The code put in the theme file allows you to modify this behaviour and theme files are not overwritten so safe to edit. See:

http://thecoderscorner.com/products/arduino-libraries/tc-menu/themes/rendering-with-themes-icons-grids/
milesg


Joined: Oct 8, 2021
Messages: 17
Offline
Thank you Dave,

I'll look deeper into the observer functions, but at a glance it looks like it might be more trouble than it's worth for my use case.

I increased the itemPadding in the theme file and that seems to help for a quick fix (it increases the padding all around, not just on the right side, but that's fine). I noticed that values which contain the number 1 seem to be pushed further to the right. Must be some quirk of the Adafruit font.

For reference I've attached a photo showing this alignment quirk as well as the 0 value items showing blank (Minimum and Maximum Position items are both Large Number items.)

Thanks again!

EDIT: Whoops, the darn thing shows up in Australia mode on the forums. If you download it, you'll get a clearer view and it should be right-side-up.
[Thumb - IMG_20220803_124332483_HDR.jpg]
 Filename IMG_20220803_124332483_HDR.jpg [Disk] Download
 Description No description given
 Filesize 1008 Kbytes
 Downloaded:  102 time(s)

davetcc


Joined: Jan 19, 2019
Messages: 636
Offline


I increased the itemPadding in the theme file and that seems to help for a quick fix (it increases the padding all around, not just on the right side, but that's fine). I noticed that values which contain the number 1 seem to be pushed further to the right. Must be some quirk of the Adafruit font.


For the incorrect sizing, it may be worth creating a test sketch with these characters in and seeing if it is the font, or a problem in tcMenu. Although we are just getting the text bounds direct from the library.

If you have a look at the menu padding object though, it can be configured either with equal values for each side, or a value for each side:

MenuPadding(int top_, int right_, int bottom_, int left_) {
            top = top_;
            bottom = bottom_;
            right = right_;
            left = left_;
        }


This should allow you to set each side separately.

For reference I've attached a photo showing this alignment quirk as well as the 0 value items showing blank (Minimum and Maximum Position items are both Large Number items.)


Yep, wrong way around smilie I'll take a look at these two later, and raise an issue if needed against TcMenuLib.

milesg


Joined: Oct 8, 2021
Messages: 17
Offline
Ah! excellent, I set the right margin to be a few more pixels than the other sides and now things are looking real sharp (The extra pixel shift of the number 1 is barely noticeable when everything is 6 pixels from the edge already) Thank you!

Regarding the empty lines for 0 values on large number items, I'm surprised no one has noticed already, since a new project seems to default the value to 0 on any item that doesn't yet have a different value saved in EEPROM. I'd be very curious to know if I'm somehow the only one seeing this issue, and how I might rectify it.

Thanks again for the advice! Your help is very much appreciated.
davetcc


Joined: Jan 19, 2019
Messages: 636
Offline
Something struck me, I already fixed the issue with initial startup, but have not fully tried it yet in either the example or my own stuff.

What you can do is to use the overloaded version of menuMgr.load, there is an overload now that allows a function that takes no parameteters and returns void to be provided as the 2nd parameter:

menuMgr.load(myMagicKey, [] {
    // do your work when not initialised here.
});


Could you let me know if after using that to pre-initialise it of the first run, you still see odd values in the large number value type.
milesg


Joined: Oct 8, 2021
Messages: 17
Offline
Hi Dave,
Please forgive my ignorance, but I'm not sure if you're asking me to add anything specific to the "do your work..." area in the code snipped you gave. I replaced my menuMgr.load line with yours as written (but added the default magicKey of 0xfade) and found no change in behavior.

But to be clear, I'm also seeing the blank column immediately upon exiting the value-editor after having toggled the value back to zero. This doesn't seem to be directly related to saving/loading the value from EEPROM.

Likewise, I continue to see a blank line in the value column of these menu items even if I had a non-zero value saved already, and then change the value back to zero. This display of the blank column persists through reboots (loading the saved zero value from EEPROM).

In other words, I NEVER see "0" in that column at any time, regardless of reboots/reading from EEPROM, OR even just while navigating the menu before saving any changes to EEPROM.

Please let me know if you'd like me to try anything else. I'm happy to experiment if it can help you.

Thanks!
davetcc


Joined: Jan 19, 2019
Messages: 636
Offline
I've found it, I had an STM32 board in the debugger and found the issue (and already fixed it locally)

https://github.com/davetcc/tcMenuLib/issues/147

davetcc


Joined: Jan 19, 2019
Messages: 636
Offline
Ah yes, that callback allows you to configure things when the board didn't load any settings, IE normally on the first run. But in this case there was an actual bug.
milesg


Joined: Oct 8, 2021
Messages: 17
Offline
Very cool! You're awesome Dave. Thanks so much for your help.
 
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.