Skip to content

Commit

Permalink
printToConsole now moving items as max lines reached (13)
Browse files Browse the repository at this point in the history
  • Loading branch information
robbamyers committed Feb 7, 2024
1 parent 52eda88 commit 3dd54e2
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions eRINA_STM32F7/src/rina/gui.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3dd54e2

Please sign in to comment.