···65656666 -- Tune: vertical speed (0-63) at which all 10 LEDs are fully lit.
6767 -- Lower = more sensitive (fewer LEDs at low speed fill up faster).
6868+ -- Higher = better dynamic range across the full velocity range.
6869 -- Higher = less sensitive (need a harder bounce to light all LEDs).
6969- constant LED_FULL_VEL : integer := 16;
7070+ constant LED_FULL_VEL : integer := 48;
70717172 -- Animation
7273 signal squish : std_logic_vector(3 downto 0) := (others => '0');
···8687 -- Absolute value of vertical velocity.
8788 abs_vel_y <= (not vel_y) + 1 when vel_y(9) = '1' else vel_y;
88898989- -- Scale so LED_FULL_VEL maps to all 10 LEDs on (1023); clamp above that.
9090- vel_out <= CONV_STD_LOGIC_VECTOR(1023, 10)
9191- when CONV_INTEGER(abs_vel_y) >= LED_FULL_VEL else
9292- CONV_STD_LOGIC_VECTOR(CONV_INTEGER(abs_vel_y) * 1023 / LED_FULL_VEL, 10);
9090+ -- Thermometer-encode speed to a horizontal bar: each bit = one LED.
9191+ -- n LEDs lit from LSB up → 0000011111 for n=5, 1111111111 for n=10.
9292+ vel_bar : process(abs_vel_y)
9393+ variable v : integer;
9494+ variable n : integer range 0 to 10;
9595+ begin
9696+ v := CONV_INTEGER(abs_vel_y);
9797+ if v >= LED_FULL_VEL then n := 10;
9898+ else n := v * 10 / LED_FULL_VEL;
9999+ end if;
100100+ case n is
101101+ when 0 => vel_out <= "0000000000";
102102+ when 1 => vel_out <= "0000000001";
103103+ when 2 => vel_out <= "0000000011";
104104+ when 3 => vel_out <= "0000000111";
105105+ when 4 => vel_out <= "0000001111";
106106+ when 5 => vel_out <= "0000011111";
107107+ when 6 => vel_out <= "0000111111";
108108+ when 7 => vel_out <= "0001111111";
109109+ when 8 => vel_out <= "0011111111";
110110+ when 9 => vel_out <= "0111111111";
111111+ when others => vel_out <= "1111111111";
112112+ end case;
113113+ end process vel_bar;
9311494115 char_width <= SIZE + ("000000" & squish) when squish_h = '0'
95116 else SIZE - ("000000" & squish(3 downto 1));