diff --git a/drivers/CoreVideo/include/CGPixel.hpp b/drivers/CoreVideo/include/CGPixel.hpp index 44995d5ef5..bd8aeb425d 100644 --- a/drivers/CoreVideo/include/CGPixel.hpp +++ b/drivers/CoreVideo/include/CGPixel.hpp @@ -27,7 +27,7 @@ struct CGPixel { void draw(CGColor color) { uintptr_t destination_address = - lcd::frame_buffer_address + (4 * (coordinates.y * lcd::dimension.width + coordinates.x)); + lcd::frame_buffer_address + (4 * (coordinates.y * lcd::dimension::width + coordinates.x)); uint32_t destinationColor = color.getARGB(); corell.rawMemoryWrite(destination_address, destinationColor); diff --git a/drivers/CoreVideo/include/internal/corevideo_config.h b/drivers/CoreVideo/include/internal/corevideo_config.h index 5ccdcde2b9..8b0b7e5c7f 100644 --- a/drivers/CoreVideo/include/internal/corevideo_config.h +++ b/drivers/CoreVideo/include/internal/corevideo_config.h @@ -15,25 +15,29 @@ namespace lcd { // TODO : this should not depend on OTM driver, // TODO : it should be instanciated and passed to objects that need it - const struct { - uint16_t width = lcd::otm8009a::landscape::width; - uint16_t height = lcd::otm8009a::landscape::height; - } dimension; + namespace dimension { + + constexpr uint16_t width = lcd::otm8009a::landscape::width; + constexpr uint16_t height = lcd::otm8009a::landscape::height; + + } // namespace dimension // TODO : this should not depend on OTM driver, // TODO : it should be instanciated and passed to objects that need it - const struct { - uint16_t VSA = lcd::otm8009a::landscape::vsync; // Vertical start active time in units of lines - uint16_t VBP = lcd::otm8009a::landscape::vbp; // Vertical Back Porch time in units of lines - uint16_t VFP = lcd::otm8009a::landscape::vfp; // Vertical Front Porch time in units of lines - uint16_t VACT = lcd::otm8009a::landscape::height; // Vertical Active time in units of lines = imageSize Y in - // pixels to display - uint16_t HSA = lcd::otm8009a::landscape::hsync; // Horizontal start active time in units of lcdClk - uint16_t HBP = lcd::otm8009a::landscape::hbp; // Horizontal Back Porch time in units of lcdClk - uint16_t HFP = lcd::otm8009a::landscape::hfp; // Horizontal Front Porch time in units of lcdClk - uint16_t HACT = lcd::otm8009a::landscape::width; // Horizontal Active time in units of lcdClk = imageSize X in - // pixels to display - } property; + namespace property { + + constexpr uint16_t VSA = lcd::otm8009a::landscape::vsync; // Vertical start active time in units of lines + constexpr uint16_t VBP = lcd::otm8009a::landscape::vbp; // Vertical Back Porch time in units of lines + constexpr uint16_t VFP = lcd::otm8009a::landscape::vfp; // Vertical Front Porch time in units of lines + constexpr uint16_t VACT = lcd::otm8009a::landscape::height; // Vertical Active time in units of lines = + // imageSize Y in pixels to display + constexpr uint16_t HSA = lcd::otm8009a::landscape::hsync; // Horizontal start active time in units of lcdClk + constexpr uint16_t HBP = lcd::otm8009a::landscape::hbp; // Horizontal Back Porch time in units of lcdClk + constexpr uint16_t HFP = lcd::otm8009a::landscape::hfp; // Horizontal Front Porch time in units of lcdClk + constexpr uint16_t HACT = lcd::otm8009a::landscape::width; // Horizontal Active time in units of lcdClk = + // imageSize X in pixels to display + + } // namespace property } // namespace lcd diff --git a/drivers/CoreVideo/source/CoreDMA2D.cpp b/drivers/CoreVideo/source/CoreDMA2D.cpp index a3ccac58ef..ec086e2f7e 100644 --- a/drivers/CoreVideo/source/CoreDMA2D.cpp +++ b/drivers/CoreVideo/source/CoreDMA2D.cpp @@ -78,7 +78,7 @@ auto CoreDMA2D::getHandle() -> DMA2D_HandleTypeDef void CoreDMA2D::transferDrawing(uintptr_t first_pixel_address, uint32_t width, uint32_t height, uint32_t color) { _hdma2d.Init.Mode = DMA2D_R2M; - _hdma2d.Init.OutputOffset = lcd::dimension.width - width; + _hdma2d.Init.OutputOffset = lcd::dimension::width - width; transferData(color, first_pixel_address, width, height); } diff --git a/drivers/CoreVideo/source/CoreDSI.cpp b/drivers/CoreVideo/source/CoreDSI.cpp index bc08565b79..a155142f9a 100644 --- a/drivers/CoreVideo/source/CoreDSI.cpp +++ b/drivers/CoreVideo/source/CoreDSI.cpp @@ -30,16 +30,16 @@ CoreDSI::CoreDSI(LKCoreSTM32HalBase &hal) : _hal(hal) _config.Mode = DSI_VID_MODE_BURST; // Mode Video burst ie : one LgP per line _config.NullPacketSize = 0xFFF; _config.NumberOfChunks = 0; - _config.PacketSize = lcd::property.HACT; // Value depending on display orientation choice portrait/landscape - _config.HorizontalSyncActive = (lcd::property.HSA * dsi::laneByteClock_kHz) / dsi::lcdClock; - _config.HorizontalBackPorch = (lcd::property.HBP * dsi::laneByteClock_kHz) / dsi::lcdClock; - _config.HorizontalLine = - ((lcd::property.HACT + lcd::property.HSA + lcd::property.HBP + lcd::property.HFP) * dsi::laneByteClock_kHz) / - dsi::lcdClock; // Value depending on display orientation choice portrait/landscape - _config.VerticalSyncActive = lcd::property.VSA; - _config.VerticalBackPorch = lcd::property.VBP; - _config.VerticalFrontPorch = lcd::property.VFP; - _config.VerticalActive = lcd::property.VACT; // Value depending on display orientation choice portrait/landscape + _config.PacketSize = lcd::property::HACT; // Value depending on display orientation choice portrait/landscape + _config.HorizontalSyncActive = (lcd::property::HSA * dsi::laneByteClock_kHz) / dsi::lcdClock; + _config.HorizontalBackPorch = (lcd::property::HBP * dsi::laneByteClock_kHz) / dsi::lcdClock; + _config.HorizontalLine = ((lcd::property::HACT + lcd::property::HSA + lcd::property::HBP + lcd::property::HFP) * + dsi::laneByteClock_kHz) / + dsi::lcdClock; // Value depending on display orientation choice portrait/landscape + _config.VerticalSyncActive = lcd::property::VSA; + _config.VerticalBackPorch = lcd::property::VBP; + _config.VerticalFrontPorch = lcd::property::VFP; + _config.VerticalActive = lcd::property::VACT; // Value depending on display orientation choice portrait/landscape // Enable or disable sending LP command while streaming is active in video mode _config.LPCommandEnable = DSI_LP_COMMAND_ENABLE; // Enable sending commands in mode LP (Low Power) diff --git a/drivers/CoreVideo/source/CoreFont.cpp b/drivers/CoreVideo/source/CoreFont.cpp index 3da0192b57..0e36844288 100644 --- a/drivers/CoreVideo/source/CoreFont.cpp +++ b/drivers/CoreVideo/source/CoreFont.cpp @@ -80,11 +80,11 @@ void CoreFont::display(const char *text, uint32_t size, uint32_t starting_line, character.origin.x += graphics::font_pixel_width; } - if ((character.origin.x + graphics::font_pixel_width) > lcd::dimension.width) { + if ((character.origin.x + graphics::font_pixel_width) > lcd::dimension::width) { character.origin.y += graphics::font_pixel_height; character.origin.x = 0; } - if ((character.origin.y + graphics::font_pixel_height) > lcd::dimension.height) { + if ((character.origin.y + graphics::font_pixel_height) > lcd::dimension::height) { return; } } diff --git a/drivers/CoreVideo/source/CoreGraphics.cpp b/drivers/CoreVideo/source/CoreGraphics.cpp index 90c3b05944..25d3a89360 100644 --- a/drivers/CoreVideo/source/CoreGraphics.cpp +++ b/drivers/CoreVideo/source/CoreGraphics.cpp @@ -11,8 +11,8 @@ CoreGraphics::CoreGraphics(interface::DMA2DBase &dma2d) : _dma2d(dma2d) {} void CoreGraphics::clearScreen(CGColor color) { FilledRectangle rect; - rect.width = lcd::dimension.width; - rect.height = lcd::dimension.height; + rect.width = lcd::dimension::width; + rect.height = lcd::dimension::height; drawRectangle(rect, color); } @@ -20,7 +20,7 @@ void CoreGraphics::clearScreen(CGColor color) void CoreGraphics::drawRectangle(FilledRectangle rectangle, CGColor color) { uintptr_t destination_address = - lcd::frame_buffer_address + 4 * (lcd::dimension.width * rectangle.origin.y + rectangle.origin.x); + lcd::frame_buffer_address + 4 * (lcd::dimension::width * rectangle.origin.y + rectangle.origin.x); uint32_t destinationColor = color.getARGB(); diff --git a/drivers/CoreVideo/source/CoreLTDC.cpp b/drivers/CoreVideo/source/CoreLTDC.cpp index d1c78cb705..3b592b9740 100644 --- a/drivers/CoreVideo/source/CoreLTDC.cpp +++ b/drivers/CoreVideo/source/CoreLTDC.cpp @@ -13,14 +13,14 @@ CoreLTDC::CoreLTDC(LKCoreSTM32HalBase &hal, interface::DSIBase &dsi) : _hal(hal) _hltdc.Instance = LTDC; // LCD pixel width/height - _hltdc.LayerCfg->ImageWidth = lcd::dimension.width; - _hltdc.LayerCfg->ImageHeight = lcd::dimension.height; + _hltdc.LayerCfg->ImageWidth = lcd::dimension::width; + _hltdc.LayerCfg->ImageHeight = lcd::dimension::height; // Timing and synchronization - _hltdc.Init.HorizontalSync = (lcd::property.HSA - 1); - _hltdc.Init.AccumulatedHBP = (lcd::property.HSA + lcd::property.HBP - 1); - _hltdc.Init.AccumulatedActiveW = (lcd::dimension.width + lcd::property.HSA + lcd::property.HBP - 1); - _hltdc.Init.TotalWidth = (lcd::dimension.width + lcd::property.HSA + lcd::property.HBP + lcd::property.HFP - 1); + _hltdc.Init.HorizontalSync = (lcd::property::HSA - 1); + _hltdc.Init.AccumulatedHBP = (lcd::property::HSA + lcd::property::HBP - 1); + _hltdc.Init.AccumulatedActiveW = (lcd::dimension::width + lcd::property::HSA + lcd::property::HBP - 1); + _hltdc.Init.TotalWidth = (lcd::dimension::width + lcd::property::HSA + lcd::property::HBP + lcd::property::HFP - 1); // Background values _hltdc.Init.Backcolor.Blue = 0; @@ -32,9 +32,9 @@ CoreLTDC::CoreLTDC(LKCoreSTM32HalBase &hal, interface::DSIBase &dsi) : _hal(hal) // Layer config _layerConfig.WindowX0 = 0; - _layerConfig.WindowX1 = lcd::dimension.width; + _layerConfig.WindowX1 = lcd::dimension::width; _layerConfig.WindowY0 = 0; - _layerConfig.WindowY1 = lcd::dimension.height; + _layerConfig.WindowY1 = lcd::dimension::height; _layerConfig.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; @@ -50,8 +50,8 @@ CoreLTDC::CoreLTDC(LKCoreSTM32HalBase &hal, interface::DSIBase &dsi) : _hal(hal) _layerConfig.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; _layerConfig.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; - _layerConfig.ImageWidth = lcd::dimension.width; - _layerConfig.ImageHeight = lcd::dimension.height; + _layerConfig.ImageWidth = lcd::dimension::width; + _layerConfig.ImageHeight = lcd::dimension::height; } void CoreLTDC::initialize() diff --git a/drivers/CoreVideo/tests/CGPixel_test.cpp b/drivers/CoreVideo/tests/CGPixel_test.cpp index 5560f5d04b..250f0c6d66 100644 --- a/drivers/CoreVideo/tests/CGPixel_test.cpp +++ b/drivers/CoreVideo/tests/CGPixel_test.cpp @@ -18,7 +18,7 @@ TEST(CGPixelTest, draw) CGColor color = CGColor::magenta; uintptr_t expected_address = - lcd::frame_buffer_address + (4 * (pixel.coordinates.y * lcd::dimension.width + pixel.coordinates.x)); + lcd::frame_buffer_address + (4 * (pixel.coordinates.y * lcd::dimension::width + pixel.coordinates.x)); auto expected_data = color.getARGB(); EXPECT_CALL(llmock, rawMemoryWrite(expected_address, expected_data)); diff --git a/drivers/CoreVideo/tests/CoreDSI_test.cpp b/drivers/CoreVideo/tests/CoreDSI_test.cpp index 1b238564a1..f7f6acf327 100644 --- a/drivers/CoreVideo/tests/CoreDSI_test.cpp +++ b/drivers/CoreVideo/tests/CoreDSI_test.cpp @@ -56,18 +56,18 @@ TEST_F(CoreDSITest, handleConfigurationVideoConfigGeneral) ASSERT_EQ(config.Mode, DSI_VID_MODE_BURST); ASSERT_EQ(config.NullPacketSize, 0xFFF); ASSERT_EQ(config.NumberOfChunks, 0); - ASSERT_EQ(config.PacketSize, lcd::property.HACT); + ASSERT_EQ(config.PacketSize, lcd::property::HACT); } TEST_F(CoreDSITest, handleConfigurationVideoConfigHorizontal) { auto config = coredsi.getConfig(); - auto horizontalSyncActive = (lcd::property.HSA * dsi::laneByteClock_kHz) / dsi::lcdClock; - auto horizontalBackPorch = (lcd::property.HBP * dsi::laneByteClock_kHz) / dsi::lcdClock; - auto horizontalLine = - ((lcd::property.HACT + lcd::property.HSA + lcd::property.HBP + lcd::property.HFP) * dsi::laneByteClock_kHz) / - dsi::lcdClock; + auto horizontalSyncActive = (lcd::property::HSA * dsi::laneByteClock_kHz) / dsi::lcdClock; + auto horizontalBackPorch = (lcd::property::HBP * dsi::laneByteClock_kHz) / dsi::lcdClock; + auto horizontalLine = ((lcd::property::HACT + lcd::property::HSA + lcd::property::HBP + lcd::property::HFP) * + dsi::laneByteClock_kHz) / + dsi::lcdClock; ASSERT_EQ(config.HorizontalSyncActive, horizontalSyncActive); ASSERT_EQ(config.HorizontalBackPorch, horizontalBackPorch); @@ -78,10 +78,10 @@ TEST_F(CoreDSITest, handleConfigurationVideoConfigVertical) { auto config = coredsi.getConfig(); - ASSERT_EQ(config.VerticalSyncActive, lcd::property.VSA); - ASSERT_EQ(config.VerticalBackPorch, lcd::property.VBP); - ASSERT_EQ(config.VerticalFrontPorch, lcd::property.VFP); - ASSERT_EQ(config.VerticalActive, lcd::property.VACT); + ASSERT_EQ(config.VerticalSyncActive, lcd::property::VSA); + ASSERT_EQ(config.VerticalBackPorch, lcd::property::VBP); + ASSERT_EQ(config.VerticalFrontPorch, lcd::property::VFP); + ASSERT_EQ(config.VerticalActive, lcd::property::VACT); } TEST_F(CoreDSITest, handleConfigurationVideoConfigLowPower) diff --git a/drivers/CoreVideo/tests/CoreFont_test.cpp b/drivers/CoreVideo/tests/CoreFont_test.cpp index f60d80970f..76986a2cf5 100644 --- a/drivers/CoreVideo/tests/CoreFont_test.cpp +++ b/drivers/CoreVideo/tests/CoreFont_test.cpp @@ -267,7 +267,7 @@ TEST_F(CoreFontTest, displayWithScreenWidthReached) sprintf(buff, "This sentence is supposed to be on multiple lines because it is too long to be displayed on " "only one line of the screen."); - uint8_t max_char_per_line = lcd::dimension.width / graphics::font_pixel_width; + uint8_t max_char_per_line = lcd::dimension::width / graphics::font_pixel_width; ASSERT_GT(text_length, max_char_per_line); // Text to display MUST exceed 47 characters for this test auto starting_line = 1; @@ -297,7 +297,7 @@ TEST_F(CoreFontTest, displayWithScreenHeightReached) auto starting_line = 20; - auto expected_last_pixel_y_position = lcd::dimension.height; + auto expected_last_pixel_y_position = lcd::dimension::height; // TODO: This EXPECT_CALL suppress the GMOCK WARNING: Uninteresting mock function call. Remove it in the future EXPECT_CALL(llmock, rawMemoryWrite).Times(AnyNumber()); diff --git a/drivers/CoreVideo/tests/CoreGraphics_test.cpp b/drivers/CoreVideo/tests/CoreGraphics_test.cpp index 7946df9baf..92e32df981 100644 --- a/drivers/CoreVideo/tests/CoreGraphics_test.cpp +++ b/drivers/CoreVideo/tests/CoreGraphics_test.cpp @@ -46,7 +46,7 @@ TEST_F(CoreGraphicsTest, drawRectangle) rectangle.height = rectangle_height; uintptr_t expected_address = - lcd::frame_buffer_address + n_channel * (lcd::dimension.width * starting_pixel_line + starting_pixel_column); + lcd::frame_buffer_address + n_channel * (lcd::dimension::width * starting_pixel_line + starting_pixel_column); EXPECT_CALL(dma2dmock, transferDrawing(expected_address, rectangle_width, rectangle_height, expected_color.getARGB())) @@ -60,7 +60,7 @@ TEST_F(CoreGraphicsTest, clearScreenDefaultColor) uintptr_t expected_address = lcd::frame_buffer_address + 0; auto expected_color = CGColor::white; - EXPECT_CALL(dma2dmock, transferDrawing(expected_address, lcd::dimension.width, lcd::dimension.height, + EXPECT_CALL(dma2dmock, transferDrawing(expected_address, lcd::dimension::width, lcd::dimension::height, expected_color.getARGB())) .Times(1); @@ -72,7 +72,7 @@ TEST_F(CoreGraphicsTest, clearScreenOtherColor) uintptr_t expected_address = lcd::frame_buffer_address + 0; auto expected_color = CGColor::magenta; - EXPECT_CALL(dma2dmock, transferDrawing(expected_address, lcd::dimension.width, lcd::dimension.height, + EXPECT_CALL(dma2dmock, transferDrawing(expected_address, lcd::dimension::width, lcd::dimension::height, expected_color.getARGB())) .Times(1); diff --git a/drivers/CoreVideo/tests/CoreLTDC_test.cpp b/drivers/CoreVideo/tests/CoreLTDC_test.cpp index f2e5ecaf25..2e78ff6bb9 100644 --- a/drivers/CoreVideo/tests/CoreLTDC_test.cpp +++ b/drivers/CoreVideo/tests/CoreLTDC_test.cpp @@ -45,18 +45,18 @@ TEST_F(CoreLTDCTest, handleConfigurationLayerCfg) { auto handle = coreltdc.getHandle(); - ASSERT_EQ(handle.LayerCfg->ImageWidth, lcd::dimension.width); - ASSERT_EQ(handle.LayerCfg->ImageHeight, lcd::dimension.height); + ASSERT_EQ(handle.LayerCfg->ImageWidth, lcd::dimension::width); + ASSERT_EQ(handle.LayerCfg->ImageHeight, lcd::dimension::height); } TEST_F(CoreLTDCTest, handleConfigurationSetupTimingConfig) { auto handle = coreltdc.getHandle(); - auto horizontal_sync = (lcd::property.HSA - 1); - auto accumulated_HBP = (lcd::property.HSA + lcd::property.HBP - 1); - auto accumulated_activeW = (lcd::dimension.width + lcd::property.HSA + lcd::property.HBP - 1); - auto total_width = (lcd::dimension.width + lcd::property.HSA + lcd::property.HBP + lcd::property.HFP - 1); + auto horizontal_sync = (lcd::property::HSA - 1); + auto accumulated_HBP = (lcd::property::HSA + lcd::property::HBP - 1); + auto accumulated_activeW = (lcd::dimension::width + lcd::property::HSA + lcd::property::HBP - 1); + auto total_width = (lcd::dimension::width + lcd::property::HSA + lcd::property::HBP + lcd::property::HFP - 1); ASSERT_EQ(handle.Init.HorizontalSync, horizontal_sync); ASSERT_EQ(handle.Init.AccumulatedHBP, accumulated_HBP); @@ -79,9 +79,9 @@ TEST_F(CoreLTDCTest, setupLayerConfig) auto layer_config = coreltdc.getLayerConfig(); ASSERT_EQ(layer_config.WindowX0, 0); - ASSERT_EQ(layer_config.WindowX1, lcd::dimension.width); + ASSERT_EQ(layer_config.WindowX1, lcd::dimension::width); ASSERT_EQ(layer_config.WindowY0, 0); - ASSERT_EQ(layer_config.WindowY1, lcd::dimension.height); + ASSERT_EQ(layer_config.WindowY1, lcd::dimension::height); ASSERT_EQ(layer_config.PixelFormat, LTDC_PIXEL_FORMAT_ARGB8888); @@ -97,8 +97,8 @@ TEST_F(CoreLTDCTest, setupLayerConfig) ASSERT_EQ(layer_config.BlendingFactor1, LTDC_BLENDING_FACTOR1_PAxCA); ASSERT_EQ(layer_config.BlendingFactor2, LTDC_BLENDING_FACTOR2_PAxCA); - ASSERT_EQ(layer_config.ImageWidth, lcd::dimension.width); - ASSERT_EQ(layer_config.ImageHeight, lcd::dimension.height); + ASSERT_EQ(layer_config.ImageWidth, lcd::dimension::width); + ASSERT_EQ(layer_config.ImageHeight, lcd::dimension::height); } MATCHER_P(WithStructEqualTo, expected, "Compare RCC_PeriphCLKInitTypeDef") diff --git a/libs/LKAnimationKit/source/BouncingSquare.cpp b/libs/LKAnimationKit/source/BouncingSquare.cpp index 40b5dcd4d8..1a2821a6a9 100644 --- a/libs/LKAnimationKit/source/BouncingSquare.cpp +++ b/libs/LKAnimationKit/source/BouncingSquare.cpp @@ -44,7 +44,7 @@ auto BouncingSquare::squareWillBeOutOfBoundHorizontal() const -> bool if (_square.origin.x + _shift.horizontal <= 0) { return true; } - if (_square.origin.x + _square.width + _shift.horizontal > static_cast(lcd::dimension.width - 1)) { + if (_square.origin.x + _square.width + _shift.horizontal > static_cast(lcd::dimension::width - 1)) { return true; } return false; @@ -55,7 +55,7 @@ auto BouncingSquare::squareWillBeOutOfBoundVertical() const -> bool if (_square.origin.y + _shift.vertical <= 0) { return true; } - if (_square.origin.y + _square.height + _shift.vertical > static_cast(lcd::dimension.height - 1)) { + if (_square.origin.y + _square.height + _shift.vertical > static_cast(lcd::dimension::height - 1)) { return true; } return false;