diff --git a/eRINA_STM32F7/src/net/receiver.adb b/eRINA_STM32F7/src/net/receiver.adb index 78a9a31..78f3dae 100644 --- a/eRINA_STM32F7/src/net/receiver.adb +++ b/eRINA_STM32F7/src/net/receiver.adb @@ -13,6 +13,7 @@ package body Receiver is Ready : Ada.Synchronous_Task_Control.Suspension_Object; ONE_US : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Microseconds (1); + -- ------------------------------ -- Start the receiver loop. -- ------------------------------ @@ -33,12 +34,13 @@ package body Receiver is Total : Net.Uint64 := 0; Count : Net.Uint64 := 0; begin - Debug.Print (Debug.Info, "Initializing Ethernet Controller..."); + + Debug.Console.Print (Debug.Info, "Initializing Ethernet Controller..."); -- Wait until the Ethernet driver is ready. Ada.Synchronous_Task_Control.Suspend_Until_True (Ready); - Debug.Print (Debug.Info, "Ethernet Controller Initialized!"); + Debug.Console.Print (Debug.Info, "Ethernet Controller Initialized!"); -- Loop receiving packets and dispatching them. Min_Receive_Time := Us_Time'Last; @@ -58,8 +60,7 @@ package body Receiver is if Ether.Ether_Type = Net.Headers.To_Network (Net.Protos.ETHERTYPE_ARP) then - ARP_Request_Count := ARP_Request_Count + 1; - Debug.Print (Debug.Info, "ARP Packet Received"); + Debug.Console.Print (Debug.Info, "ARP Packet Received"); Net.Protos.Arp.Receive (Network.Ifnet, Packet); elsif Ether.Ether_Type = Net.Headers.To_Network (Net.Protos.ETHERTYPE_RINA) diff --git a/eRINA_STM32F7/src/net/receiver.ads b/eRINA_STM32F7/src/net/receiver.ads index 3e80c35..9083b5e 100644 --- a/eRINA_STM32F7/src/net/receiver.ads +++ b/eRINA_STM32F7/src/net/receiver.ads @@ -29,8 +29,6 @@ package Receiver is Max_Receive_Time : Us_Time := 0 with Atomic; - ARP_Request_Count : Natural := 0; - -- Start the receiver loop. procedure Start; diff --git a/eRINA_STM32F7/src/rina/board.adb b/eRINA_STM32F7/src/rina/board.adb index 0376d16..e098309 100644 --- a/eRINA_STM32F7/src/rina/board.adb +++ b/eRINA_STM32F7/src/rina/board.adb @@ -5,7 +5,7 @@ package body Board is procedure Pressed is begin STM32.Board.All_LEDs_On; - Debug.Print(Debug.Info, "Button pressed!"); + Debug.Console.Print(Debug.Info, "Button pressed!"); end Pressed; end Button_Handler; end Board; \ No newline at end of file diff --git a/eRINA_STM32F7/src/rina/debug.adb b/eRINA_STM32F7/src/rina/debug.adb index a50e1e2..87a78e8 100644 --- a/eRINA_STM32F7/src/rina/debug.adb +++ b/eRINA_STM32F7/src/rina/debug.adb @@ -4,105 +4,93 @@ with GUI; package body Debug is - protected body Mutex is - entry Seize when not Owned is + protected body Console is + 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 - Owned := True; - end Seize; - procedure Release is - begin - Owned := False; - end Release; - end Mutex; - - -- 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 - Print_Mutex.Seize; - Foreground := - (case Debug_Level is when Info | Error => HAL.Bitmap.White, - when Warning => HAL.Bitmap.Black); + 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); + 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; + 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; + -- 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.Screen_Buffer.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 debug prefix + Bitmapped_Drawing.Draw_String + (Buffer => GUI.Screen_Buffer.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.Screen_Buffer.all, - Start => - GUI.Scale - ((CURRENT_CONSOLE_POSITION.X + - GUI.MeasureText (Debug_Level'Image, BMP_Fonts.Font8x8).Width + - LINE_PADDING * 2, - CURRENT_CONSOLE_POSITION.Y)), - Msg => Msg, Font => BMP_Fonts.Font8x8, Foreground => HAL.Bitmap.White, - Background => HAL.Bitmap.Black); + -- Draw actual message text + Bitmapped_Drawing.Draw_String + (Buffer => GUI.Screen_Buffer.all, + Start => + GUI.Scale + ((CURRENT_CONSOLE_POSITION.X + + GUI.MeasureText (Debug_Level'Image, BMP_Fonts.Font8x8).Width + + LINE_PADDING * 2, + 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; + -- 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); + STM32.Board.Display.Update_Layer (1, True); + end Print; - Print_Mutex.Release; - end Print; + procedure CopyLine + (SrcLineNumber : in Natural; DstLineNumer : in Natural; + DeleteSrc : in Boolean) + is + -- TODO: Cleanup later... + srcToPoint : constant HAL.Bitmap.Point := + (0, + Natural'Min + (CONSOLE_STARTING_POINT.Y + + (FONT_HEIGHT + LINE_PADDING) * SrcLineNumber, + GUI.Board_Resolution.Height - 2)); + dstToPoint : constant HAL.Bitmap.Point := + (0, + Natural'Min + (CONSOLE_STARTING_POINT.Y + + (FONT_HEIGHT + LINE_PADDING) * DstLineNumer, + GUI.Board_Resolution.Height - 2)); + srcRect : constant HAL.Bitmap.Rect := + (Position => srcToPoint, Width => GUI.Board_Resolution.Width, + Height => FONT_HEIGHT + LINE_PADDING); + begin + HAL.Bitmap.Copy_Rect + (Src_Buffer => GUI.Screen_Buffer.all, Src_Pt => srcToPoint, + Dst_Buffer => GUI.Screen_Buffer.all, Dst_Pt => dstToPoint, + Width => GUI.Board_Resolution.Width, + Height => FONT_HEIGHT + LINE_PADDING, Synchronous => True); + if DeleteSrc then + HAL.Bitmap.Fill_Rect + (Buffer => GUI.Screen_Buffer.all, Area => srcRect); + end if; + STM32.Board.Display.Update_Layer (1, True); + end CopyLine; + end Console; - procedure CopyLine - (SrcLineNumber : in Natural; DstLineNumer : in Natural; - DeleteSrc : in Boolean) - is - -- TODO: Cleanup later... - srcToPoint : constant HAL.Bitmap.Point := - (0, - Natural'Min - (CONSOLE_STARTING_POINT.Y + - (FONT_HEIGHT + LINE_PADDING) * SrcLineNumber, - GUI.Board_Resolution.Height - 2)); - dstToPoint : constant HAL.Bitmap.Point := - (0, - Natural'Min - (CONSOLE_STARTING_POINT.Y + - (FONT_HEIGHT + LINE_PADDING) * DstLineNumer, - GUI.Board_Resolution.Height - 2)); - srcRect : constant HAL.Bitmap.Rect := - (Position => srcToPoint, Width => GUI.Board_Resolution.Width, - Height => FONT_HEIGHT + LINE_PADDING); - begin - HAL.Bitmap.Copy_Rect - (Src_Buffer => GUI.Screen_Buffer.all, Src_Pt => srcToPoint, - Dst_Buffer => GUI.Screen_Buffer.all, Dst_Pt => dstToPoint, - Width => GUI.Board_Resolution.Width, - Height => FONT_HEIGHT + LINE_PADDING, Synchronous => True); - if DeleteSrc then - HAL.Bitmap.Fill_Rect - (Buffer => GUI.Screen_Buffer.all, Area => srcRect); - end if; - STM32.Board.Display.Update_Layer (1, True); - end CopyLine; end Debug; diff --git a/eRINA_STM32F7/src/rina/debug.ads b/eRINA_STM32F7/src/rina/debug.ads index 900d6bd..b3acf55 100644 --- a/eRINA_STM32F7/src/rina/debug.ads +++ b/eRINA_STM32F7/src/rina/debug.ads @@ -4,23 +4,19 @@ 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; - protected type Mutex is - entry Seize; - procedure Release; + protected Console is + procedure Print (Debug_Level : in Debug; Msg : in String); + procedure CopyLine + (SrcLineNumber : in Natural; DstLineNumer : in Natural; + DeleteSrc : in Boolean); private - Owned : Boolean := False; - end Mutex; + CONSOLE_STARTING_POINT : HAL.Bitmap.Point := (0, 100); + CURRENT_CONSOLE_POSITION : HAL.Bitmap.Point := (0, 100); + end Console; - Print_Mutex : Mutex; - procedure Print (Debug_Level : in Debug; Msg : in String); - procedure CopyLine - (SrcLineNumber : in Natural; DstLineNumer : in Natural; - DeleteSrc : in Boolean); end Debug; diff --git a/eRINA_STM32F7/src/rina/demo.adb b/eRINA_STM32F7/src/rina/demo.adb index 66e1ed6..b4ae5b1 100644 --- a/eRINA_STM32F7/src/rina/demo.adb +++ b/eRINA_STM32F7/src/rina/demo.adb @@ -4,6 +4,7 @@ with Textures.PSU; with Network; with STM32; with STM32.Board; +with Debug; procedure Demo is begin @@ -23,6 +24,14 @@ begin ("Ignored Packets: " & Network.Ifnet.Rx_Stats.Ignored'Image, (80, 30)); - delay Duration(1 / GUI.Frame_Rate); + GUI.Print + ("Status: ", + (80, 45)); + + GUI.Print + ("Waiting for enrollment request", + (145, 45)); + + delay Duration(1.0 / GUI.Frame_Rate); end loop; end Demo; \ No newline at end of file diff --git a/eRINA_STM32F7/src/rina/gui.ads b/eRINA_STM32F7/src/rina/gui.ads index ab51514..308bfa2 100644 --- a/eRINA_STM32F7/src/rina/gui.ads +++ b/eRINA_STM32F7/src/rina/gui.ads @@ -14,8 +14,8 @@ package GUI is end record; Board_Resolution : Size := (480, 272); - Frame_Rate : Natural := 60; - + Frame_Rate : Natural := 30; + procedure Initialize; procedure Update; procedure Print (Msg : in String; Pos : in HAL.Bitmap.Point);