Fix TouchGFX and update UI

This commit is contained in:
2024-07-21 14:34:44 +02:00
parent 51f6fa6014
commit 3208c8f86f
5 changed files with 30 additions and 39 deletions

View File

@ -1005,7 +1005,6 @@
{
"Type": "CustomContainerInstance",
"Name": "statusTS_R2D",
"X": 1,
"Width": 65,
"Height": 33,
"CustomContainerDefinitionName": "DriverViewStatusItem"
@ -1053,7 +1052,7 @@
{
"Type": "CustomContainerInstance",
"Name": "statusLV",
"X": 389,
"X": 390,
"Width": 65,
"Height": 33,
"CustomContainerDefinitionName": "DriverViewStatusItem"

View File

@ -23,37 +23,47 @@
#include <touchgfx/hal/PaintRGB565Impl.hpp>
#include "stm32h7xx.h"
#include "stm32h7xx_hal_ltdc.h"
using namespace touchgfx;
namespace
{
// Use the section "TouchGFX_Framebuffer" in the linker script to specify the placement of the buffer
LOCATION_PRAGMA_NOLOAD("TouchGFX_Framebuffer")
uint32_t frameBuf[(320 * 480 * 2 + 3) / 4] LOCATION_ATTRIBUTE_NOLOAD("TouchGFX_Framebuffer");
static uint16_t lcd_int_active_line;
static uint16_t lcd_int_porch_line;
}
void TouchGFXGeneratedHAL::initialize()
{
HAL::initialize();
registerEventListener(*(Application::getInstance()));
setFrameBufferStartAddresses((void*)frameBuf, (void*)0, (void*)0);
setFrameBufferStartAddresses((void*)0x24040000, (void*)0x24040000, (void*)0);
}
void TouchGFXGeneratedHAL::configureInterrupts()
{
NVIC_SetPriority(LTDC_IRQn, 9);
}
void TouchGFXGeneratedHAL::enableInterrupts()
{
NVIC_EnableIRQ(LTDC_IRQn);
}
void TouchGFXGeneratedHAL::disableInterrupts()
{
NVIC_DisableIRQ(LTDC_IRQn);
}
void TouchGFXGeneratedHAL::enableLCDControllerInterrupt()
{
lcd_int_active_line = (LTDC->BPCR & 0x7FF) - 1;
lcd_int_porch_line = (LTDC->AWCR & 0x7FF) - 1;
/* Sets the Line Interrupt position */
LTDC->LIPCR = lcd_int_active_line;
/* Line Interrupt Enable */
LTDC->IER |= LTDC_IER_LIE;
}
bool TouchGFXGeneratedHAL::beginFrame()
@ -66,21 +76,17 @@ void TouchGFXGeneratedHAL::endFrame()
HAL::endFrame();
}
inline uint8_t* TouchGFXGeneratedHAL::advanceFrameBufferToRect(uint8_t* fbPtr, const touchgfx::Rect& rect) const
{
// Advance vertically Advance horizontally
fbPtr += rect.y * lcd().framebufferStride() + rect.x * 2;
return fbPtr;
}
uint16_t* TouchGFXGeneratedHAL::getTFTFrameBuffer() const
{
return (uint16_t*)frameBuf;
return (uint16_t*)LTDC_Layer1->CFBAR;
}
void TouchGFXGeneratedHAL::setTFTFrameBuffer(uint16_t* adr)
{
//setTFTFrameBuffer() not used for selected display interface
LTDC_Layer1->CFBAR = (uint32_t)adr;
/* Reload immediate */
LTDC->SRCR = (uint32_t)LTDC_SRCR_IMR;
}
void TouchGFXGeneratedHAL::flushFrameBuffer(const touchgfx::Rect& rect)

View File

@ -156,24 +156,6 @@ public:
* Called when a rendering pass is completed.
*/
virtual void endFrame();
/**
*
* @fn inline uint8_t* TouchGFXGeneratedHAL::advanceFrameBufferToRect(uint8_t* fbPtr, const touchgfx::Rect& rect) const;
*
* @brief This function calculates the offset in the framebuffer address according to "rect" coordinates.
*
* This function is typically for users who need to transfer framebuffer data to
* a display from within flushFrameBuffer(Rect& rect). While HAL::lockFrameBuffer()
* returns a pointer to the current drawing framebuffer, users must manually calculate
* the offset from that pointer to the Rect to transfer. This function will advance the offset
* in the framebuffer equal to the rect's upper left corner (x, y).
*
*
* @param fbPtr Pointer to the start of the framebuffer, coordinates (0, 0)
* @param rect The area of the screen expressed in absolute coordinates, which has to be transformed to address.
*
*/
inline uint8_t* advanceFrameBufferToRect(uint8_t* fbPtr, const touchgfx::Rect& rect) const;
protected:
/**