chrisjn52 Posted May 3, 2016 Report Share Posted May 3, 2016 Could you confirm whether there are any plans to create a numeric control widget such as is shown here, (Amplitude [V]), before I attempt to create one based on the textedit widget with dial input capability? Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted May 3, 2016 Report Share Posted May 3, 2016 A widget like that (spin box) is on the ToDo list but with a very low priority. Due to other more important tasks we won't tackle this within the next couple of months. However, as you mentioned it's possible to create a widget yourself. I can recommend you having a look at our brand new "HowTo: Create a widget" article that is currently work in progress but already very usable: http://wiki.ugfx.org/index.php/Creating_a_widget Any feedback is highly welcomed. Let us know if you have any questions. We are happy to help you wherever we can. Link to comment Share on other sites More sharing options...
kamocat Posted August 27, 2018 Report Share Posted August 27, 2018 Hi Chris, I realize that this topic is 2 years old. Did you end up making the Numeric Control widget? @chrisjn52 Link to comment Share on other sites More sharing options...
kamocat Posted August 27, 2018 Report Share Posted August 27, 2018 I took a stab at this, basing my widget off of the Textedit widget. So far I have it ignoring letters and safely handling decimals. (If a new decimal point is inserted, the old decimal point is removed) Those are mostly cosmetic, though. Here's what I intend to do: Create a method to read the number, as a floating point. Change from insertion mode to overwrite mode, as this seems more intuitive for numeric entry. Add support for dial inputs Add support for negative numbers To make it more like the LabVIEW Numeric Control, you would also need those up/down arrows that emulate a dial input. I think this would make more sense as a separate widget. Honestly, I think they're hard to use, so I'm not planning on implementing that. Something that bothers me about the Textedit implementation is the dynamic memory allocation. I suppose it's memory-efficient, but since we're limited to 16 digits of precision in Double Floating Point, it seems reasonable to allocate 19 bytes and be done with it. (That's an extra byte each for the decimal and negative symbols and terminating character) Link to comment Share on other sites More sharing options...
inmarket Posted August 28, 2018 Report Share Posted August 28, 2018 Your memory allocation scheme sounds appropriate to me too. Good thinking. Link to comment Share on other sites More sharing options...
kamocat Posted August 28, 2018 Report Share Posted August 28, 2018 Alright, I have the first two parts done. I'm creating a fork on the git site so other people can see where I'm at. Next is the dial input. How do I simulate that? Does the slider work for this? Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted August 29, 2018 Report Share Posted August 29, 2018 That sounds great! I'm looking forward seeing that widget You simply add the function to the widget's VMT which handles incoming dial events - simple as that! --> https://wiki.ugfx.io/index.php/Creating_a_widget#VMT Link to comment Share on other sites More sharing options...
kamocat Posted August 29, 2018 Report Share Posted August 29, 2018 Hey, I just noticed the spinbox widget. This appears to be very similar to what Chris was asking for, but for text instead of numbers. Or maybe it works with both? Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted August 29, 2018 Report Share Posted August 29, 2018 The spinbox in that branch is made for nummeric values, not texts Link to comment Share on other sites More sharing options...
kamocat Posted August 29, 2018 Report Share Posted August 29, 2018 I see. The numeric one seems to work fine, but the text one gives a segfault. Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted August 29, 2018 Report Share Posted August 29, 2018 Yep, that seems correct. I remember that I left of pretty much at that point. I still wish to finish it at some point. If I remember correctly it's like 95% done. The segfault should be easy to track down as it will be either a buffer allocation or an array index overflow. Link to comment Share on other sites More sharing options...
kamocat Posted August 29, 2018 Report Share Posted August 29, 2018 From Valgrind: ==19659== Invalid read of size 1 ==19659== at 0x11300D: strip_spaces ==19659== by 0x1132E7: mf_render_aligned ==19659== by 0x10E30C: gdispGFillStringBox ==19659== by 0x11A6E6: gwinSpinboxDefaultDraw ==19659== by 0x1168C9: _gwidgetRedraw ==19659== by 0x11781F: WM_Redraw ==19659== by 0x117069: _gwinFlushRedraws ==19659== by 0x116E1F: RedrawTimerFn ==19659== by 0x11503C: GTimerThreadHandler ==19659== by 0x49CBFC1: start_thread (in /usr/lib32/libpthread-2.28.so) ==19659== by 0x4AE0CA5: clone (in /usr/lib32/libc-2.28.so) ==19659== Address 0x0 is not stack'd, malloc'd or (recently) free'd I've attached the demo I'm using, which I put in ugfx/demos/gwin/spinbox Strangely, it works ok for 4 items, but not for 5. (Although the first item is replaced with "f", and the last item doesn't show up) Anway, I'm done playing with this one for now. It doesn't quite do what I want, and I don't really want to debug the drawing routine. However, storing the value as an integer instead of a float is a good idea, and might very well be more effecient. I think I'll make a function for that too. main.c gfxconf.h demo.mk Link to comment Share on other sites More sharing options...
kamocat Posted August 29, 2018 Report Share Posted August 29, 2018 (edited) Back onto the numeric control I'm making: I'm having trouble with activating my git account. I'll leave that as a seperate thread. So, here's what I've done so far. These go in ugfx/demos/modules/gwin/numeric/ main.c gfxconf.h demo.mk These go in ugfx/src/gwin/ gwin_numeric.h gwin_numeric.c Edited August 29, 2018 by kamocat Link to comment Share on other sites More sharing options...
kamocat Posted September 14, 2018 Report Share Posted September 14, 2018 Hi everyone, I know it's been a while. I haven't gotten the dial working yet, because as far as I can tell, events aren't triggering the geventEventWait() function on my laptop. I haven't tried on my stm32. Anyway, I'm running out of time before classes start, and so I wanted to upload my progress for the benefit of the community. I sqaushed it into a single git patch. What I settled on for the dial input was overwriting the first n digits of the value. This seemed to make more sense than modifying the least significant digit, since the dial input seems to be for analog dials with limited range, rather than rotary encoders. Also, it allows use of the dial without the keyboard - it didn't seem to make much sense to use the dial in conjunction with the keyboard. If someone wanted an exact number, they would just type it in. Anyway, that's what the gwinNumericSetIntVal() is intended for. 0001-Creating-Numeric-Control-and-demo.patch Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now