From 79bffbeed0d8c1ae03fded3584da4ec08e9997a2 Mon Sep 17 00:00:00 2001 From: Mason Ticehurst Date: Thu, 29 Feb 2024 23:24:27 -0500 Subject: [PATCH] Add TX/RX indicators to LCD --- .../src/net/stm32/net-interfaces-stm32.adb | 43 +++++++++++++++++-- .../src/net/stm32/net-interfaces-stm32.ads | 4 ++ eRINA_STM32F7/src/rina/demo.adb | 10 +++++ eRINA_STM32F7/src/rina/gui.adb | 13 +++++- eRINA_STM32F7/src/rina/gui.ads | 8 +++- 5 files changed, 73 insertions(+), 5 deletions(-) diff --git a/eRINA_STM32F7/src/net/stm32/net-interfaces-stm32.adb b/eRINA_STM32F7/src/net/stm32/net-interfaces-stm32.adb index 0c6c070..b6a2848 100644 --- a/eRINA_STM32F7/src/net/stm32/net-interfaces-stm32.adb +++ b/eRINA_STM32F7/src/net/stm32/net-interfaces-stm32.adb @@ -61,7 +61,7 @@ package body Net.Interfaces.STM32 is (System.Address, Rx_Ring_Array_Type_Access); Tx_Ring_Instance : aliased Tx_Ring_Array_Type; - + function Next_Tx (Value : in Tx_Position) return Tx_Position; function Next_Rx (Value : in Rx_Position) return Rx_Position; @@ -94,7 +94,7 @@ package body Net.Interfaces.STM32 is -- Check if the transmit queue is initialized. function Is_Ready return Boolean; - + function Get_Cur_TX return Tx_Position; private -- Transmit queue management. Tx_Space : Uint32 := 0; @@ -118,7 +118,7 @@ package body Net.Interfaces.STM32 is -- Check if the receive queue is initialized. function Is_Ready return Boolean; - + function Get_Cur_RX return Rx_Position; private -- Receive queue management. @@ -298,6 +298,11 @@ package body Net.Interfaces.STM32 is return Tx_Ring /= null; end Is_Ready; + function Get_Cur_TX return Tx_Position is + begin + return Cur_Tx; + end Get_Cur_TX; + end Transmit_Queue; protected body Receive_Queue is @@ -319,6 +324,11 @@ package body Net.Interfaces.STM32 is Ethernet_MAC_Periph.MACCR.RE := True; end Wait_Packet; + function Get_Cur_RX return Rx_Position is + begin + return Cur_Rx; + end Get_Cur_RX; + procedure Receive_Interrupt is Rx : Rx_Ring_Access; begin @@ -425,4 +435,31 @@ package body Net.Interfaces.STM32 is end Receive_Queue; + task RX_TX_Monitor; + + task body RX_TX_Monitor is + RX_Pos : Rx_Position := Receive_Queue.Get_Cur_RX; + TX_Pos : Tx_Position := Transmit_Queue.Get_Cur_TX; + begin + loop + if Receive_Queue.Get_Cur_RX /= RX_Pos then + RX_Active := True; + RX_Pos := Receive_Queue.Get_Cur_RX; + delay 0.1; + else + RX_Active := False; + end if; + + if Transmit_Queue.Get_Cur_TX /= TX_Pos then + TX_Active := True; + TX_Pos := Transmit_Queue.Get_Cur_TX; + delay 0.1; + else + TX_Active := False; + end if; + + delay 0.01; + end loop; + end RX_TX_Monitor; + end Net.Interfaces.STM32; diff --git a/eRINA_STM32F7/src/net/stm32/net-interfaces-stm32.ads b/eRINA_STM32F7/src/net/stm32/net-interfaces-stm32.ads index 75c149b..dfa8427 100644 --- a/eRINA_STM32F7/src/net/stm32/net-interfaces-stm32.ads +++ b/eRINA_STM32F7/src/net/stm32/net-interfaces-stm32.ads @@ -24,6 +24,10 @@ package Net.Interfaces.STM32 is -- Size of the receive ring. RX_RING_SIZE : constant Uint32 := 500; + -- TX/RX activity statuses + RX_Active : Boolean := False; + TX_Active : Boolean := False; + -- The STM32F Ethernet driver. type STM32_Ifnet is limited new Net.Interfaces.Ifnet_Type with null record; diff --git a/eRINA_STM32F7/src/rina/demo.adb b/eRINA_STM32F7/src/rina/demo.adb index 7adea57..1bdc1dd 100644 --- a/eRINA_STM32F7/src/rina/demo.adb +++ b/eRINA_STM32F7/src/rina/demo.adb @@ -52,10 +52,20 @@ begin ((5, 105), (GUI.Board_Resolution.Width - 8, 160), HAL.Bitmap.Black, 2, 1); + GUI.Draw_Rounded_Rectangle ((277, 2), (200, 60), HAL.Bitmap.Black, 2, 1); GUI.Print ("CPU U: xx.xx%", (280, 12)); GUI.Print ("RAM U: xx.xx%", (280, 24)); GUI.Print (" Mac: 00:81:E1:05:05:01", (280, 36)); GUI.Print ("Board: STM32F746-DISCO", (280, 48)); + + GUI.Draw_Rounded_Rectangle ((277, 65), (200, 20), HAL.Bitmap.Black, 2, 1); + + GUI.Fill_Rounded_Rectangle ((330, 70), (25, 10), GUI.Get_RX_Status_Color, 1); + GUI.Print ("RX", (300, 71)); + + GUI.Fill_Rounded_Rectangle ((420, 70), (25, 10), GUI.Get_TX_Status_Color, 1); + GUI.Print ("TX", (390, 71)); + -- GUI.Print ("Status: ", (80, 45)); -- GUI.Print ("Waiting for enrollment request", (145, 45)); diff --git a/eRINA_STM32F7/src/rina/gui.adb b/eRINA_STM32F7/src/rina/gui.adb index 6b2822d..89d4662 100644 --- a/eRINA_STM32F7/src/rina/gui.adb +++ b/eRINA_STM32F7/src/rina/gui.adb @@ -1,6 +1,7 @@ with Bitmapped_Drawing; with STM32.Board; -with STM32.RNG.Interrupts; +with STM32.RNG.Interrupts; use STM32.RNG.Interrupts; +with Net.Interfaces.STM32; package body GUI is @@ -25,6 +26,16 @@ package body GUI is STM32.Board.Display.Update_Layer (1); end Update; + function Get_TX_Status_Color return Bitmap_Color is + begin + return (if Net.Interfaces.STM32.TX_Active then GUI.TX_Active else GUI.TX_Inactive); + end Get_TX_Status_Color; + + function Get_RX_Status_Color return Bitmap_Color is + begin + return (if Net.Interfaces.STM32.RX_Active then GUI.RX_Active else GUI.RX_Inactive); + end Get_RX_Status_Color; + procedure Draw_Rectangle (P : Point; S : Size; C : Bitmap_Color) is begin Set_Source (Buffer => Screen_Buffer.all, ARGB => C); diff --git a/eRINA_STM32F7/src/rina/gui.ads b/eRINA_STM32F7/src/rina/gui.ads index e66600a..926458e 100644 --- a/eRINA_STM32F7/src/rina/gui.ads +++ b/eRINA_STM32F7/src/rina/gui.ads @@ -9,6 +9,10 @@ package GUI is Foreground : Bitmap_Color := Black; Background : Bitmap_Color := White; Button_Color : Bitmap_Color := (255, 242, 243, 245); + TX_Active : Bitmap_Color := (255, 111, 255, 109); + TX_Inactive : Bitmap_Color := (255, 56, 128, 55); + RX_Active : Bitmap_Color := (255, 255, 109, 109); + RX_Inactive : Bitmap_Color := (255, 128, 55, 55); Build_Verson : String := "0.0.1"; type Size is record @@ -26,7 +30,7 @@ package GUI is end record; Board_Resolution : Size := (480, 272); - Frame_Rate : Natural := 60; + Frame_Rate : Natural := 120; Max_Buttons : Natural := 16; package Button_Vectors is new Ada.Containers.Vectors @@ -36,6 +40,8 @@ package GUI is procedure Initialize; procedure Update; + function Get_TX_Status_Color return Bitmap_Color; + function Get_RX_Status_Color return Bitmap_Color; procedure Print (Msg : in String; Pos : in Point); procedure Print_Large (Msg : in String; Pos : in Point); function Screen_Buffer return Any_Bitmap_Buffer;