1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: fix led velocity

dunkirk.sh 6f116668 e927f89c

verified
+26 -5
+26 -5
physics_engine.vhd
··· 65 65 66 66 -- Tune: vertical speed (0-63) at which all 10 LEDs are fully lit. 67 67 -- Lower = more sensitive (fewer LEDs at low speed fill up faster). 68 + -- Higher = better dynamic range across the full velocity range. 68 69 -- Higher = less sensitive (need a harder bounce to light all LEDs). 69 - constant LED_FULL_VEL : integer := 16; 70 + constant LED_FULL_VEL : integer := 48; 70 71 71 72 -- Animation 72 73 signal squish : std_logic_vector(3 downto 0) := (others => '0'); ··· 86 87 -- Absolute value of vertical velocity. 87 88 abs_vel_y <= (not vel_y) + 1 when vel_y(9) = '1' else vel_y; 88 89 89 - -- Scale so LED_FULL_VEL maps to all 10 LEDs on (1023); clamp above that. 90 - vel_out <= CONV_STD_LOGIC_VECTOR(1023, 10) 91 - when CONV_INTEGER(abs_vel_y) >= LED_FULL_VEL else 92 - CONV_STD_LOGIC_VECTOR(CONV_INTEGER(abs_vel_y) * 1023 / LED_FULL_VEL, 10); 90 + -- Thermometer-encode speed to a horizontal bar: each bit = one LED. 91 + -- n LEDs lit from LSB up → 0000011111 for n=5, 1111111111 for n=10. 92 + vel_bar : process(abs_vel_y) 93 + variable v : integer; 94 + variable n : integer range 0 to 10; 95 + begin 96 + v := CONV_INTEGER(abs_vel_y); 97 + if v >= LED_FULL_VEL then n := 10; 98 + else n := v * 10 / LED_FULL_VEL; 99 + end if; 100 + case n is 101 + when 0 => vel_out <= "0000000000"; 102 + when 1 => vel_out <= "0000000001"; 103 + when 2 => vel_out <= "0000000011"; 104 + when 3 => vel_out <= "0000000111"; 105 + when 4 => vel_out <= "0000001111"; 106 + when 5 => vel_out <= "0000011111"; 107 + when 6 => vel_out <= "0000111111"; 108 + when 7 => vel_out <= "0001111111"; 109 + when 8 => vel_out <= "0011111111"; 110 + when 9 => vel_out <= "0111111111"; 111 + when others => vel_out <= "1111111111"; 112 + end case; 113 + end process vel_bar; 93 114 94 115 char_width <= SIZE + ("000000" & squish) when squish_h = '0' 95 116 else SIZE - ("000000" & squish(3 downto 1));