king2 Posted January 6, 2016 Report Posted January 6, 2016 Hi!I need to solve some tasks with GIU. I will ask questions with description, may be there is a simpler way to get my tasks completed.My main goal is to solve my tasks without deep modifying/tuning components. Maybe my questions are dumb, so sorry in advance! If in each of cases there is a better way to do it, please tell me!1. [setting date and time] To set each of day, month, hour, minute and so on, I should for each of them make text label, up/down arrows, write some code to not allow user set month number 0 or 13, or 25-th hour (to get something like emWin's 'spinner' widget). Can I do it simple with uFGX?2. [buttons with pictures etc] I need to make square button with picture inside (green/red depending of status), and little text in it as second line. As I understand, I should use gwinButtonDraw_Image, and draw text at pre-defined coordinates inside button. Can image be replaced on-fly when needed with another? I do not need any animation of pressing process, users just presses on button, I do something inside my firmware and than I can change or not button status.3. Can I draw text on top of image button? For all elements, how can I define z-orders that I need?4. Can images and fonts be compressed in firmware?Thank you in advance!
Joel Bodenmann Posted January 6, 2016 Report Posted January 6, 2016 1. The most proper, most reliable and most portable way of doing this is creating your own widget that allows to input a date/time. The widget would behave just like the other widgets such as the buttons and the sliders: You can create an instance, you can place them anywhere on the display and you can give them any size. The widget would sent an event through GEVENT when the date/time has changed just like the slider sends an event when the slider position has changed. You can also add different functions eg. to query the current date/time and to change from 12 to 24 hour mode. Those are of course not necessary but writing a real widget helps you to add functionalities in the future while being completely portable.Writing your own widget is not as complex as it might look at the first glance. Essentially it is just a VMT (table of function pointers) where you register your functions that handle touch inputs and so on. Everything is nicely commented and documented. As there are already quite a lot of different widgets you have many different examples that will help you to understand how to write your own widgets. We are also happy to answer any of your questions (please make a new forum thread for that).I would really encourage you for writing a real widget for this. The widget class is really just a container and it won't be more difficult than writing this manually. There is one function that renders the widget and in that function you call gdispDrawXxx() and gdispFillXxx() functions just as you would outside of a widget and there are other functions that tell you when a touch happened and at what position. It's straight forward - really. Just read some of the existing ones and let us know when you have any questions 2. Using the gwinButtonDraw_Image rendering routine is the correct way of doing what you want to do. You can replace the image at any time by just calling gwinSetCustomDraw() with a different image pointer. That function will also take care of redrawing the button widget so you don't have to take care of that yourself.Important note: Many people want to change the image during runtime because they want to draw different images for the pressed and the released state. However, that is not necessary. .The gwinButtonDraw_Image already takes care of that for you: The image you pass by gwinSetCustomDraw() can either have one time, two times or three times the height of the actual button widget itself. When the image is twice the height than the button then the top half of the image is used for the 'released' state and the bottom half is used for when the button is in the 'pressed' state. The same applies to when then image is three times the height: Top for pressed, middle for released and bottom for when the button is disabled.Here's a very basic image just to make sure that you understand what I'm trying to say:
king2 Posted January 6, 2016 Author Report Posted January 6, 2016 1. Now I deciding should I switch from CMSISOS/StemWin back to ChibiOS or not, and use uGFX instead of StemWin or not (chances of uGFX was just raised ). But I have to try new ChibiOS USB host stack first. Next I will try to implement interface with uGFX (approx in a week). If I will decide to use uGFX, sure, I will code date/time widget and will share it with you and community.2, 3. OK, I understood, it looks simpler that I expected.4. I have SDRAM in my hardware, so I will try to have fonts compressed and uncompress it into SDRAM from firmware.Thanks!
Joel Bodenmann Posted January 6, 2016 Report Posted January 6, 2016 Glad to hear that you like what you see Note that you can run uGFX on any RTOS (or bare metal without any operating system at all). The decision whether you want to use uGFX or not shouldn't be influenced by the underlying system.Please do not hesitate to ask should you have any other questions. We are happy to help where we can.~ Tectu
inmarket Posted January 6, 2016 Report Posted January 6, 2016 Fonts are typically stored in program space (they compile as static const structures) and are thus normally stored with the program in the flash.Because of this unless you have extremely small amouts of flash or are using lots of large fonts there is generally no need to relocate them into RAM.Note that fonts are already a compressed format (they are not stored as pixel images) so additional compression may not make as much a difference as you expect.
king2 Posted January 7, 2016 Author Report Posted January 7, 2016 Thanks!Sure I know that uGFX isn't glued to ChibiOS, in my case it is different choices, but first priority is to choose right OS.I have 512 kb flash only, but I have to include firmware for another two modules in main firmware to make all system to be updated with current versions, so I'm trying to reduce space everywhere..
Joel Bodenmann Posted January 7, 2016 Report Posted January 7, 2016 Using RLE fonts is the way to go then ~ Tectu
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