GUI

More
01 May 2012 19:34 #136 by PhracturedBlue
Replied by PhracturedBlue on topic Re: GUI
Yes, that is feasible. We don't actually need 2 image functions. The BMP format defines whether there is alpha or not, so we can just figure it out from the header I believe. There are a few ways to deal with alpha in BMP, so we need to find the most supported method, but it should be possible.

Transparent background on fonts is already there. just add '-DTRASNPARENT_FONT' (note the typo) in the makefile

I didn't enable it because it made no sense until we had a proper refresh function.

Please Log in or Create an account to join the conversation.

More
01 May 2012 20:11 #137 by FDR
Replied by FDR on topic Re: GUI
There must be a reason they didn't use alpha ch, for example the larger file size.
If we first read in the same viewport from the background image, then we can draw the new color if it is not magenta, otherwise the old one again. It can be complicated, if we aren't drawing directly to the bacground, but some intermediate layers...

Please Log in or Create an account to join the conversation.

More
01 May 2012 20:25 #138 by MatCat
Replied by MatCat on topic Re: GUI
Not an alpha channel, but an alpha value on the entire bitmap + black for full transparency, that is what the Walkera firmware does.

I don't recommend using black for full transparency marker though because it is too valuable a color to be used. Though I suspect that the walkera routine actually does use a buffer because the background image renders black (could just be because the canvas is black), however the status bar animation on startup screws up when the background has transparency, this means it is not just drawing the background, then the status bar animation ontop, it is actually combining them together then drawing it, otherwise the status bar would not screw up on transparent parts of the background, it would just draw ontop.

I do not know how much ram we are working with on the device, for a single full screen buffer (which is what I suspect walkera is using).

It is slow though, and you can see the lines draw when it alphas, though it is applying alpha to almost the entire screen since it is the primary panel that gets it.


I am open to suggestions on it, at this moment I am not even going to focus on that so much as I am to get the GUI API in place so we can develop with it, looks can be refined later, but at this stage we do need to know if it is worth it or not to use a buffer since that is something we need to know now :).

My goal today is:

Labels (Text holders)
Frames (Window/Canvas for GUI Objects)
Beginnings of a Dialog Box

Please Log in or Create an account to join the conversation.

More
01 May 2012 20:38 #139 by MatCat
Replied by MatCat on topic Re: GUI
Do we have the ability to ask the LCD for the color of a pizel at an x,y coordinate? Instead of trying to incrament the pointer address why not just read the current pixel and re-write it IF possible?

Please Log in or Create an account to join the conversation.

More
01 May 2012 20:45 #140 by PhracturedBlue
Replied by PhracturedBlue on topic Re: GUI
Sometimes I think I'm talking to a brick wall :)
I mentioned above I tried exactly that and it didn't work. I think I know why, so I may give it a shot in the future (you shouldn't actually need to write the pixel, since reading it should increment the pointer)

In any case, it is already done. Pull my latest code.
fonts will have a transparent background
bitmaps generated by GIMP in 1555 format will have transparent background.
You don't lose any colors, but do lose 1 bit of depth on green.
Included is such a bitmap
Attachments:

Please Log in or Create an account to join the conversation.

More
01 May 2012 21:06 #141 by MatCat
Replied by MatCat on topic Re: GUI
Ok it looks a million times better now ROFL, BUT it is doing alpha it seems to the entire graphic... the image is a pearly colored button, but renders as blueish color, still looks good though :).

Sorry if I didn't get a clear picture of what you said earlyer.

Please Log in or Create an account to join the conversation.

More
01 May 2012 21:19 #142 by PhracturedBlue
Replied by PhracturedBlue on topic Re: GUI
It isn't doing alpha on the entire image, but it may be that my RGB555->RGB565 conversion isn't right. I need to convert 5bit green into 6bit green and I might have gotten it wrong. You should also check that the original BMP looks ok when rendered in windows. If not, then I may have screwed up the color conversion when I created it. Note that alpha is currently 'hard' if the alpha bit is set, the pixel is 100% transparent, otherwise it is 100% opaque. That may not be the right way to implement it, but it was the easiest. I need to find a better spec for how ARGB1555 is supposed to be displayed.

Please Log in or Create an account to join the conversation.

More
01 May 2012 21:29 #143 by PhracturedBlue
Replied by PhracturedBlue on topic Re: GUI
I fixed the color issue. I was indeed improperly converting ARGB1555->RGB565

Please Log in or Create an account to join the conversation.

More
01 May 2012 21:41 #144 by MatCat
Replied by MatCat on topic Re: GUI
Ok good, I just got done implamenting labels too. I am converting over main.c any sprintf's to use labels if has_fs is defined. At this point merging any changes to main.c is going to cause me a lot of conflicts :P.

Please Log in or Create an account to join the conversation.

More
01 May 2012 22:39 #145 by MatCat
Replied by MatCat on topic Re: GUI
Would it pose any problems to include string.h in the project on a global space?

Please Log in or Create an account to join the conversation.

More
02 May 2012 00:56 #146 by PhracturedBlue
Replied by PhracturedBlue on topic Re: GUI
I'm not sure what you are doing with the strings, but you should be constantly aware of our memory limitations. 48KB is not very much memory at all. We need to be very smart about what we keep in RAM vs what is in ROM. Wherever possible it is probably ideal to pre-compute strings and only store indexes/refernces to them.
You can likely include any include file that is in libc. we have newlibc for the stm32.

You really shouldn't use HAS_FS for anything other than handling bitmaps. I see no reason why the label class would need to be bounded by that In fact, I can move HAS_FS into the bmp drawing code, such that DrawImage just draws a solid-color fill if it isn't defined. I don't want lots of #ifdefs in the code, and would like to be able to test as much functionality on real hardware at all times. I hope it won't be too long until I have USB stuff working.

It may make sense to just start over with main.c. It was designed purely as a proof of concept, and the current output does not need to be maintained (though the scanner that rcH4x0r implemented may be cool to keep as an option in the final firmware)

Please Log in or Create an account to join the conversation.

More
02 May 2012 01:52 #147 by MatCat
Replied by MatCat on topic Re: GUI
Good point on ifdefs...

Well at the moment all gui objects are stored in arrays, each with their own string, at the moment it's not the most effecient but as I go along I am improving it for memory use...

I am removing the ifdefs and only putting them where bmp is drawn...

Only reason I am even bothering with the current main.c is because we don't really have much else going on yet so it provides a good testbed at the moment.

Please Log in or Create an account to join the conversation.

More
02 May 2012 02:10 #148 by MatCat
Replied by MatCat on topic Re: GUI
I just pushed some code that is a LOT cleaner, and should work on device (buttons would just render as a text string).

Without a buffer it's quite annoying as everything flashes as it's redrawn which I imagine will only get worse as more elements are on screen.

I am going to ponder over strings for a minute...

Please Log in or Create an account to join the conversation.

More
02 May 2012 03:02 #149 by MatCat
Replied by MatCat on topic Re: GUI
Ok seeing as how my programming is generally done for PC's, the concept of worrying about rom vs ram is a concept I am working on trying to figure out...


You say we have a 48k ram limit...

in the fonts file you create arrays of fonts, they are const, does this mean the ptr to them is pointing to a ROM location? Or is all of that allocated in RAM?

Please Log in or Create an account to join the conversation.

More
02 May 2012 04:49 #150 by PhracturedBlue
Replied by PhracturedBlue on topic Re: GUI
You can assume that any data that is 'const' will be ROM.
So the fonts are in ROM. Any string that is specified in quotes is also in ROM (but sprintf will copy it to RAM of course)

printf("foo") : "foo" is in ROM
char foo[] = "bar" : "bar" is (probably) in RAM (if the string isn't modified, it could be in ROM)
const char foo[] = "bar" : bar is in ROM
sprintf(foo, "bar") : foo is in RAM but "bar" is in ROM

Please Log in or Create an account to join the conversation.

More
02 May 2012 05:26 #151 by MatCat
Replied by MatCat on topic Re: GUI
So... if defined as const it is rom... but I assume const cannot be changed once set... is there a way to have changable strings stored in rom?

Also what about scope... I assume locally declared variables are gone once the scope is done (I.E. in a function call).

Obviously we are going to need a string table...

48k really is not much...

Please Log in or Create an account to join the conversation.

More
02 May 2012 06:49 #152 by PhracturedBlue
Replied by PhracturedBlue on topic Re: GUI
If a variable is const, it can be locally scoped or global, it'll still be in ROM (but like any local variable you can only access it from the function it is defined in)

you cannot have a modifyable string in ROM. By definition ROM is read-only, so it can't be changed.
you can use sprintf and friends to create a new variable based on a const string, which will go into RAM (generally on the stack). But you don't want to keep that string in memory, so you need enough info to regenerate it on demand for repainting.

Please Log in or Create an account to join the conversation.

More
02 May 2012 15:24 #154 by PhracturedBlue
Replied by PhracturedBlue on topic Re: GUI
I get a segfault with your latest code:
Program received signal SIGSEGV, Segmentation fault.
0x0000000000403da7 in GUI_DrawObjects () at gui/gui.c:136
136						buttonBox = GUI_Button_Array[GUI_Array[i].TypeID].box;
(gdb) p i
$1 = 206
looks like 'i' is out of rage. GUI_Array is only 128 elements long. Changing the declaration to Gui_Array[256] fixed it for me.

I like the direction you are going. I'm not sure about hardcoding the arrays, but something like a linked-list or malloc could easily use up more RAM in overhead and be less predictable.
Your code currently uses 0x4370 = 17kB of RAM FYI

Please Log in or Create an account to join the conversation.

More
02 May 2012 18:09 #155 by MatCat
Replied by MatCat on topic Re: GUI
Yeah I am still trying to think of a better solution then hard arrays... Last night I changed the array sizes and forgot to change some of the loops :P.

I thought about link lists or dynamic arrays as well...

Certainly a chalange point I am not used to but it's fun to figure it out none the less :).

Please Log in or Create an account to join the conversation.

More
02 May 2012 22:17 #156 by MatCat
Replied by MatCat on topic Re: GUI
I attempted to enlarge the gui.bmp to a 500x500 image however the program barfed on it and spit out what appeared to be a memory dump, I made it smaller (I think 300x300) which resulted in no error however it was unable to render any piece of the image...

Please Log in or Create an account to join the conversation.

Time to create page: 0.077 seconds
Powered by Kunena Forum