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;