cancel
Showing results for 
Search instead for 
Did you mean: 

I'm trying to create a screen positioning screen.

PSucr.1
Associate II

I'm trying to create a screen positioning screen, to adjust the location of the screen using the LTDC registers. I've used the BPRC registers, and the HAL_LTDC_SetWindowPosition() function methods.

My screen has 4 buttons for adjusting all directions in X, and Y.

When a limit is reached, I setInvisible() the button.

==============================

I've created a routine to adjust the BPCR registers, and this moves the display around.

But is is limited to a small range of values in Y, only 0..23. Greater than that generates and LTDC_ER_EXCEPTION. (X-Range is 0..100+)

I've also found if NOT called from the VSync interrupt (OSWrappers::signalVSync() routine), I get random LTDC_ER_EXCEPTION.

I've created a callback mechanism, so this routine is called from the VSync interrupt.

callback()

{

  // Need to change LTDC_BPCR register only.

  hltdc.Init.AccumulatedHBP = x; // 46, 0..100 allowed

  hltdc.Init.AccumulatedVBP = y; // 23, 0..23 allowed (24 locks up the GUI.)

  hltdc.Init.AccumulatedActiveW = x + DISPLAY_SIZE_X;

  hltdc.Init.AccumulatedActiveH = y + DISPLAY_SIZE_Y;

   

  // Changes the Horizontal, and Vertical Back Porch values.

  hltdc.Instance->BPCR &= ~(LTDC_BPCR_AVBP | LTDC_BPCR_AHBP);

  int tmp = (hltdc.Init.AccumulatedHBP << 16U);

  hltdc.Instance->BPCR |= (tmp | hltdc.Init.AccumulatedVBP);   

}

This works rather well, but as I said, is very limited in Y movement.

outside the interrupt, it generates the LTDC_ER_EXCEPTION sometimes.

==============================

So I tried using the HAL_LTDC_SetWindowPosition() routine which also moves the display around.

I also call this from the VSync Interrupt. I get better range on this routine X values of -50..45, and Y values of -87..0.

BUT, I'm noticing that some of the Buttons, when setInvisible(), will come and go, as the screen is moved. They are still there, but just NOT redrawn. And sometimes other strange artifacts.

I also note with the HAL_LTDC_SetWindowPosition, that sometimes I get the LTDC_ER_EXCEPTION.

=========================

I also tried to implement the HAL_LTDC_SetWindowPosition_NO_RELOAD, then doing a HAL_LTDC_Reload, setup for the next blanking inverval. This can be called directly from the GUI when a button is pressed.

This version can run outside of the VSync Interrupt, but still has the problems with buttons coming, and going, and once in a while LTDC_ER_EXCEPTION, and similar strange artifacts.

Any ideas.

Paul Sucro.

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

I could imagine these kinds of errors when you try to configure the LTDC layer when the application is running. I think maybe it would be better to configure the position of the root container in your screen - This does not require you to do any LTDC layer configuration and will move all the children in the screen at the same time. Also, this allows you to utilize the background color of the Layer as you're moving the screen container in any of the four directions, and thus only being displayed on the layer partially.

The only reason to really re-configure the layer is if you're using two layers and want to utilize the blending factor in the layer itself.

Screen.hpp defines the following function:

/**
     * Obtain a reference to the root container of this screen.
     *
     * @return The root container.
     */
    Container& getRootContainer()
    {
        return container;
    }

View solution in original post

3 REPLIES 3
Martin KJELDSEN
Chief III

I could imagine these kinds of errors when you try to configure the LTDC layer when the application is running. I think maybe it would be better to configure the position of the root container in your screen - This does not require you to do any LTDC layer configuration and will move all the children in the screen at the same time. Also, this allows you to utilize the background color of the Layer as you're moving the screen container in any of the four directions, and thus only being displayed on the layer partially.

The only reason to really re-configure the layer is if you're using two layers and want to utilize the blending factor in the layer itself.

Screen.hpp defines the following function:

/**
     * Obtain a reference to the root container of this screen.
     *
     * @return The root container.
     */
    Container& getRootContainer()
    {
        return container;
    }

PSucr.1
Associate II

I tried this method, but it does not adjust the screen position under simulation.

I would expect this to adjust the position diagonally down, and the right each time called.

  Container rootContainer = getRootContainer();

  rect = rootContainer.getRect();

  rect.x += 1;

  rect.y += 1;

  rootContainer.setWidth(rect.width - 1);

  rootContainer.setHeight(rect.height - 1);

  rootContainer.setXY(rect.x, rect.y);

  rootContainer.invalidate();

You'll have to live with that (for now anyway) =) It's not something we considered abstracting in the simulator HAL (HALSDL2.cpp). Feel free to read up on SDL and tinker with that in:

touchgfx/source/platform/hal/simulator/HALSDL2.cpp

So it works for you on target?