cancel
Showing results for 
Search instead for 
Did you mean: 

Render problems after rotating the display 180 degrees

MPant.1
Associate

I have a TFT display with a resolution of 800x480 and STM32F429. Used the code from here https://community.st.com/s/question/0D50X0000A1lVxsSQE/repost-change-lcd-orientation-in-180-degree , everything works fine in the simulator

0693W000003C3QDQA0.png

and separately tested on the 476H Discovery but on the TFT with F429 does not render different areas

0693W000003C3WGQA0.jpg

// FrontendApplication.hpp
 
virtual void draw(Rect& rect) {
  if(drawCacheEnabled) {
    Rect r(0, 0, HAL::DISPLAY_WIDTH, HAL::DISPLAY_HEIGHT);
    Application::draw(r);
  } else {
    Application::draw(rect); 
  }
}
 
// Mirror.hpp
 
#ifndef MIRROR_HPP
#define MIRROR_HPP
 
#include <touchgfx/widgets/Widget.hpp>
#include <touchgfx/hal/HAL.hpp>
 
class Mirror : public touchgfx::Widget {
public:
  Mirror() {}
  virtual ~Mirror() {}
  virtual touchgfx::Rect getSolidRect() const {
    return Rect(0, 0, 0, 0);
  }
  virtual void draw(const touchgfx::Rect& invalidatedArea) const {
    uint16_t* framebuffer = touchgfx::HAL::getInstance()->lockFrameBuffer();
    for(int y = 0; y < HAL::DISPLAY_HEIGHT / 2; y++) {
      touchgfx::HAL::getInstance()->blockCopy((void*)rowBufferTop, (const void*)(framebuffer + y * HAL::DISPLAY_WIDTH), HAL::DISPLAY_WIDTH * 2);
      uint16_t* start = rowBufferTop;
      uint16_t* end = start + HAL::DISPLAY_WIDTH - 1;
      for(int x = 0; x < HAL::DISPLAY_WIDTH / 2; x++) {
        uint16_t temp = *start;
        *start = *end;
        *end = temp;
        start++;
        end--;
      }
      touchgfx::HAL::getInstance()->blockCopy((void*)rowBufferBottom, (const void*)(framebuffer + (HAL::DISPLAY_HEIGHT - 1 - y) * HAL::DISPLAY_WIDTH), HAL::DISPLAY_WIDTH * 2);
      start = rowBufferBottom;
      end = start + HAL::DISPLAY_WIDTH - 1;
      for(int x = 0; x < HAL::DISPLAY_WIDTH / 2; x++) {
        uint16_t temp = *start;
        *start = *end;
        *end = temp;
        start++;
        end--;
      }
      touchgfx::HAL::getInstance()->blockCopy((void*)(framebuffer + y * HAL::DISPLAY_WIDTH), rowBufferBottom, HAL::DISPLAY_WIDTH * 2);
      touchgfx::HAL::getInstance()->blockCopy((void*)(framebuffer + (HAL::DISPLAY_HEIGHT - 1 - y) * HAL::DISPLAY_WIDTH), rowBufferTop, HAL::DISPLAY_WIDTH * 2);
    }
    touchgfx::HAL::getInstance()->unlockFrameBuffer();
  }
private:
  static const uint16_t DISP_WIDTH = 800;
  mutable uint16_t rowBufferTop[DISP_WIDTH];
  mutable uint16_t rowBufferBottom[DISP_WIDTH];
};
#endif
 
// StartupView.hpp
void StartUPView::setupScreen() {
  StartUPViewBase::setupScreen();
  mirror.setPosition(0, 0, 800, 480);
  add(mirror);
}

Everything works fine without a mirror and these empty zones appear in different places

1 REPLY 1
Alexandre RENOUX
Principal

Hello,

What is the status on your issue ? Why do you want to mirror the screen by code ?

/Alexandre