-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from PSU-Capstone-Team24/Console_Cleanup
Console Output Cleanup
- Loading branch information
Showing
22 changed files
with
963 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
with Bitmapped_Drawing; | ||
with STM32.Board; | ||
with GUI; | ||
|
||
package body Debug is | ||
|
||
-- Probably a cleaner way to do this | ||
procedure Print (Debug_Level : in Debug; Msg : in String) is | ||
currentLine : constant Natural := | ||
(CURRENT_CONSOLE_POSITION.Y - 100) / FONT_HEIGHT; -- zero indexed | ||
Foreground : HAL.Bitmap.Bitmap_Color; | ||
Background : HAL.Bitmap.Bitmap_Color; | ||
begin | ||
|
||
Foreground := | ||
(case Debug_Level is when Info | Error => HAL.Bitmap.White, | ||
when Warning => HAL.Bitmap.Black); | ||
|
||
Background := | ||
(case Debug_Level is when Info => HAL.Bitmap.Blue, | ||
when Warning => HAL.Bitmap.Yellow, when Error => HAL.Bitmap.Red); | ||
|
||
if currentLine > MAX_LINES then | ||
-- Shift console lines up | ||
for I in 1 .. MAX_LINES loop | ||
CopyLine (I, I - 1, I = MAX_LINES); | ||
end loop; | ||
|
||
-- Adjust Y position to overwrite the last line | ||
CURRENT_CONSOLE_POSITION.Y := | ||
CURRENT_CONSOLE_POSITION.Y - FONT_HEIGHT - LINE_PADDING; | ||
end if; | ||
|
||
-- Draw debug prefix | ||
Bitmapped_Drawing.Draw_String | ||
(Buffer => GUI.ScreenBuffer.all, | ||
Start => | ||
GUI.Scale | ||
((CURRENT_CONSOLE_POSITION.X, CURRENT_CONSOLE_POSITION.Y)), | ||
Msg => Debug_Level'Image, Font => BMP_Fonts.Font8x8, | ||
Foreground => Foreground, Background => Background); | ||
|
||
-- Draw actual message text | ||
Bitmapped_Drawing.Draw_String | ||
(Buffer => GUI.ScreenBuffer.all, | ||
Start => | ||
GUI.Scale | ||
((CURRENT_CONSOLE_POSITION.X + | ||
GUI.MeasureText (Debug_Level'Image, BMP_Fonts.Font8x8).Width + | ||
LINE_PADDING, | ||
CURRENT_CONSOLE_POSITION.Y)), | ||
Msg => Msg, Font => BMP_Fonts.Font8x8, Foreground => HAL.Bitmap.White, | ||
Background => HAL.Bitmap.Black); | ||
|
||
-- Move the Y position down for the next message | ||
CURRENT_CONSOLE_POSITION.Y := | ||
CURRENT_CONSOLE_POSITION.Y + FONT_HEIGHT + LINE_PADDING; | ||
|
||
STM32.Board.Display.Update_Layer (1, True); | ||
end Print; | ||
|
||
procedure CopyLine | ||
(SrcLineNumber : in Natural; DstLineNumer : in Natural; | ||
DeleteSrc : in Boolean) | ||
is | ||
-- TODO: Cleanup later... | ||
srcToPoint : constant HAL.Bitmap.Point := | ||
(0, (CONSOLE_STARTING_POINT.Y + (FONT_HEIGHT * SrcLineNumber))); | ||
dstToPoint : constant HAL.Bitmap.Point := | ||
(0, (CONSOLE_STARTING_POINT.Y + (FONT_HEIGHT * DstLineNumer))); | ||
srcRect : constant HAL.Bitmap.Rect := | ||
(Position => srcToPoint, Width => GUI.Board_Resolution.Width, | ||
Height => FONT_HEIGHT); | ||
begin | ||
HAL.Bitmap.Copy_Rect | ||
(Src_Buffer => GUI.ScreenBuffer.all, | ||
Src_Pt => srcToPoint, | ||
Dst_Buffer => GUI.ScreenBuffer.all, | ||
Dst_Pt => dstToPoint, Width => GUI.Board_Resolution.Width, | ||
Height => FONT_HEIGHT, Synchronous => True); | ||
if DeleteSrc then | ||
HAL.Bitmap.Fill_Rect | ||
(Buffer => GUI.ScreenBuffer.all, | ||
Area => srcRect); | ||
end if; | ||
STM32.Board.Display.Update_Layer (1, True); | ||
end CopyLine; | ||
end Debug; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
with HAL.Bitmap; | ||
with BMP_Fonts; | ||
|
||
package Debug is | ||
type Debug is (Error, Warning, Info); | ||
|
||
CONSOLE_STARTING_POINT : HAL.Bitmap.Point := (0, 100); | ||
CURRENT_CONSOLE_POSITION : HAL.Bitmap.Point := (0, 100); | ||
FONT_HEIGHT : constant Natural := | ||
BMP_Fonts.Char_Height (Font => BMP_Fonts.Font8x8); | ||
MAX_LINES : constant Natural := 20; | ||
LINE_PADDING : constant Natural := 2; | ||
|
||
procedure Print (Debug_Level : in Debug; Msg : in String); | ||
procedure CopyLine | ||
(SrcLineNumber : in Natural; DstLineNumer : in Natural; | ||
DeleteSrc : in Boolean); | ||
end Debug; |
Oops, something went wrong.