Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma Task_Dispatching_Policy(FIFO_Within_Priorities);
- pragma Locking_Policy(Ceiling_Locking);
- with Ada.Text_IO; use Ada.Text_IO;
- with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
- with Pendulum_IO_Sim; use Pendulum_IO_Sim;
- with Chars_8x5; use Chars_8x5;
- with Low_Level_Types; use Low_Level_Types;
- with Ada.Real_Time; use Ada.Real_Time;
- with Pendulum_State_T; use Pendulum_State_T;
- with System;
- procedure Pendulum is
- task Pendulum_Input is
- pragma Priority(System.Priority'Last-1);
- end Pendulum_Input;
- task Pendulum_Output is
- pragma Priority(System.Priority'Last-2);
- end Pendulum_Output;
- Column_Count: Constant := 12 * 6;
- Margin: Constant := 10;
- Display_Buffer: Array (Byte range 0..Column_Count-1) of Byte;
- Displayed_Text: String := "`Erasmus VLC";
- Sig_Left_Known: Boolean := False; -- determines of last A is already set
- Display_Reset: Boolean := False;
- P: Pendulum_State;
- -- UTILITIES - not used in final version --
- procedure Print_Time (T: Time) is
- Sec: Seconds_Count;
- Hnd: Time_Span;
- begin
- Split (T, Sec, Hnd);
- Put_Line (Seconds_Count'Image (Sec mod 100) & "+" & Duration'Image (To_Duration (Hnd)));
- end Print_Time;
- procedure Print_Time_Span (T: Time_Span) is
- begin
- Put_Line (Duration'Image (To_Duration (T)));
- end Print_Time_Span;
- -- END OF UTILITIES --
- ---------------------------------------------------------------------------------------------------
- task body Pendulum_Input is
- Next: Time := Clock;
- Period: Time_Span := Microseconds (10);
- PS: Pendulum_Signals;
- begin
- loop
- P.Test_Inputs;
- PS := P.Get_Pendulum_Signals;
- P.Reset_Pendulum_Signals;
- if (PS.Bar_Fall) then
- if (PS.Syn) then
- -- falling of the Bar+Syn
- P.On_Move_Right;
- if (Sig_Left_Known) then Display_Reset := True; end if;
- else
- if (Sig_Left_Known) then
- P.On_Move_Left;
- else
- P.On_First_Move_Left;
- Sig_Left_Known := True;
- end if;
- end if;
- end if;
- Next := Next + Period;
- delay until Next;
- end loop;
- end Pendulum_Input;
- ---------------------------------------------------------------------------------------------------
- task body Pendulum_Output is
- Column_Delay: Duration;
- Pendulum_Reverse: Time;
- Next: Time;
- begin
- while (not Display_Reset) loop
- delay 0.001;
- end loop;
- loop
- Column_Delay := To_Duration (P.Get_Cycle_Length / (2*(2*Margin + Column_Count)));
- Set_Leds (0);
- Pendulum_Reverse := P.Get_Start_Drawing + P.Get_Cycle_Length/2;
- delay until P.Get_Start_Drawing;
- Display_Reset := False;
- -- skip left margin
- Set_Leds (0);
- delay until (P.Get_Start_Drawing + To_Time_Span (Column_Delay)*Margin);
- -- draw the image (pendulum going right
- Next := Clock;
- for Column in 0..Column_Count-1 loop
- Set_Leds ( Display_Buffer (Byte (Column)) );
- Next := Next + To_Time_Span (Column_Delay);
- delay until Next;
- end loop;
- -- skip right margin
- Set_Leds (0);
- --delay Column_Delay*(2*Margin-1);
- delay until Pendulum_Reverse;
- delay until (Pendulum_Reverse + To_Time_Span (Column_Delay) * Margin);
- -- draw the image (pendulum going left)
- Next := Clock;
- for Column in 0..Column_Count-1 loop
- Set_Leds ( Display_Buffer (Byte (Column_Count-Column-1)) );
- Next := Next + To_Time_Span (Column_Delay);
- delay until Next;
- end loop;
- if (not Display_Reset) then
- Reset_Leds;
- while (not Display_Reset) loop
- delay 0.0001;
- end loop;
- Next := Clock + To_Time_Span (Column_Delay)*Margin;
- delay until Next;
- end if;
- end loop;
- end Pendulum_Output;
- ---------------------------------------------------------------------------------------------------
- begin
- for i in 0..11 loop
- for j in 0..4 loop
- Display_Buffer (Byte(i*6+j)) := Char_Map (Displayed_Text (i+1), j);
- end loop;
- Display_Buffer (Byte (i*6+5)) := 0;
- end loop;
- end Pendulum;
Add Comment
Please, Sign In to add comment