Skip to content

Commit

Permalink
♻️ (video): Set CGGraphics with CGColor+CGPoint+CGPixel+Character+Fil…
Browse files Browse the repository at this point in the history
…ledRectangle
  • Loading branch information
YannLocatelli committed Jan 27, 2023
1 parent a78c489 commit 83a6249
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 88 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Leka - LekaOS
// Copyright 2021 APF France handicap
// Copyright 2023 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <cstdint>

#include "CoreLL.h"
#include "internal/corevideo_config.h"

namespace leka {

struct CGColor {
Expand Down Expand Up @@ -37,4 +40,36 @@ constexpr CGColor CGColor::yellow {0xFF, 0xFF, 0x00};
constexpr CGColor CGColor::cyan {0x00, 0xFF, 0xFF};
constexpr CGColor CGColor::magenta {0xFF, 0x00, 0xFF};

struct CGPoint {
uint32_t x = 0;
uint32_t y = 0;
};

struct CGPixel {
explicit CGPixel(CoreLL &ll) : corell(ll) {}

CGPoint coordinates {0, 0};
CoreLL &corell;

void draw(CGColor color)
{
uintptr_t destination_address =
lcd::frame_buffer_address + (4 * (coordinates.y * lcd::dimension::width + coordinates.x));
uint32_t destinationColor = color.getARGB();

corell.rawMemoryWrite(destination_address, destinationColor);
}
};

struct Character {
CGPoint origin {}; // Top left corner by convention
uint8_t ascii {}; // From 0x20 to 0x7F
};

struct FilledRectangle {
CGPoint origin {0, 0}; // * Top left corner by convention
uint16_t width {};
uint16_t height {};
};

} // namespace leka
36 changes: 0 additions & 36 deletions drivers/CoreVideo/include/CGPixel.hpp

This file was deleted.

18 changes: 0 additions & 18 deletions drivers/CoreVideo/include/Character.hpp

This file was deleted.

4 changes: 1 addition & 3 deletions drivers/CoreVideo/include/CoreFont.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

#pragma once

#include "CGColor.hpp"
#include "CGPixel.hpp"
#include "Character.hpp"
#include "CGGraphics.hpp"
#include "interface/Font.hpp"

namespace leka {
Expand Down
3 changes: 1 addition & 2 deletions drivers/CoreVideo/include/CoreGraphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

#pragma once

#include "CGColor.hpp"
#include "CGGraphics.hpp"
#include "CoreLL.h"
#include "FilledRectangle.hpp"
#include "interface/DMA2D.hpp"
#include "interface/Graphics.hpp"
#include "internal/corevideo_config.h"
Expand Down
2 changes: 1 addition & 1 deletion drivers/CoreVideo/include/CoreVideo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include "FilledRectangle.hpp"
#include "CGGraphics.hpp"
#include "interface/DMA2D.hpp"
#include "interface/DSI.hpp"
#include "interface/Font.hpp"
Expand Down
19 changes: 0 additions & 19 deletions drivers/CoreVideo/include/FilledRectangle.hpp

This file was deleted.

3 changes: 1 addition & 2 deletions drivers/CoreVideo/tests/CGColor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Copyright 2021 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#include "CGColor.hpp"

#include "CGGraphics.hpp"
#include "gtest/gtest.h"

using namespace leka;
Expand Down
3 changes: 1 addition & 2 deletions drivers/CoreVideo/tests/CGPixel_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Copyright 2021 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#include "CGPixel.hpp"

#include "CGGraphics.hpp"
#include "gtest/gtest.h"
#include "mocks/leka/CoreLL.h"

Expand Down
1 change: 0 additions & 1 deletion drivers/CoreVideo/tests/CoreFont_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "CoreFont.hpp"

#include "CGFont.hpp"
#include "Character.hpp"
#include "gtest/gtest.h"
#include "internal/corevideo_config.h"
#include "mocks/leka/CoreLL.h"
Expand Down
1 change: 0 additions & 1 deletion drivers/CoreVideo/tests/CoreVideo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "CoreVideo.hpp"

#include "Character.hpp"
#include "gtest/gtest.h"
#include "mocks/leka/CoreDMA2D.h"
#include "mocks/leka/CoreDSI.h"
Expand Down
2 changes: 1 addition & 1 deletion libs/UIAnimationKit/include/internal/BouncingSquare.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <cstdint>

#include "CGAnimation.h"
#include "FilledRectangle.hpp"
#include "CGGraphics.hpp"
#include "interface/Graphics.hpp"

namespace leka::animation {
Expand Down
2 changes: 1 addition & 1 deletion spikes/lk_reinforcer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "drivers/HighResClock.h"
#include "rtos/ThisThread.h"

#include "CGPixel.hpp"
#include "CGGraphics.hpp"
#include "CoreAccelerometer.h"
#include "CoreDMA2D.hpp"
#include "CoreDSI.hpp"
Expand Down

0 comments on commit 83a6249

Please sign in to comment.