From a8c384ea9c99ab49497a6b9725cd125dcba7751f Mon Sep 17 00:00:00 2001 From: Benjamin <88098139+Bexin3@users.noreply.github.com> Date: Mon, 8 Jan 2024 15:38:02 +0100 Subject: [PATCH] Delete SpeeduinoGL directory --- SpeeduinoGL/LICENSE.md | 1 - SpeeduinoGL/README.md | 3 - .../examples/FillCircle/FillCircle.ino | 44 ----- .../RotatingSquare/RotatingSquare.ino | 51 ----- SpeeduinoGL/library.properties | 10 - SpeeduinoGL/src/SpeeduinoGL.cpp | 176 ------------------ SpeeduinoGL/src/SpeeduinoGL.h | 32 ---- 7 files changed, 317 deletions(-) delete mode 100644 SpeeduinoGL/LICENSE.md delete mode 100644 SpeeduinoGL/README.md delete mode 100644 SpeeduinoGL/examples/FillCircle/FillCircle.ino delete mode 100644 SpeeduinoGL/examples/RotatingSquare/RotatingSquare.ino delete mode 100644 SpeeduinoGL/library.properties delete mode 100644 SpeeduinoGL/src/SpeeduinoGL.cpp delete mode 100644 SpeeduinoGL/src/SpeeduinoGL.h diff --git a/SpeeduinoGL/LICENSE.md b/SpeeduinoGL/LICENSE.md deleted file mode 100644 index 265fcfd..0000000 --- a/SpeeduinoGL/LICENSE.md +++ /dev/null @@ -1 +0,0 @@ -Creative Commons Licence
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. diff --git a/SpeeduinoGL/README.md b/SpeeduinoGL/README.md deleted file mode 100644 index c59141d..0000000 --- a/SpeeduinoGL/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# SpeeduinoGL -A work in progress library with basic graphical functions optimised for arm cortex m7. -Tested on GIGA R1, with rasterization writing to registers between two lines, and basic shapes (triangle, rectangle).Support for processing arrays instead of pixels one by one, and boundary checking are under progress. diff --git a/SpeeduinoGL/examples/FillCircle/FillCircle.ino b/SpeeduinoGL/examples/FillCircle/FillCircle.ino deleted file mode 100644 index 11e4a38..0000000 --- a/SpeeduinoGL/examples/FillCircle/FillCircle.ino +++ /dev/null @@ -1,44 +0,0 @@ -#include "SpeeduinoGL.h" -#include "Arduino_H7_Video.h" -#include "dsi.h" -#include "SDRAM.h" - -uint16_t* FrameBuffer = (uint16_t*)SDRAM_START_ADDRESS; -const int ResV = 480; - -Rectangle sq1 = { - { 0, 0 }, - { 0, 480 }, - { 800, 0 }, - { 800, 480 } -}; - -Point centre = {400, 240}; - -// The buffer used to rotate and resize the frame -Arduino_H7_Video Display(800, 480, GigaDisplayShield); - -void setup() { - SDRAM.begin(); - Display.begin(); - - dsi_lcdClear(0); - dsi_drawCurrentFrameBuffer(); - dsi_lcdClear(0); - dsi_drawCurrentFrameBuffer(); - - ConfigBuffer(SDRAM_START_ADDRESS, ResV); - FillRectangle(sq1, 0x00FF); -} - -void loop() { - - int32_t t1 = micros(); - // FillRectangle(sq1, 0x00FF); - FillCircle(100, 0x0FFF, centre); - Serial.println(micros() - t1); - - dsi_lcdDrawImage((void*)FrameBuffer, (void*)dsi_getCurrentFrameBuffer(), 480, 800, DMA2D_INPUT_RGB565); - dsi_drawCurrentFrameBuffer(); -} - diff --git a/SpeeduinoGL/examples/RotatingSquare/RotatingSquare.ino b/SpeeduinoGL/examples/RotatingSquare/RotatingSquare.ino deleted file mode 100644 index e1eb780..0000000 --- a/SpeeduinoGL/examples/RotatingSquare/RotatingSquare.ino +++ /dev/null @@ -1,51 +0,0 @@ -#include "SpeeduinoGL.h" -#include "Arduino_H7_Video.h" -#include "dsi.h" -#include "SDRAM.h" - -uint16_t* FrameBuffer = (uint16_t*)SDRAM_START_ADDRESS; -const int ResV = 480; - -Rectangle sq1 = { - {0, 0}, - {0, 480}, - {800, 0}, - {800, 480} -}; - -float angle = 0; - -// The buffer used to rotate and resize the frame -Arduino_H7_Video Display(800, 480, GigaDisplayShield); - -void setup() { - SDRAM.begin(); - Display.begin(); - - dsi_lcdClear(0); - dsi_drawCurrentFrameBuffer(); - dsi_lcdClear(0); - dsi_drawCurrentFrameBuffer(); - - ConfigBuffer(SDRAM_START_ADDRESS, ResV); -} - -void loop() { - FillRectangle(sq1, 0x0986); - - angle += 0.01; - - sq1 = { - {400 + 150 * (-cos(angle) + sin(angle)), 240 + 150 * (cos(angle) + sin(angle)) }, - {400 + 150 * (-cos(angle) - sin(angle)), 240 + 150 * (-cos(angle) + sin(angle)) }, - {400 + 150 * (cos(angle) - sin(angle)), 240 + 150 * (-cos(angle) - sin(angle)) }, - {400 + 150 * (cos(angle) + sin(angle)), 240 + 150 * (cos(angle) - sin(angle)) } - }; - - int32_t t1 = micros(); - FillRectangle(sq1, 0x00FF); - Serial.println(micros() - t1); - - dsi_lcdDrawImage((void *)FrameBuffer, (void *)dsi_getCurrentFrameBuffer(), 480, 800, DMA2D_INPUT_RGB565); - dsi_drawCurrentFrameBuffer(); -} diff --git a/SpeeduinoGL/library.properties b/SpeeduinoGL/library.properties deleted file mode 100644 index 3ac0d8a..0000000 --- a/SpeeduinoGL/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=SpeeduinoGL -version=0.0.1 -author=Benjamin Gombala -maintainer=Benjamin Gombala benjamin.gombala@gmail.com Bexin -sentence=A library with basic graphical functions optimised for arm cortex m7. -paragraph=Cortex-M7 graphical library -category=Display -url=https://github.com/Bexin3/SpeeduinoGL -architectures=* -includes=SpeeduinoGL.h diff --git a/SpeeduinoGL/src/SpeeduinoGL.cpp b/SpeeduinoGL/src/SpeeduinoGL.cpp deleted file mode 100644 index cadb246..0000000 --- a/SpeeduinoGL/src/SpeeduinoGL.cpp +++ /dev/null @@ -1,176 +0,0 @@ -#include "SpeeduinoGL.h" -#include - -uint32_t ImageAddress = 0x60000000; -uint32_t ResV = 480; -uint32_t ResH = 800; - - - void ConfigBuffer(uint32_t Address, uint32_t ResolutionV, uint32_t ResolutionH) { - ResV = ResolutionV; - ImageAddress = Address; - ResH = ResolutionH; - } - - void FillTriangle(Triangle triangle, uint16_t Colour) { - // Sort points based on x-coordinates - std::sort(&triangle.A, &triangle.C + 1, - [](const Point &a, const Point &b) { - return a.w < b.w; - } - ); - - float gradAC = (triangle.A.h - triangle.C.h) / (triangle.A.w - triangle.C.w); - float gradAB = (triangle.A.h - triangle.B.h) / (triangle.A.w - triangle.B.w); - float gradBC = (triangle.B.h - triangle.C.h) / (triangle.B.w - triangle.C.w); - - bool Polarized = gradAB > gradAC; - - PolarizedTwoLineRasterizer(ceil(triangle.A.w), ceil(triangle.B.w), - triangle.A.h + gradAC * (ceil(triangle.A.w) - triangle.A.w), - triangle.A.h + gradAB * (ceil(triangle.A.w) - triangle.A.w), - gradAB, gradAC, Colour, Polarized); - - PolarizedTwoLineRasterizer(ceil(triangle.B.w), ceil(triangle.C.w), - triangle.A.h + gradAC * (ceil(triangle.B.w) - triangle.A.w), - triangle.B.h + gradBC * (ceil(triangle.B.w) - triangle.B.w), - gradBC, gradAC, Colour, Polarized); - } - - void FillRectangle(Rectangle rectangle, uint16_t Colour) { - // Sort points based on x-coordinates - std::sort(&rectangle.A, &rectangle.C + 1, - [](const Point &a, const Point &b) { - return a.w < b.w; - } - ); - - bool switched = false; - bool Polarized = false; - - float gradAC = (rectangle.C.h - rectangle.A.h) / (rectangle.C.w - rectangle.A.w); - float gradAD = (rectangle.D.h - rectangle.A.h) / (rectangle.D.w - rectangle.A.w); - float gradAB = (rectangle.B.h - rectangle.A.h) / (rectangle.B.w - rectangle.A.w); - - if (gradAD > gradAB) { - if (gradAC > gradAD) { - std::swap(rectangle.C, rectangle.D); - std::swap(gradAC, gradAD); - switched = true; - } - } else { - if (gradAC < gradAD) { - std::swap(rectangle.C, rectangle.D); - std::swap(gradAC, gradAD); - switched = true; - } - } - - float gradBC = (rectangle.C.h - rectangle.B.h) / (rectangle.C.w - rectangle.B.w); - float gradDC = (rectangle.C.h - rectangle.D.h) / (rectangle.C.w - rectangle.D.w); - - Polarized = gradAB > gradAD; - - PolarizedTwoLineRasterizer(ceil(rectangle.A.w), ceil(rectangle.B.w), - rectangle.A.h + gradAD * (ceil(rectangle.A.w) - rectangle.A.w), - rectangle.A.h + gradAB * (ceil(rectangle.A.w) - rectangle.A.w), - gradAB, gradAD, Colour, Polarized); - - if (switched) { - PolarizedTwoLineRasterizer(ceil(rectangle.B.w), ceil(rectangle.C.w), - rectangle.A.h + gradAD * (ceil(rectangle.B.w) - rectangle.A.w), - rectangle.B.h + gradBC * (ceil(rectangle.B.w) - rectangle.B.w), - gradBC, gradAD, Colour, Polarized); - - PolarizedTwoLineRasterizer(ceil(rectangle.C.w), ceil(rectangle.D.w), - rectangle.A.h + gradAD * (ceil(rectangle.C.w) - rectangle.A.w), - rectangle.C.h + gradDC * (ceil(rectangle.C.w) - rectangle.C.w), - gradDC, gradAD, Colour, Polarized); - } else { - PolarizedTwoLineRasterizer(ceil(rectangle.B.w), ceil(rectangle.D.w), - rectangle.A.h + gradAD * (ceil(rectangle.B.w) - rectangle.A.w), - rectangle.B.h + gradBC * (ceil(rectangle.B.w) - rectangle.B.w), - gradBC, gradAD, Colour, Polarized); - - PolarizedTwoLineRasterizer(ceil(rectangle.D.w), ceil(rectangle.C.w), - rectangle.D.h + gradDC * (ceil(rectangle.D.w) - rectangle.D.w), - rectangle.B.h + gradBC * (ceil(rectangle.D.w) - rectangle.B.w), - gradBC, gradDC, Colour, Polarized); - } - } - - void PolarizedTwoLineRasterizer(int32_t CellStartX, int32_t CellEndX, float PointerCoordinateH, float PointerEndH, float Gradient1, float Gradient2, uint16_t Colour, bool Polarity) { - if (Polarity) { - TwoLineRasterizer(CellStartX, CellEndX, PointerCoordinateH, PointerEndH, Gradient1, Gradient2, Colour); - } else { - TwoLineRasterizer(CellStartX, CellEndX, PointerEndH, PointerCoordinateH, Gradient2, Gradient1, Colour); - } - } - - - void TwoLineRasterizer(int32_t CellStartX, int32_t CellEndX, float PointerCoordinateH, float PointerEndH, float Gradient1, float Gradient2, uint16_t Colour) { - uint16_t* ImageBuffer = (uint16_t*)ImageAddress; - - if (CellStartX < 0) { - PointerCoordinateH -= Gradient2 * CellStartX; - PointerEndH -= Gradient1 * CellStartX; - } - - if (CellEndX > ResH) { - CellEndX = ResH; - } - - for (uint32_t CurrentW = CellStartX; CellEndX > CurrentW; CurrentW++) { - uint32_t PointerCoorInt = ceil(PointerCoordinateH); - uint32_t PointerEndInt = ceil(PointerEndH); - - if (PointerEndInt > ResV) { - PointerEndInt = ResV; - } - - for (int32_t CurrentH = PointerCoorInt; PointerEndInt > CurrentH; CurrentH++) { - ImageBuffer[ResV * (CurrentW) + (CurrentH)] = Colour; - } - - PointerCoordinateH += Gradient2; - PointerEndH += Gradient1; - } - } - - void FillCircle(float Radius, uint16_t Colour, Point Centre) { - uint16_t* ImageBuffer = (uint16_t*)ImageAddress; - - float RadiusTo2 = pow(Radius, 2); - - uint32_t CellEndX = ceil(Centre.w+Radius); - - if (CellEndX > ResH) { - CellEndX = ResH; - }; - - uint32_t CellStartX = ceil(Centre.w-Radius); - float RadiusPos = CellStartX-(Centre.w); - - - for (uint32_t CurrentW = CellStartX; CellEndX > CurrentW; CurrentW++) { - - - float height = sqrt(RadiusTo2 - pow(RadiusPos, 2)); - uint16_t PointerCoorInt = floor(Centre.h - height + 1); - uint16_t PointerEndInt = ceil(Centre.h + height); - - - - if (PointerEndInt > ResV) { - PointerEndInt = ResV; - } - - for (int32_t CurrentH = PointerCoorInt; (PointerEndInt) > CurrentH; CurrentH++) { - ImageBuffer[ResV * (CurrentW) + (CurrentH)] = Colour; - }; - - RadiusPos++; - - } - } - diff --git a/SpeeduinoGL/src/SpeeduinoGL.h b/SpeeduinoGL/src/SpeeduinoGL.h deleted file mode 100644 index c789447..0000000 --- a/SpeeduinoGL/src/SpeeduinoGL.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef SpeeduinoGL_h -#define SpeeduinoGL_h - -#include - - struct Point { - float w; - float h; - }; - - struct Triangle { - Point A; - Point B; - Point C; - }; - - struct Rectangle { - Point A; - Point B; - Point D; - Point C; - }; - - void ConfigBuffer(uint32_t address = 0x60000000, uint32_t ResolutionV = 480, uint32_t ResolutionH = 800); - void FillTriangle(Triangle triangle, uint16_t Colour); - void FillRectangle(Rectangle rectangle, uint16_t Colour); - - void PolarizedTwoLineRasterizer(int32_t CellStartX, int32_t CellEndX, float PointerCoordinateH, float PointerEndH, float Gradient1, float Gradient2, uint16_t Colour, bool Polarity); - void TwoLineRasterizer(int32_t CellStartX, int32_t CellEndX, float PointerCoordinateH, float PointerEndH, float Gradient1, float Gradient2, uint16_t Colour); - void FillCircle(float Radius, uint16_t Colour, Point Centre); - -#endif