chrisjn52 Posted May 31, 2016 Report Share Posted May 31, 2016 Video of my first ugfx project - a numeric Spinbox widget. Hardware is STM32F103C8T6 using RAW on 320x240 SPI colour display. Useage - ghSpinBox1 = gwinSpinboxCreate(0, &wi, 0, -200, 200, 5, ".", 2, "V"); // init, min, max, step, decimalmark, places, units Apologies if video a little shaky, it was difficult to use sylus between camera and fragile breadboard setup. P1000162.MP4 Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted May 31, 2016 Report Share Posted May 31, 2016 Wow, those look great! Nice work! Would it be possible for you to share the actual widget source? We'd love to add this spinbox widget to the official repository! From the video it seems like you are always redrawing the entire string. As an optimization it would be possible to just redraw the value string without the unit string. Link to comment Share on other sites More sharing options...
chrisjn52 Posted May 31, 2016 Author Report Share Posted May 31, 2016 Thanks for your encouragement and optimisation suggestion. I'll share the source once I have looked into this. Link to comment Share on other sites More sharing options...
chrisjn52 Posted June 1, 2016 Author Report Share Posted June 1, 2016 I must confess that I am unsure of the best way to achieve the partial redraw from an architectural standpoint. I have considered setting a flag when a spinbox mouseup event occurs so that my gwinSpinboxDefaultDraw() function will only do a partial redraw but I haven't tried this as I am not sure if it will work or whether there a preferred or more elegant method I should use? This leads me to question why I am redrawing the whole widget if only a partial redraw of the text within is possible. Clearly I am missing something here. I have looked through the examples & widget sources but I don't see any that seem to cater for a partial redraw. Link to comment Share on other sites More sharing options...
chrisjn52 Posted June 1, 2016 Author Report Share Posted June 1, 2016 Just found this thread which seems to suggest I could possibly do a partial redraw from within the spinbox mouseup function, something I had also considered. Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted June 3, 2016 Report Share Posted June 3, 2016 Using flags for a partial redraw is indeed the recommended / intended way to go. You'd set a flag that either indicates that only a partial or a full redraw is required in the functions that modify the string content. In the rendering routine you'll simply read that flag and draw the stuff that needs to be drawn accordingly. I hope that helps. Please don't hesitate to ask if you have any further questions. We are happy to help where we can. Link to comment Share on other sites More sharing options...
chrisjn52 Posted June 8, 2016 Author Report Share Posted June 8, 2016 I have attached the Spinbox source with a demo main() with the optimization you suggested, along with a short video. The spinbox now also caters for text as well as numeric data. Only mouse/touchscreen input is currently catered for. Any suggestions/improvements on the code, methods or style would be welcomed. gwin_spinbox.c main.c gwin_spinbox.h P1000165.MP4 Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted June 8, 2016 Report Share Posted June 8, 2016 This looks awesome, great work! I haven't had time to look at the code yet but the video looks very promising We will review the code (which might sadly take up to two weeks) and eventually add it to the repository. In the meantime I will create a blog post to inform people. Great work, keep it up! Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted July 18, 2016 Report Share Posted July 18, 2016 I took a closer look at the code. Here are my thoughts: The gtimerInit() function must go into the Create() function. Initialization should only happen once. After that you can use gtimerStart() and gtimerStop() at any time as you are doing now. The callback functions you use with the GTimer don't have the correct signature. They must be of the following signature: void foo(void* param). You are free to cast that void pointer to anything you like inside the function. The drawing function doesn't have the correct signature. It must be the following signature: void foo(GWidgetObject* gw, void* param). Some functions don't use the parameters passed to them. Suppress warnings by using (void)x; the upArrow and downArrow arrays in the drawing function should only be created/declared if GDISP_NEED_CONVEX_POLYGON is set to TRUE. Otherwise you get compiler warnings about unused variables. The configuration macros in the header to set the padding, border width, max. character count etc. should either get a prefix (eg. GSPINBOX_) or should be moved to the C file (recommended!) to avoid naming conflicts. That being said, I'd also like to say that I like your style of commenting things. Well done! If you handle the things listed above we can add your spinbox widget to the library Link to comment Share on other sites More sharing options...
chrisjn52 Posted July 19, 2016 Author Report Share Posted July 19, 2016 You seemed to have found some warnings that I was not aware of so I checked my GCC compiler project settings and the All Warnings (-Wall) is set as default in the ST System Workbench Eclipse IDE. I then added the Extra Warnings (-Wextra) option which added a few more of the warnings you have mentioned. Please let me know if there are any other GCC compiler warning options that you would recommend. I believe I have addressed the issues in the code that you have highlighted and the revised code is attached. gwin_spinbox.c main.c gwin_spinbox.h Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted July 19, 2016 Report Share Posted July 19, 2016 Thanks for getting this done so quickly! I will have a look at it tomorrow and let you know. If you really hate your life you can enable -pedantic. But the warnings I got I got from regular GCC while compiling on win32. When developing something like a widget you definitely want to use the Windows/Linux/MacOS port, otherwise you have to flash your target each time and debugging is a pain too. Also I got crashes with the spinbox that was supposed to show the days of the week. However, I simply commented it out and didn't investigate due to not having a whole lot of time. I'll try again with the new version tomorrow and let you know how it's looking. 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