From a4f7e96049dec8ec0ebfa511ca9c9c286c034ca1 Mon Sep 17 00:00:00 2001 From: robbamyers Date: Tue, 6 Feb 2024 20:53:10 -0500 Subject: [PATCH 1/3] added copy line procedure --- eRINA_STM32F7/src/rina/gui.adb | 60 ++++++++++++++++++++++++++++++++++ eRINA_STM32F7/src/rina/gui.ads | 17 ++++++++++ 2 files changed, 77 insertions(+) create mode 100644 eRINA_STM32F7/src/rina/gui.adb create mode 100644 eRINA_STM32F7/src/rina/gui.ads diff --git a/eRINA_STM32F7/src/rina/gui.adb b/eRINA_STM32F7/src/rina/gui.adb new file mode 100644 index 0000000..6ad3c45 --- /dev/null +++ b/eRINA_STM32F7/src/rina/gui.adb @@ -0,0 +1,60 @@ +with Bitmapped_Drawing; +with HAL.Bitmap; +with STM32.Board; +with STM32.RNG.Interrupts; + + +package body GUI is + pragma Warnings (Off); + + CONSOLE_STARTING_POINT : HAL.Bitmap.Point := (0, 100); + CURRENT_CONSOLE_POSITION : HAL.Bitmap.Point := (0, 100); + + + function Scale (Point : in HAL.Bitmap.Point) return HAL.Bitmap.Point; + + function Scale (Point : in HAL.Bitmap.Point) return HAL.Bitmap.Point is + begin + if STM32.Board.LCD_Natural_Width > 480 then + return (Point.X * 800 / 480, Point.Y * 480 / 272); + else + return Point; + end if; + end Scale; + + procedure Print (X : in Natural; Y : in Natural; Msg : in String) is + begin + Bitmapped_Drawing.Draw_String (Buffer => STM32.Board.Display.Hidden_Buffer (1).all, + Start => Scale ((X,Y)), + Msg => Msg, + Font => Large_Font, + Foreground => Foreground, + Background => Background); + end Print; + + procedure Initialize (Title : in String) is + begin + STM32.RNG.Interrupts.Initialize_RNG; + STM32.Board.Display.Initialize; + STM32.Board.Display.Initialize_Layer (1, HAL.Bitmap.ARGB_1555); + Print(0, 0, Title); + end Initialize; + + procedure PrintToConsole(Msg : in String) is + begin + Print(CURRENT_CONSOLE_POSITION.X, CURRENT_CONSOLE_POSITION.Y, Msg); + CURRENT_CONSOLE_POSITION := (0, CURRENT_CONSOLE_POSITION.Y + 12); + STM32.Board.Display.Update_Layer(1, True); + end PrintToConsole; + + procedure CopyLine(SrcLineNumber : in Natural; DstLineNumer : in Natural; DeleteSrc : in Boolean) is + fontHeight : Natural := BMP_Fonts.Char_Height(Font => Large_Font); + srcToPoint : HAL.Bitmap.Point := (0, (CONSOLE_STARTING_POINT.Y + (fontHeight * SrcLineNumber))); + dstToPoint : HAL.Bitmap.Point := (0, (CONSOLE_STARTING_POINT.Y + (fontHeight * DstLineNumer))); + begin + HAL.Bitmap.Copy_Rect(Src_Buffer => STM32.Board.Display.Hidden_Buffer (1).all, Src_Pt => srcToPoint, Dst_Buffer => STM32.Board.Display.Hidden_Buffer (1).all, Dst_Pt => dstToPoint, Width => 480, Height => fontHeight, Synchronous => True); + STM32.Board.Display.Update_Layer(1, True); + end CopyLine; + + +end GUI; \ No newline at end of file diff --git a/eRINA_STM32F7/src/rina/gui.ads b/eRINA_STM32F7/src/rina/gui.ads new file mode 100644 index 0000000..3071295 --- /dev/null +++ b/eRINA_STM32F7/src/rina/gui.ads @@ -0,0 +1,17 @@ +with BMP_Fonts; +with HAL.Bitmap; +package GUI is + pragma Warnings(Off); + + Large_Font : BMP_Fonts.BMP_Font := BMP_Fonts.Font12x12; + Foreground : HAL.Bitmap.Bitmap_Color := HAL.Bitmap.White; + Background : HAL.Bitmap.Bitmap_Color := HAL.Bitmap.Black; + + procedure Print (X : in Natural; Y : in Natural; Msg : in String); + + procedure Initialize (Title : in String); + + procedure PrintToConsole(Msg : in String); + + procedure CopyLine(SrcLineNumber : in Natural; DstLineNumer : in Natural; DeleteSrc : in Boolean); +end GUI; \ No newline at end of file From 52eda88285608e9627f336d1af69d33f698045b7 Mon Sep 17 00:00:00 2001 From: robbamyers Date: Tue, 6 Feb 2024 21:03:34 -0500 Subject: [PATCH 2/3] modified copyline to handle deleting src line --- eRINA_STM32F7/src/rina/gui.adb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eRINA_STM32F7/src/rina/gui.adb b/eRINA_STM32F7/src/rina/gui.adb index 6ad3c45..abbd122 100644 --- a/eRINA_STM32F7/src/rina/gui.adb +++ b/eRINA_STM32F7/src/rina/gui.adb @@ -51,8 +51,12 @@ package body GUI is fontHeight : Natural := BMP_Fonts.Char_Height(Font => Large_Font); srcToPoint : HAL.Bitmap.Point := (0, (CONSOLE_STARTING_POINT.Y + (fontHeight * SrcLineNumber))); dstToPoint : HAL.Bitmap.Point := (0, (CONSOLE_STARTING_POINT.Y + (fontHeight * DstLineNumer))); + srcRect : HAL.Bitmap.Rect := (Position => srcToPoint, Width => 480, Height => fontHeight); begin HAL.Bitmap.Copy_Rect(Src_Buffer => STM32.Board.Display.Hidden_Buffer (1).all, Src_Pt => srcToPoint, Dst_Buffer => STM32.Board.Display.Hidden_Buffer (1).all, Dst_Pt => dstToPoint, Width => 480, Height => fontHeight, Synchronous => True); + if DeleteSrc then + HAL.Bitmap.Fill_Rect(Buffer => STM32.Board.Display.Hidden_Buffer (1).all, Area => srcRect); + end if; STM32.Board.Display.Update_Layer(1, True); end CopyLine; From 3dd54e2f64f247ccec17885ab7d469b4a063cf75 Mon Sep 17 00:00:00 2001 From: robbamyers Date: Tue, 6 Feb 2024 22:58:04 -0500 Subject: [PATCH 3/3] printToConsole now moving items as max lines reached (13) --- eRINA_STM32F7/src/rina/gui.adb | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/eRINA_STM32F7/src/rina/gui.adb b/eRINA_STM32F7/src/rina/gui.adb index abbd122..da15c8e 100644 --- a/eRINA_STM32F7/src/rina/gui.adb +++ b/eRINA_STM32F7/src/rina/gui.adb @@ -9,6 +9,7 @@ package body GUI is CONSOLE_STARTING_POINT : HAL.Bitmap.Point := (0, 100); CURRENT_CONSOLE_POSITION : HAL.Bitmap.Point := (0, 100); + FONT_HEIGHT : Natural := BMP_Fonts.Char_Height(Font => Large_Font); function Scale (Point : in HAL.Bitmap.Point) return HAL.Bitmap.Point; @@ -40,20 +41,39 @@ package body GUI is Print(0, 0, Title); end Initialize; + -- Probably a cleaner way to do this procedure PrintToConsole(Msg : in String) is + currentLine : Natural := (CURRENT_CONSOLE_POSITION.Y - 100) / FONT_HEIGHT; -- zero indexed begin - Print(CURRENT_CONSOLE_POSITION.X, CURRENT_CONSOLE_POSITION.Y, Msg); - CURRENT_CONSOLE_POSITION := (0, CURRENT_CONSOLE_POSITION.Y + 12); + if currentLine = 14 then --make dynamic + declare + iterator : Integer := 1; + begin + while iterator < 13 loop --make dynamic + CopyLine(iterator, iterator - 1, false); + iterator := iterator + 1; + end loop; + CopyLine(13, 12, True); --make dynamic + end; + CURRENT_CONSOLE_POSITION.Y := CURRENT_CONSOLE_POSITION.Y - FONT_HEIGHT; + Print(CURRENT_CONSOLE_POSITION.X, CURRENT_CONSOLE_POSITION.Y, Msg); + CURRENT_CONSOLE_POSITION.Y := CURRENT_CONSOLE_POSITION.Y + FONT_HEIGHT; + + else + Print(CURRENT_CONSOLE_POSITION.X, CURRENT_CONSOLE_POSITION.Y, Msg); + CURRENT_CONSOLE_POSITION.Y := CURRENT_CONSOLE_POSITION.Y + FONT_HEIGHT; + end if; + STM32.Board.Display.Update_Layer(1, True); end PrintToConsole; + procedure CopyLine(SrcLineNumber : in Natural; DstLineNumer : in Natural; DeleteSrc : in Boolean) is - fontHeight : Natural := BMP_Fonts.Char_Height(Font => Large_Font); - srcToPoint : HAL.Bitmap.Point := (0, (CONSOLE_STARTING_POINT.Y + (fontHeight * SrcLineNumber))); - dstToPoint : HAL.Bitmap.Point := (0, (CONSOLE_STARTING_POINT.Y + (fontHeight * DstLineNumer))); - srcRect : HAL.Bitmap.Rect := (Position => srcToPoint, Width => 480, Height => fontHeight); + srcToPoint : HAL.Bitmap.Point := (0, (CONSOLE_STARTING_POINT.Y + (FONT_HEIGHT * SrcLineNumber))); + dstToPoint : HAL.Bitmap.Point := (0, (CONSOLE_STARTING_POINT.Y + (FONT_HEIGHT * DstLineNumer))); + srcRect : HAL.Bitmap.Rect := (Position => srcToPoint, Width => 480, Height => FONT_HEIGHT); -- dont hardcode 480 begin - HAL.Bitmap.Copy_Rect(Src_Buffer => STM32.Board.Display.Hidden_Buffer (1).all, Src_Pt => srcToPoint, Dst_Buffer => STM32.Board.Display.Hidden_Buffer (1).all, Dst_Pt => dstToPoint, Width => 480, Height => fontHeight, Synchronous => True); + HAL.Bitmap.Copy_Rect(Src_Buffer => STM32.Board.Display.Hidden_Buffer (1).all, Src_Pt => srcToPoint, Dst_Buffer => STM32.Board.Display.Hidden_Buffer (1).all, Dst_Pt => dstToPoint, Width => 480, Height => FONT_HEIGHT, Synchronous => True); if DeleteSrc then HAL.Bitmap.Fill_Rect(Buffer => STM32.Board.Display.Hidden_Buffer (1).all, Area => srcRect); end if;