• AVR Freaks

Helpful ReplyHot!Layer switch cause strange behaviour

Author
DanmartDSE
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2018/08/29 00:37:58
  • Location: 0
  • Status: offline
2018/11/09 00:34:19 (permalink)
0

Layer switch cause strange behaviour

Background: MPLAB X IDE v5.05, XC32v2.10, PIC32MZ2064DAH176, Harmony v2.05.2, 7” 800x480 display
 
Hi, I am facing some issues when switching between layers in my application.
I have implemented a pop-up message which is displayed in Layer1 over Layer0;  when it disappears data fields in Layer0 start to blink between two different values. Please, keep on reading for further explanation.
 
Let’s take ImageOne as an example of what is going on with my application (it is not the actual screen, as I have several widgets and data fields in  Layer0).
 
So looking at ImageOne: Layer0 has black background containing two data fields (left and right). Layer1 contains the popup greybox which disappears when pressing “OK” button.
 
What I have going on is:
1-      Left-datafield counting seconds
2-      Pop-up menu appears (left-datafield keeps counting seconds)
3-      Press OK
4-      Unpress OK triggers event (set in Graphics Composer): eventOK = 1;
5-      Back to the code “eventOK = 1” causes: Right_Datafield_Value  = Right_Datafield_Value + 1;
6-      Pop-up menu disappears. Left-datafield keeps counting seconds; right-datafield value blinks between 0 and 1 every second.
If loop is repeated (steps 2 to 6 again) right-datafield value blinks between 1 and 2 every second, and so on.
  
It seems like Layer0 is stucked between a previous state to the Layer0-to-Layer1 switch and another state after the Layer1-to-Layer0 switch (?). I don’t know if this makes any sense.
It also happens that if left-datafield is set from the start not to count seconds then right-datafield does not blink; but now it follows erratic behaviour and “Right_Datafield_Value  = Right_Datafield_Value  + 1;” increments are not properly actualized. By this I mean that the display is not actualized, because if for example in the third loop it is displaying value 2 (should be 3), in the fourth loop it correctly changes to value 4.
 
Now, this is the code I have in order to handle the pop-up menu.
 
When the  pop-up message is desired to be displayed Layer0 is alphablended with Layer1, so Layer0 is shaded (see code below: AlphaAmount=70; actually this is not shown in image one):
      screen = laContext_GetActiveScreen();     //there are several screens, so it takes the one displayed
        layer = screen->layers[0];
        laLayer_SetAlphaAmount(layer, 70);
        layer = screen->layers[1];
        laLayer_SetAlphaAmount(layer, 255);  
        laLayer_SetAllowInputPassthrough(layer, LA_FALSE);
        laWidget_SetVisible((laWidget*)PopUpMenu, LA_TRUE); //displays the grey box with the OK button
 
Until this point it works fine. When OK button is pressed (and unpressed, as commented before) this is the code that follows:
      screen = laContext_GetActiveScreen(); //there are several screens, so it takes the one displayed     
        layer = screen->layers[0];
        laLayer_SetAlphaAmount(layer, 255);
        layer = screen->layers[1];
        laLayer_SetAlphaAmount(layer, 0);   
        laLayer_SetAllowInputPassthrough(layer, LA_TRUE); 
        laWidget_SetVisible((laWidget*)PanelMensajeAcc, LA_FALSE); //hides the grey box with the OK button
 
I have already read some threads here in the forum but I am not able to find any explanation to this behaviour, so any feedback would be appreciated. Thank you so much in advance.
 

Attached Image(s)

#1
Ed@Microchip
Super Member
  • Total Posts : 152
  • Reward points : 0
  • Joined: 2017/04/06 09:39:29
  • Location: 0
  • Status: offline
Re: Layer switch cause strange behaviour 2018/11/09 09:35:23 (permalink) ☄ Helpfulby DanmartDSE 2018/11/12 02:34:47
5 (1)
Are you using double-buffering? If so, can you confirm:
 
1. Both layer0 and layer1 are set to double-buffered in MHGC (select the layer in the Tree and set Buffer Count = 2) 
2. In MHC, GLCD is set to double-buffered (Use Graphics Stack -> Graphics COntroller -> GLCD -> Driver Settings ->Frame BUffers per layer = 2)
#2
DanmartDSE
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2018/08/29 00:37:58
  • Location: 0
  • Status: offline
Re: Layer switch cause strange behaviour 2018/11/12 02:34:36 (permalink)
0
Thank you Ed, that was indeed the problem: buffer count in Layer1 was set to 1 instead of 2. Now the values of the datafields are being correctly displayed.
 
Now there is another issue regarding objects in Layer1.
It is possible to show new objects and to move them to different places in the layer, but it is not possible to make them disappear from the screen.
For example an object can be succesfully moved once from one place to another, but when trying to move this object a second time it does not disappear from the original position, being hence duplicated instead of moved.
#3
Ed@Microchip
Super Member
  • Total Posts : 152
  • Reward points : 0
  • Joined: 2017/04/06 09:39:29
  • Location: 0
  • Status: offline
Re: Layer switch cause strange behaviour 2018/11/12 09:32:17 (permalink) ☄ Helpfulby DanmartDSE 2018/11/13 08:45:29
0
Layers will need to have a background scheme assigned to it so it can use the 'background color' to repaint the areas used for previous widget positions. In the case of the upper layers (1 & 2), this will be a 'clear' color scheme, so that the base layer will show through when the upper layer background is repainted.
 
To do this, you will need to create a "Clear Scheme" with color background color set to 0 (note, alpha channel = 0), assign it to the layer and set the background type to "Fill".
 
You can look at the GFX demo applications for reference. As an example, look at the MHGC project for Aria_showcase, pic32mz_da_sk_intddr_meb2 configuration. Check out the assigned scheme (ClearScheme) for layers 1 & 2, and the background type (Fill).
#4
DanmartDSE
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2018/08/29 00:37:58
  • Location: 0
  • Status: offline
Re: Layer switch cause strange behaviour 2018/11/13 08:39:01 (permalink)
0
Thanks again for your help Ed, it solved the proble.
However, we are facing new issues related to Layer1 position in the screen. Layer1 is correctly displayed only when it is positioned in (0, 0) like the ImageTwo attached.
 
In order to increase performance, we would like that Layer1 would be as small as possible, so it is necessary to place it at a position different than (0, 0), as shown in ImageThree.
 
When we place the Layer1 at a position different than (0,0), Layer1 is not correctly displayed: depending on the position Layer1 is located, it is shown only partially or it is not shown at all.
P.S: The images attached show Layer1 with white background over Layer0 in black background.
post edited by DanmartDSE - 2018/11/13 08:45:08

Attached Image(s)

#5
Ed@Microchip
Super Member
  • Total Posts : 152
  • Reward points : 0
  • Joined: 2017/04/06 09:39:29
  • Location: 0
  • Status: offline
Re: Layer switch cause strange behaviour 2018/11/13 09:06:49 (permalink)
0
Hi Dan,
 
   We'll take a look if this is an issue with the library.
 
   As an alternative solution, you can have Layer1 at 0,0 at full size and just use a panel widget as a parent widget for the other widgets in Layer1. Set the size of the panel widget to your desired size and reposition it inside Layer1. All the child widgets inside the panel widget will follow its parent. You can also set a color scheme for the panel widget to set a background color for the panel area.
 
    You can look at the aria_coffee_maker graphics demo application as reference. Check out the "MainScreen" screen and see how the widgets in Layer1 and 2 are parented under a panel widget that partially fills the layer. The panels slide in and out of the screen, with the children widgets inside.
 
Thanks,
 
Ed
#6
Jump to:
© 2019 APG vNext Commercial Version 4.5