Forum Discussion
Altera_Forum
Honored Contributor
14 years agoHi guys.
I already solved my problem. We figured that even a single press (say a second duration) could mean many many make codes are being sent out from the keyboard. Our solution is to detect the key press at the end of the break stage (using the second byte of the break code: break code is F0 follows by the make code of the key being released). This is our solution:
process(done) begin
if(done = '1') then
if(current_state = IDLE) then
intLeft <= '0';
intRight <= '0';
intDown <= '0';
intUp <= '0';
int_move_en <= '0';
if (hex = "11110000") then next_state <= RECEIVED_BREAK; end if; -- if F0 is received
elsif(current_state = RECEIVED_BREAK) then
if(hex = "00011101") then intUp <= '1'; int_move_en <= '1'; end if;
if(hex = "00011011") then intDown <= '1'; int_move_en <= '1'; end if;
if(hex = "00100011") then intRight <= '1'; int_move_en <= '1'; end if;
if(hex = "00011100") then intLeft <= '1'; int_move_en <= '1'; end if;
next_state <= IDLE;
end if;
end if;
end process;