Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moved console down, removed cpu and mem usage, added submenu #28

Merged
merged 3 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eRINA_STM32F7/src/rina/debug.ads
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package Debug is
BMP_Fonts.Char_Height (Font => BMP_Fonts.Font8x8);
Max_Characters_Per_Line : constant Positive := 52;
Line_Padding : constant Natural := 4;
Starting_Point : constant HAL.Bitmap.Point := (10, 110);
Starting_Point : constant HAL.Bitmap.Point := (10, 125);

-- Debug bitmap colors
Info_Color : constant HAL.Bitmap.Bitmap_Color := (255, 109, 177, 255);
Expand Down
75 changes: 59 additions & 16 deletions eRINA_STM32F7/src/rina/demo.adb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ with Ada.Real_Time; use Ada.Real_Time;
with Demo_IPCP;
with HAL.Bitmap;
with Debug;
with HAL.Touch_Panel;

procedure Demo is
Period : constant Time_Span := Milliseconds (1 / GUI.Frame_Rate * 1_000);
Next_Render : Time := Clock;
This_DIF : DIF_Access;
This_IPCP : IPCP;
Show_Menu : Boolean := False;
begin
GUI.Initialize;
STM32.Board.Touch_Panel.Initialize;
Network.Initialize;
STM32.Board.Configure_User_Button_GPIO;
STM32.Board.Initialize_LEDs;
Expand All @@ -35,39 +38,78 @@ begin

-- Render loop keeps the board from immediately terminating
loop
declare
State : HAL.Touch_Panel.TP_State := STM32.Board.Touch_Panel.Get_All_Touch_Points;
begin
-- if the menu button on screen is pressed, set the Show_Menu flag
if GUI.Has_Touch(State => State) then
Show_Menu := GUI.Has_Touch_Within_Area(State => State, P => (75, 45), S => (48, 25));
end if;

GUI.Draw_Rectangle ((0, 0), GUI.Board_Resolution, HAL.Bitmap.White);

-- This is really ugly, but I'm not good enough with generics to figure out how to make it look better
-- Perhaps Texture should be a tagged record instead so we can use dot notation here
Texture_PSU.PSU.Print (Texture_PSU.Bitmap, (5, 8));
Texture_Logo.Logo.Print (Texture_Logo.Bitmap, (75, 0));

GUI.Fill_Rounded_Rectangle ((75, 45), (128, 25), GUI.Button_Color, 2);
GUI.Print ("Menu", (120, 53));

GUI.Print_Large ("Console", (5, 90));
-- if the show menu flag is set, draw the menu button as a different color
if Show_Menu then
GUI.Fill_Rounded_Rectangle ((75, 45), (48, 25), GUI.Button_Selected_Color, 2);
else
GUI.Fill_Rounded_Rectangle ((75, 45), (48, 25), GUI.Button_Color, 2);
end if;
GUI.Print ("Menu", (82, 53));

-- when the user presses the menu button, show the submenu
if Show_Menu then
GUI.Draw_Rounded_Rectangle ((125, 45), (150,65), HAL.Bitmap.Black, 2, 1);

GUI.Fill_Rounded_Rectangle ((130, 50), (140, 15), GUI.Button_Color, 2);
GUI.Print ("Network Stats", (150, 53));

GUI.Fill_Rounded_Rectangle ((130, 70), (140, 15), GUI.Button_Color, 2);
GUI.Print ("Network Settings", (135, 73));

GUI.Fill_Rounded_Rectangle ((130, 90), (140, 15), GUI.Button_Color, 2);
GUI.Print ("Device Info", (155, 93));

-- if there is a touch event while the menu is open
-- if (GUI.Has_Touch(State => State)) then
-- if GUI.Has_Touch_Within_Area(State => State, P => (130, 50), S => (140, 15)) then
-- -- Show Network statistics, maybe add a piece of state to show network statistics similar to Show_Menu
-- end if;
-- if GUI.Has_Touch_Within_Area(State => State, P => (130, 70), S => (140, 15)) then
-- -- Show Network settings, maybe add a piece of state to show network settings similar to Show_Menu
-- end if;
-- if GUI.Has_Touch_Within_Area(State => State, P => (130, 90), S => (140, 15)) then
-- -- Show Device Info, maybe add a piece of state to show device info similar to Show_Menu
-- end if;
-- end if;
end if;


GUI.Print_Large ("Console", (5, 105));
GUI.Draw_Rounded_Rectangle
((5, 105), (GUI.Board_Resolution.Width - 8, 160), HAL.Bitmap.Black, 2,
((5, 120), (GUI.Board_Resolution.Width - 8, 145), 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, 2), (200, 36), HAL.Bitmap.Black, 2, 1);
GUI.Print (" Mac: 00:81:E1:05:05:01", (280, 12));
GUI.Print ("Board: STM32F746-DISCO", (280, 24));

GUI.Draw_Rounded_Rectangle
((277, 65), (200, 20), HAL.Bitmap.Black, 2, 1);
((277, 40), (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));
((330, 46), (25, 10), GUI.Get_RX_Status_Color, 1);
GUI.Print ("RX", (300, 48));

GUI.Fill_Rounded_Rectangle
((420, 70), (25, 10), GUI.Get_TX_Status_Color, 1);
GUI.Print ("TX", (390, 71));
((420, 46), (25, 10), GUI.Get_TX_Status_Color, 1);
GUI.Print ("TX", (390, 48));

GUI.Print ("Version: " & GUI.Build_Verson, (362, 90));
GUI.Print ("Version: " & GUI.Build_Verson, (362, 105));

-- GUI.Print ("Status: ", (80, 45));
-- GUI.Print ("Waiting for enrollment request", (145, 45));
Expand All @@ -82,5 +124,6 @@ begin
Next_Render := Next_Render + Period;

delay until Next_Render;
end;
end loop;
end Demo;
22 changes: 22 additions & 0 deletions eRINA_STM32F7/src/rina/gui.adb
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,26 @@ package body GUI is
(Text'Length * BMP_Fonts.Char_Width (Font),
BMP_Fonts.Char_Height (Font));
end MeasureText;

function Has_Touch_Within_Area(State : HAL.Touch_Panel.TP_State; P : Point; S : Size) return Boolean is
begin
if State'Length > 0 then
if State (1).X >= P.X and State (1).X <= P.X + S.Width and
State (1).Y >= P.Y and State (1).Y <= P.Y + S.Height then
return True;
else
return False;
end if;
end if;
end Has_Touch_Within_Area;

function Has_Touch(State : HAL.Touch_Panel.TP_State) return Boolean is
begin
if State'Length > 0 then
return True;
else
return False;
end if;
end Has_Touch;

end GUI;
5 changes: 4 additions & 1 deletion eRINA_STM32F7/src/rina/gui.ads
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
with BMP_Fonts;
with HAL.Bitmap; use HAL.Bitmap;
with Ada.Containers.Vectors;

with HAL.Touch_Panel; use HAL.Touch_Panel;
package GUI is
pragma Warnings (Off);

Large_Font : BMP_Fonts.BMP_Font := BMP_Fonts.Font12x12;
Foreground : Bitmap_Color := Black;
Background : Bitmap_Color := White;
Button_Color : Bitmap_Color := (255, 242, 243, 245);
Button_Selected_Color : Bitmap_Color := (255, 255, 255, 255);
TX_Active : Bitmap_Color := (255, 111, 255, 109);
TX_Inactive : Bitmap_Color := (255, 56, 128, 55);
RX_Active : Bitmap_Color := (255, 255, 109, 109);
Expand Down Expand Up @@ -55,4 +56,6 @@ package GUI is
function MeasureText
(Text : in String; Font : in BMP_Fonts.BMP_Font) return Size;
function Scale (Position : in Point) return Point;
function Has_Touch_Within_Area (State : HAL.Touch_Panel.TP_State; P : Point; S : Size) return Boolean;
function Has_Touch (State : HAL.Touch_Panel.TP_State) return Boolean;
end GUI;
Loading