library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.all;
USE IEEE.STD_LOGIC_UNSIGNED.all;
entity oled_module_controllerv1 is
Port ( clk : in STD_LOGIC;
rst : in STD_LOGIC;
preset : in std_logic ;
key_in: in std_logic_vector (0 to 15) ;
adt_sec10 : in std_logic_vector(3 downto 0) ;
status_reg : in std_logic_vector( 1 downto 0) ;
led : out std_logic_vector(1 downto 0) ;
cdt_hour10 , cdt_hour1, cdt_min10 ,cdt_min1, cdt_sec10 ,cdt_sec1 : in std_logic_vector (3 downto 0) ;
adt_day100,adt_day10 ,adt_day1 : in std_logic_Vector ( 3 downto 0) ;
adt_sec1 : in std_logic_vector( 3 downto 0) ;
adt_min10, adt_min1 : in std_logic_vector( 3 downto 0) ;
adt_hour10,adt_hour1:in std_logic_vector( 3 downto 0) ;
data_out : inout STD_LOGIC_vector( 7 downto 0) ;
rs : out STD_LOGIC;
cursor : out std_logic_vector( 3 downto 0) ;
rw : out STD_LOGIC;
e : out STD_LOGIC;
sec0_En ,sec1_en , min0_en, min1_en , hour1_en, hour0_en : out std_logic ;
dac_a0 , dac_scl, dac_sda : out std_logic );
end oled_module_controllerv1;
architecture Behavioral of oled_module_controllerv1 is
signal clock_count : unsigned ( 23 downto 0) :=(others=>'0') ;
signal clk_enable400 : std_logic :='0' ;
type state_type is (
power_up,reset1, reset2, reset3, func_set, display_on, mode_set, line2, return_home, drop_lcd_e, display_off, display_clear ,line2_data,char_mode, cursor_shift,
adt_state,sec10,sec1 ,min10,min1,coln1,coln2, hour10 , hour1,day100,day10 ,day1 ,dcoln,
cdth10 ,cdth1, cdtm10,cdtm1 ,cdts10,cdts1, status ,coln3,coln4,coln5,coln6,coln7 ,cdt_ih10,cdt_ih1, cdt_im10,cdt_im1,cdt_is10,cdt_is1
, dram_address,rst1,rst2,rst3,rst4,disp_off, func, clear_screen ,disp_on, MODE ,ADDR, message_enter ,
second_line,CURSOR_ON,l2 , second_linedata,zero , one , two , three , four, five , six , seven, eight , nine , forward , backward , data_delay , delay , time_save,
enter_h1, enter_h0 , hour_coln , min_coln , enter_min1 ,enter_min0 , enter_sec1 , enter_sec0,
h1_0 ,h1_1,h1_2 ,h1_delay,h1_cursor_delay , h1_forward , h0_0, h0_1,h0_2,h0_3 ,h0_delay,h0_forward_cursor_delay,h0_backward_cursor_delay,
h0_forward, h0_backward , hour_coln_forward , hour_coln_backward, min_coln_forward, min_coln_backward , hour_coln_forward_delay,hour_coln_backward_delay,
min_coln_forward_delay,min_coln_backward_delay,m1_forward_cursor_delay,m1_backward_cursor_delay,s1_backward_cursor_delay,s1_forward_cursor_delay,
m1_0 ,m1_1,m1_2 ,m1_3,m1_4,m1_5,m1_6,m1_7,m1_8 , m1_9 , m1_delay , m1_forward , m1_backward , m0_0, m0_1,m0_2,m0_3 ,m0_4,m0_5,m0_6,m0_7,m0_8,m0_9 , m0_delay,m0_forward_cursor_delay,m0_backward_cursor_delay,
m0_forward, m0_backward ,
s1_0 ,s1_1,s1_2 ,s1_3,s1_4,s1_5,s1_6,s1_7,s1_8 , s1_9 , s1_delay, s1_forward , s1_backward , s0_0, s0_1,s0_2,s0_3 ,s0_4,s0_5,s0_6,s0_7,s0_8,s0_9,s0_delay,s0_forward_cursor_delay,s0_backward_cursor_delay,
s0_forward, s0_backward ,timesave ,time_save_backward, time_save_backward_cursor_delay
);
signal state, next_command : state_type;
signal data_bus : std_logic_vector ( 7 downto 0) ;
signal lcd_e, lcd_rs, lcd_rw_int : std_Logic ;
type character_string is array ( 0 to 15 ) of STD_LOGIC_VECTOR( 7 downto 0 );
signal lcd_display_string : character_string;
signal lcd_display_string_01 : character_string;
signal lcd_display_string_02 : character_string;
signal lcd_display_string_03 : character_string;
signal next_char : STD_LOGIC_VECTOR(7 downto 0);
signal char_count : STD_LOGIC_VECTOR(4 downto 0);
signal counter : unsigned ( 26 downto 0) :=( others=>'0') ;
signal sec_bcd: unsigned( 3 downto 0) :=( others=>'0') ;
signal sec_en: std_logic ;
signal sec_out : std_logic_vector( 7 downto 0) ;
------------------adt ------------
type str1 is array ( 0 to 5) of std_logic_Vector ( 7 downto 0) ;
signal adt_string,cdt_string : str1;
signal adt :std_logic_vector ( 7 downto 0) ;
signal cdt: std_logic_vector( 7 downto 0) ;
signal str_count : std_logic_vector( 3 downto 0) :="0000" ;
signal message_count : std_Logic_vector( 3 downto 0) ;
signal wait_count : std_logic_vector( 19 downto 0) := (others=>'0') ;
signal wait_time : integer range 0 to 119 :=0 ;
signal enable_key : std_logic:='0' ;
signal adt_d1s: std_logic_vector ( 7 downto 0) ;
signal adt_d10s : std_logic_vector ( 7 downto 0) ;
signal adt_d100s: std_logic_vector ( 7 downto 0) ;
signal adt_sec1s: std_logic_vector ( 7 downto 0) ;
signal adt_sec10s : std_logic_vector ( 7 downto 0) ;
signal adt_min1s: std_logic_vector ( 7 downto 0) ;
signal adt_min10s : std_logic_vector ( 7 downto 0) ;
signal adt_hour1s: std_logic_vector ( 7 downto 0) ;
signal adt_hour10s : std_logic_vector ( 7 downto 0) ;
--------------------------cdt--------------------------------
signal cdt_sec1s: std_logic_vector ( 7 downto 0) ;
signal cdt_sec10s : std_logic_vector ( 7 downto 0) ;
signal cdt_min1s: std_logic_vector ( 7 downto 0) ;
signal cdt_min10s : std_logic_vector ( 7 downto 0) ;
signal cdt_hour1s: std_logic_vector ( 7 downto 0) ;
signal cdt_hour10s : std_logic_vector ( 7 downto 0) ;
---------------------xxxxxxxxxxxxxxxx----------
signal key_stored, fkey_stored: std_logic_vector( 7 downto 0) ;
signal key_q : std_logic_vector( 0 to 15 ) ;
signal hour2_reg , hour1_reg : std_logic_Vector ( 3 downto 0) ;
signal sec2_reg , sec1_reg , min2_reg , min1_reg : std_logic_vector( 3 downto 0) ;
-------status -register ---------
signal sts_reg : std_logic_vector ( 1 downto 0) ;
signal wait_1sec : integer range 0 to 60000 := 0 ;
signal space_count : integer range 0 to 19 := 0 ;
signal one_mscounter : natural range 0 to 835 :=0 ; -------counter for 10 mhz clock enable for 10 mhz checking
signal f1khz : std_logic ;
signal cursor_count1: std_logic_Vector ( 3 downto 0) :="0000" ;
signal cursor_count2 : std_logic_Vector ( 3 downto 0) :="0111" ;
signal cursor_count : std_Logic_vector ( 3 downto 0) :="0000" ;
signal h1_reg , h0_reg , m1_reg , m0_reg , s1_reg , s0_reg : std_logic_vector (0 to 15) ;
signal h1_q , h0_q, m1_q , m0_q , s1_q , s0_q : std_logic_vector (0 to 15) ;
attribute mark_debug : string ;
attribute mark_debug of key_q : signal is "true" ;
attribute mark_debug of lcd_e : signal is "true" ;
attribute mark_debug of lcd_rs : signal is "true" ;
attribute mark_debug of lcd_rw_int : signal is "true" ;
attribute mark_debug of data_bus : signal is "true" ;
attribute mark_debug of preset : signal is "true" ;
attribute mark_debug of cursor_count : signal is "true" ;
begin
dac_a0<=lcd_rs ;
dac_scl<= lcd_rw_int;
dac_sda<=lcd_e ;
---------------=============================
lcd_display_string <=( X"45" , X"6E" , X"74" ,X"65" , X"72" , X"20" ,X"63" , X"64" , X"74" , X"20" , X"54" , X"69" , X"6D" , X"65" , X"20", X"20") ;
next_char<= lcd_display_string( conv_integer( message_count)) ;
---------===============================
process(f1khz )
begin
if rising_edge ( f1khz ) then
key_q <= key_in ;
end if ;
end process ;
-----------------xxxxxxxxx----------------------------
-----------adt day---------------------------------
--------------------------------------------
process ( adt_day1) begin
case adt_day1 is
when "0000" =>
adt_d1s<=x"30" ;
when "0001"=>
adt_d1s<=x"31" ;
when "0010"=>
adt_d1s <=x"32" ;
when "0011"=>
adt_d1s<=x"33" ;
when "0100"=>
adt_d1s <=x"34" ;
when "0101"=>
adt_d1s <=x"35" ;
when others=>
adt_d1s <=x"30" ;
end case ;
end process ;
process ( adt_day10) begin
case adt_day10 is
when "0000" =>
adt_d10s<=x"30" ;
when "0001"=>
adt_d10s<=x"31" ;
when "0010"=>
adt_d10s <=x"32" ;
when "0011"=>
adt_d10s<=x"33" ;
when "0100"=>
adt_d10s <=x"34" ;
when "0101"=>
adt_d10s <=x"35" ;
when "0110"=>
adt_d10s<=x"36" ;
when others=>
adt_d10s <=x"30" ;
end case ;
end process ;
process ( adt_day100) begin
case adt_day100 is
when "0000" =>
adt_d100s<=x"30" ;
when "0001"=>
adt_d100s<=x"31" ;
when "0010"=>
adt_d100s <=x"32" ;
when "0011"=>
adt_d100s<=x"33" ;
when others=>
adt_d100s <=x"30" ;
end case ;
end process ;
----------------------------XXXXXXXXXXXXXXXXXX---------------------------------
------------------ADT HOUR ---------------------------------------------------
----------=============================================
process ( adt_hour10)
begin
case adt_hour10 is
when "0000" =>
adt_hour10s<=x"30" ;
when "0001"=>
adt_hour10s<=x"31" ;
when "0010"=>
adt_hour10s <=x"32" ;
when "0011"=>
adt_hour10s<=x"33" ;
when "0100"=>
adt_hour10s <=x"34" ;
when "0101"=>
adt_hour10s <=x"35" ;
when "0110"=>
adt_hour10s<=x"36" ;
when "0111"=>
adt_hour10s <=x"37" ;
when "1000"=>
adt_hour10s <=x"38" ;
when "1001"=>
adt_hour10s <=x"39" ;
when others =>
adt_hour10s <= x"30" ;
end case ;
end process ;
process ( adt_hour1)
begin
case adt_hour1 is
when "0000" =>
adt_hour1s<=x"30" ;
when "0001"=>
adt_hour1s <=x"31" ;
when "0010"=>
adt_hour1s<=x"32" ;
when "0011"=>
adt_hour1s <=x"33" ;
when "0100"=>
adt_hour1s <=x"34" ;
when "0101"=>
adt_hour1s <=x"35" ;
when "0110"=>
adt_hour1s <=x"36" ;
when "0111"=>
adt_hour1s <=x"37" ;
when "1000"=>
adt_hour1s <=x"38" ;
when "1001"=>
adt_hour1s <=x"39" ;
when others =>
adt_hour1s <= x"30" ;
end case ;
end process ;
----------------------XXXXXXXXXXXXXXXXX-------------------------------
--------------------ADT MIN-------------------------------------------------
------------------======================================
process ( adt_min10)
begin
case adt_min10 is
when "0000" =>
adt_min10s<=x"30" ;
when "0001"=>
adt_min10s <=x"31" ;
when "0010"=>
adt_min10s <=x"32" ;
when "0011"=>
adt_min10s <=x"33" ;
when "0100"=>
adt_min10s <=x"34" ;
when "0101"=>
adt_min10s <=x"35" ;
when "0110"=>
adt_min10s <=x"36" ;
when "0111"=>
adt_min10s <=x"37" ;
when "1000"=>
adt_min10s <=x"38" ;
when "1001"=>
adt_min10s <=x"39" ;
when others =>
adt_min10s <= x"30" ;
end case ;
end process ;
process ( adt_min1)
begin
case adt_min1 is
when "0000" =>
adt_min1s<=x"30" ;
when "0001"=>
adt_min1s <=x"31" ;
when "0010"=>
adt_min1s <=x"32" ;
when "0011"=>
adt_min1s <=x"33" ;
when "0100"=>
adt_min1s <=x"34" ;
when "0101"=>
adt_min1s <=x"35" ;
when "0110"=>
adt_min1s <=x"36" ;
when "0111"=>
adt_min1s <=x"37" ;
when "1000"=>
adt_min1s <=x"38" ;
when "1001"=>
adt_min1s <=x"39" ;
when others =>
adt_min1s <= x"30" ;
end case ;
end process ;
----------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-----------------------------
---------------ADT SEC-------------------------------------------------
-------===============================================
process ( adt_sec1)
begin
case (adt_sec1 ) is
when "0000" =>
adt_sec1s <=x"30" ;
when "0001"=>
adt_sec1s <=x"31" ;
when "0010"=>
adt_sec1s <=x"32" ;
when "0011"=>
adt_sec1s <=x"33" ;
when "0100"=>
adt_sec1s <=x"34" ;
when "0101"=>
adt_sec1s <=x"35" ;
when "0110"=>
adt_sec1s <=x"36" ;
when "0111"=>
adt_sec1s <=x"37" ;
when "1000"=>
adt_sec1s <=x"38" ;
when "1001"=>
adt_sec1s <=x"39" ;
when others =>
adt_sec1s <= x"30" ;
end case ;
end process ;
process ( adt_sec10)
begin
case adt_sec10 is
when "0000" =>
adt_sec10s <=x"30" ;
when "0001"=>
adt_sec10s <=x"31" ;
when "0010"=>
adt_sec10s <=x"32" ;
when "0011"=>
adt_sec10s <=x"33" ;
when "0100"=>
adt_sec10s <=x"34" ;
when "0101"=>
adt_sec10s <=x"35" ;
when "0110"=>
adt_sec10s <=x"36" ;
when "0111"=>
adt_sec10s <=x"37" ;
when "1000"=>
adt_sec10s <=x"38" ;
when "1001"=>
adt_sec10s <=x"39" ;
when others =>
adt_sec10s <= x"30" ;
end case ;
end process ;
--------------=============================cdt=======================
----============================================================
----------------------------XXXXXXXXXXXXXXXXXX---------------------------------
------------------CDT HOUR ---------------------------------------------------
----------=============================================
process ( cdt_hour10)
begin
case cdt_hour10 is
when "0000" =>
cdt_hour10s<=x"30" ;
when "0001"=>
cdt_hour10s<=x"31" ;
when "0010"=>
cdt_hour10s <=x"32" ;
when "0011"=>
cdt_hour10s<=x"33" ;
when "0100"=>
cdt_hour10s <=x"34" ;
when "0101"=>
cdt_hour10s <=x"35" ;
when "0110"=>
cdt_hour10s<=x"36" ;
when "0111"=>
cdt_hour10s <=x"37" ;
when "1000"=>
cdt_hour10s <=x"38" ;
when "1001"=>
cdt_hour10s <=x"39" ;
when others =>
cdt_hour10s <= x"30" ;
end case ;
--end if;
--end if ;
end process ;
process ( cdt_hour1)
begin
case cdt_hour1 is
when "0000" =>
cdt_hour1s<=x"30" ;
when "0001"=>
cdt_hour1s <=x"31" ;
when "0010"=>
cdt_hour1s<=x"32" ;
when "0011"=>
cdt_hour1s <=x"33" ;
when "0100"=>
cdt_hour1s <=x"34" ;
when "0101"=>
cdt_hour1s <=x"35" ;
when "0110"=>
cdt_hour1s <=x"36" ;
when "0111"=>
cdt_hour1s <=x"37" ;
when "1000"=>
cdt_hour1s <=x"38" ;
when "1001"=>
cdt_hour1s <=x"39" ;
when others =>
cdt_hour1s <= x"30" ;
end case ;
end process ;
----------------------XXXXXXXXXXXXXXXXX-------------------------------
--------------------ADT MIN-------------------------------------------------
------------------======================================
process ( cdt_min10)
begin
case cdt_min10 is
when "0000" =>
cdt_min10s<=x"30" ;
when "0001"=>
cdt_min10s <=x"31" ;
when "0010"=>
cdt_min10s <=x"32" ;
when "0011"=>
cdt_min10s <=x"33" ;
when "0100"=>
cdt_min10s <=x"34" ;
when "0101"=>
cdt_min10s <=x"35" ;
when "0110"=>
cdt_min10s <=x"36" ;
when "0111"=>
cdt_min10s <=x"37" ;
when "1000"=>
cdt_min10s <=x"38" ;
when "1001"=>
cdt_min10s <=x"39" ;
when others =>
cdt_min10s <= x"30" ;
end case ;
end process ;
process ( cdt_min1)
begin
case cdt_min1 is
when "0000" =>
cdt_min1s<=x"30" ;
when "0001"=>
cdt_min1s <=x"31" ;
when "0010"=>
cdt_min1s <=x"32" ;
when "0011"=>
cdt_min1s <=x"33" ;
when "0100"=>
cdt_min1s <=x"34" ;
when "0101"=>
cdt_min1s <=x"35" ;
when "0110"=>
cdt_min1s <=x"36" ;
when "0111"=>
cdt_min1s <=x"37" ;
when "1000"=>
cdt_min1s <=x"38" ;
when "1001"=>
cdt_min1s <=x"39" ;
when others =>
cdt_min1s <= x"30" ;
end case ;
end process ;
----------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-----------------------------
---------------ADT SEC-------------------------------------------------
-------===============================================
process ( cdt_sec1)
begin
case (cdt_sec1 ) is
when "0000" =>
cdt_sec1s <=x"30" ;
when "0001"=>
cdt_sec1s <=x"31" ;
when "0010"=>
cdt_sec1s <=x"32" ;
when "0011"=>
cdt_sec1s <=x"33" ;
when "0100"=>
cdt_sec1s <=x"34" ;
when "0101"=>
cdt_sec1s <=x"35" ;
when "0110"=>
cdt_sec1s <=x"36" ;
when "0111"=>
cdt_sec1s <=x"37" ;
when "1000"=>
cdt_sec1s <=x"38" ;
when "1001"=>
cdt_sec1s <=x"39" ;
when others =>
cdt_sec1s <= x"30" ;
end case ;
end process ;
process ( cdt_sec10)
begin
case cdt_sec10 is
when "0000" =>
cdt_sec10s <=x"30" ;
when "0001"=>
cdt_sec10s <=x"31" ;
when "0010"=>
cdt_sec10s <=x"32" ;
when "0011"=>
cdt_sec10s <=x"33" ;
when "0100"=>
cdt_sec10s <=x"34" ;
when "0101"=>
cdt_sec10s <=x"35" ;
when "0110"=>
cdt_sec10s <=x"36" ;
when "0111"=>
cdt_sec10s <=x"37" ;
when "1000"=>
cdt_sec10s <=x"38" ;
when "1001"=>
cdt_sec10s <=x"39" ;
when others =>
cdt_sec10s <= x"30" ;
end case ;
end process ;
------------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-----------------------
adt_string <=( x"41" ,x"44" ,x"54" , x"3a",x"20" ,x"20" ) ;
adt <= adt_string (conv_integer ( str_count ) ) ;
cdt_string <=(x"43" , x"44" , x"54" ,x"3a",x"20" ,x"20" );
cdt <= cdt_string ( conv_integer ( str_count)) ;
-- BIDIRECTIONAL TRI STATE LCD DATA BUS
data_out <= data_bus when lcd_rw_int = '0' else "ZZZZZZZZ";
-- LCD_RW PORT is assigned to it matching SIGNAL
rw <= lcd_rw_int;
e<=lcd_e ;
rs <=lcd_rs ;
process ( clk )
begin
if rising_edge ( clk) then
if ( rst='1') then
clock_count <=(others=>'0') ;
clk_enable400<='0' ;
else
if ( clock_count <= 416) then -----------240 khz enable signal for zedboard working 100 mhz
-- if ( clock_count <= 99999) then -----------240 khz enable signal for zedboard working 100 mhz
-- if ( clock_count <= 99999) then -----------240 khz enable signal for zedboard working 100 mhz
-- if ( clock_count <= 24999) then ----------- working 4khz final
clock_count <= clock_count +1 ;
clk_enable400 <='0' ;
else
clock_count<=(others=>'0') ;
clk_enable400 <='1';
end if ;
end if ;
end if ;
end process ;
------------xx-------------------------
process ( clk, rst )
begin
if (rst='1') then
one_mscounter <=0;
f1khz <='0';
elsif rising_edge( clk) then
-- if ( one_mscounter =835) then ---- for zedboard default 120 khz
-- if ( one_mscounter =417) then ---- for zedboard default 120 khz 120 khz enable freequency
if ( one_mscounter =417) then ---- for zedboard default 120 khz
-- if ( one_mscounter =4999) then -------for 10 mhz clock
-- if ( one_mscounter =62499) then -------for 1khz clock for zybo ----working
one_mscounter <=0;
f1khz <= not (f1khz) ; ----240 khz frequeny
else
one_mscounter <= one_mscounter +1 ;
end if ;
end if ;
end process;
------------------------------------------------------------------
---------------statemachine cotnrol-----------------------------
--------------------------------------------------------------------
process ( f1khz,rst)
begin
if (rst='1') then
state <= power_up;
data_bus <= x"38"; -- RESET ---default
next_command <= reset1;
lcd_e <= '1'; ------------enableing data in 120 khz half of the clk_enable
lcd_rs <= '0';
lcd_rw_int <= '0';
str_count <= "0000" ;
wait_count <=(others=>'0') ;
message_count<=(others=>'0') ;
sec1_en <='0';
sec0_en <='0' ;
min1_en <='0' ;
min0_en <='0' ;
hour1_en <='0' ;
hour0_en <='0' ;
cursor_count <="0000" ;
cursor_count1<="0000";
cursor_count2<="0111";
elsif rising_edge(f1khz) then
-- if clk_enable400 = '1' then
case (state ) is
when power_up =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38"; -- EXTERNAL RESET
state <= drop_lcd_e;
if ( wait_count =120) then ------ testing
wait_count <=(others=>'0') ;
next_command <= reset1; ----500 ms reached
else
wait_count <= wait_count +1 ;
end if ;
char_count <= "00000";
if ( preset='1') then
next_command <= rst1 ;
end if ;
--======================= INITIALIZATION START ============================--
when reset1 =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38"; -- EXTERNAL RESET
state <= drop_lcd_e;
if ( wait_count =120) then ------ testing
wait_count <=(others=>'0') ;
next_command <= reset2; ----500 ms reached
else
wait_count <= wait_count +1 ;
end if ;
char_count <= "00000";
if ( preset='1') then
next_command <= rst1 ;
end if ;
when reset2 =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38"; -- EXTERNAL RESET
state <= drop_lcd_e;
next_command <= reset3;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when reset3 =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38"; -- EXTERNAL RESET
state <= drop_lcd_e;
next_command <= func_set;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when func_set =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38"; -- Set Function to 8-bit transfer, 2 line display and a 5x8 Font size
state <= drop_lcd_e;
next_command <= display_off; ---default working
-- next_command <= display_clear;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when display_off =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"08"; -- Turns OFF the Display, Cursor OFF and Blinking Cursor Position OFF.......
-- data_bus <= x"0D"; -- (0F = Display ON and Cursor ON, Blinking cursor position ON)
state <= drop_lcd_e;
next_command <= display_clear;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when display_clear =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"01"; -- Clears the Display
state <= drop_lcd_e;
next_command <= display_on;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when display_on =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"0C"; -- Turns on the Display (0E = Display ON, Cursor ON and Blinking cursor OFF)
-- data_bus <= x"0D";
state <= drop_lcd_e;
next_command <= dram_address;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when cursor_shift =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"14";
state <= drop_lcd_e;
next_command <= mode_set;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when char_mode =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"17";
state <= drop_lcd_e;
next_command <= mode_set;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when dram_address =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= "10000000";
state <= drop_lcd_e;
next_command <= mode_set;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when mode_set =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"06"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=adt_state ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when adt_state =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt ;
next_command <=adt_state; ----added
if ( str_count ="0101") then
str_count <="0000" ;
next_command<=day100;
else
str_count <= str_count +1 ;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when day100=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_d100s;
next_command<=day10;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when day10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_d10s;
next_command<=day1;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when day1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_d1s;
next_command<=dcoln;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when dcoln=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=x"3a";
next_command<=hour10;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when hour10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_hour10s;
next_command<=hour1;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when hour1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_hour1s;
next_command<=coln2;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when coln2=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=x"3a";
next_command<=min10;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when min10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_min10s;
next_command<=min1;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when min1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_min1s;
next_command<=coln1;
if ( preset='1') then
next_command <= rst1 ;
end if ;
-----------------------------------------------------
when coln1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=x"3a";
next_command<=sec10;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when sec10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_sec10s;
next_command<=sec1;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when sec1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_sec1s;
next_command<=line2;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when line2 =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"c0"; ---c0 default ---working
-- data_bus <= x"40";
state <= drop_lcd_e;
-- next_command<=cdt_c;
next_command<=line2_data;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when line2_data=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= cdt ;
next_command <=line2_data; ----added
if ( str_count ="0101") then
str_count <="0000" ;
next_command<=cdth10;
-- next_command<=line3;
else
str_count <= str_count +1 ;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
----------------==========================cdt -timing
when cdth10=>
----------------------------
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=cdt_hour10s;
next_command<=cdth1;
if ( preset='1') then
next_command <= rst1 ;
end if ;
--------------------------------
when cdth1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=cdt_hour1s;
next_command<=coln3;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when coln3=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"3a";
next_command<=cdtm10;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when cdtm10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=cdt_min10s;
next_command<=cdtm1;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when cdtm1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=cdt_min1s;
next_command<=coln4;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when coln4=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=x"3a";
next_command<=cdts10;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when cdts10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=cdt_sec10s;
next_command<=cdts1;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when cdts1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=cdt_sec1s;
next_command<=coln5 ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when coln5=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=x"3a";
next_command<=status;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when status =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
if ( status_reg ="00" ) then
data_bus <=x"30";
elsif ( status_reg="10" ) then
data_bus<=x"55" ;
elsif (status_reg="01" ) then
data_bus <=x"44" ;
elsif (status_reg="11" ) then
data_bus <=x"48" ;
else
data_bus <=x"55" ;
end if ;
next_command<=return_home;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when return_home =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"02"; ----just now commented
state <= drop_lcd_e;
next_command <=adt_state ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when drop_lcd_e =>
state <= next_command;
lcd_e <= '0';
when rst1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
sec1_en <='0';
data_bus <= x"01" ; ---- defualt working x"38";
next_command <= rst2;
when rst2=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38"; ---38 working defualt
if ( wait_count =600) then ------ testing
wait_count <=(others=>'0') ;
next_command <= func; ----500 ms reached ----working
-- next_command <= message_enter; ----500 ms reached
else
wait_count <= wait_count +1 ;
end if ;
when rst3=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38";
next_command <= rst4; ----500 ms reached
when rst4=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38";
next_command <= func; ----500 ms reached
when func=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38";
-- next_command <= disp_off; ----500 ms reached WORKING
next_command <= disp_on; ----500 ms reached
when disp_off =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"08";
next_command <=clear_screen ; ----500 ms reached
when clear_screen=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"01";
next_command <= disp_on; ----500 ms reached
when disp_on =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"0C"; -- Turns on the Display (0E = Display ON, Cursor ON and Blinking cursor OFF)
-- data_bus <=x"0E"; ----display on , cursor on , blink off
-- next_command <= ADDR; ---- working default
next_command <= MODE;
when MODE =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"06";
-- data_bus <= x"07";
next_command <= ADDR;
when ADDR =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= "10000000"; ---dram selection
next_command <= message_enter;
when message_enter=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
sec1_en <='0';
sec0_en <='0' ;
min1_en <='0' ;
min0_en <='0' ;
hour1_en <='0' ;
hour0_en <='0' ;
data_bus <= next_char;
next_command <=message_enter;
if ( message_count ="1111") then
message_count <="0000" ;
IF ( PRESET='0') THEN
next_command<=second_line;
else
next_command<=time_save;
END IF ;
else
message_count <= message_count +1 ;
end if ;
when second_line=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"C0";
next_command<=cdt_ih10; ---default working
---------start added ------------------
when cdt_ih10=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
hour1_en <='1' ;
data_bus <=cdt_hour10s;
state <= drop_lcd_e;
next_command<=cdt_ih1;
when cdt_ih1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
hour0_en<='1' ;
data_bus <=cdt_hour1s;
next_command<=coln6;
when coln6=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"3a";
next_command<=cdt_im10;
when cdt_im10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
min1_en <='1' ;
data_bus <=cdt_min10s;
next_command<=cdt_im1;
when cdt_im1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
min0_en <='1' ;
data_bus <=cdt_min1s;
next_command<=coln7;
when coln7=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"3a";
next_command<=cdt_is10;
when cdt_is10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
sec1_en <='1' ;
data_bus <=cdt_sec10s;
next_command<=cdt_is1;
when cdt_is1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=cdt_sec1s;
next_command<=l2;
when l2=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"C0";
next_command<=CURSOR_ON;
cursor_count<="0000" ; -----added
when CURSOR_ON=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"0E"; -- Turns on the Display (0E = Display ON, Cursor ON and Blinking cursor OFF)
state <= drop_lcd_e;
next_command<= enter_h1; ---added
----------end cursor on -------
-----------------------added code for manual entry of the hour minuste and second
------------entry hour1-------------------------------------------
when enter_h1 =>
if (key_q=x"0100" ) then ------ 0
data_bus <= x"30" ;
state <= drop_lcd_e;
next_command<=h1_0 ;
end if ;
if ( key_q =x"0004" ) then ------1
data_bus <= x"31" ;
state <= drop_lcd_e;
next_command<=h1_1 ;
end if ;
if ( key_q =x"0008") then ----- 2
data_bus <=x"32" ;
state <= drop_lcd_e;
next_command<=h1_2 ;
end if ;
if (key_q=x"0020" ) then ----A SHIFT THE CURSOR TO THE LIFT
-- data_bus <= x"04" ; ------SHIFT CURSOR TO LEFT
data_bus <= x"14" ; -----SHIFT CURSOR POSITION TO LEFT
state <= drop_lcd_e;
next_command<=h1_forward; ------default
end if ;
--------------------------h1_state ---start ----------------
when h1_0=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"30"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=h1_delay ;
when h1_1=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"31"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=h1_delay ;
when h1_2=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"32"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=h1_delay ;
when h1_delay=>
lcd_e <= '0';
lcd_rs <= '1';
lcd_rw_int <= '0';
h1_reg <=key_q ;
if ( wait_1sec=60000) then ---- .5 sec wait
-- if ( wait_1sec=6) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count +1 ;
-- if ( cursor_count=1) then
else
wait_1sec <= wait_1sec+1 ;
end if ;
if ( cursor_count=1) then
state <=enter_h0 ;
end if ;
when h1_forward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"04"; -- Auto increment address and move cursor to the LEFT
data_bus <= x"14" ; ----SHIFT CURSOR POSTION TO LEFT
state <= drop_lcd_e;
next_command <=h1_cursor_delay ;
when h1_cursor_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
if ( wait_1sec=60000) then ---- .5 sec wait
-- if ( wait_1sec=6) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count +1 ;
else
wait_1sec <=wait_1sec+1 ;
end if ;
if ( cursor_count=1) then
state <=enter_h0 ;
end if ;
------------------end hour1 definition --
----------------------enter hous0 start ----==============
when enter_h0 =>
if (key_q=x"0100" ) then ------ 0
data_bus <= x"30" ;
state <= drop_lcd_e;
next_command<=h0_0 ;
end if ;
if ( key_q =x"0004" ) then ------1
data_bus <= x"31" ;
state <= drop_lcd_e;
next_command<=h0_1 ;
end if ;
if ( key_q =x"0008") then ----- 2
data_bus <=x"32" ;
state <= drop_lcd_e;
next_command<=h0_2 ;
end if ;
if (key_q=x"0010" ) then -------3
data_bus <= x"33" ;
state <= drop_lcd_e;
next_command<=h0_3 ;
end if ;
if (key_q=x"0020" ) then ----A SHIFT THE CURSOR TO THE LIFT
-- data_bus <= x"04" ; ------SHIFT CURSOR TO LEFT
-- lcd_e <= '1';
data_bus <= x"14" ; -----SHIFT CURSOR POSITION TO LEFT
state <= drop_lcd_e;
next_command<=h0_forward; ----default
-- next_command<=coln1;
end if ;
if (key_q=x"1000" ) then ---B SHIFT THE DISPLAY AND CURSOR POSITION TO RIGHT
-- data_bus <= x"06" ; ------SHIFT CURSOR TO RIGHT
data_bus <= x"10" ; -----SHIFT CURSOR POSITION TO RIGHT
state <= drop_lcd_e;
next_command<=h0_backward; ----default
end if ;
--------h0-----state----start
when h0_0=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"30"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=h0_delay ;
when h0_1=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"31"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=h0_delay ;
when h0_2=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"32"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=h0_delay ;
when h0_3=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"33"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=h0_delay ;
when h0_delay=>
lcd_e <= '0';
lcd_rs <= '1';
lcd_rw_int <= '0';
h0_reg <=key_q ;
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count +1 ;
else
wait_1sec<=wait_1sec+1 ;
-- end if ;
end if ;
if ( cursor_count=2) then
state<=hour_coln ;
end if ;
when h0_forward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"04"; -- Auto increment address and move cursor to the LEFT
data_bus <= x"14" ; ----SHIFT CURSOR POSTION TO LEFT
state <= drop_lcd_e;
next_command <=h0_forward_cursor_delay ;
when h0_backward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"06"; -- Auto increment address and move cursor to the right
data_bus <= x"10" ; ----SHIFT CURSOR POSTION TO RIGHT
state <= drop_lcd_e;
next_command <=h0_backward_cursor_delay ;
when h0_forward_cursor_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count +1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
if ( cursor_count=2) then
state<=hour_coln ;
end if ;
when h0_backward_cursor_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count -1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
if ( cursor_count=0) then
state <=enter_h1 ;
end if ;
-------- h0_end --------------------------------
----------------------------------------------hour--------coln----start -------------------------------------
when hour_coln=>
if (key_q=x"0020" ) then ----A SHIFT THE CURSOR TO THE LIFT
-- data_bus <= x"04" ; ------SHIFT CURSOR TO LEFT
data_bus <= x"14" ; -----SHIFT CURSOR POSITION TO LEFT
state <= drop_lcd_e;
next_command<=hour_coln_forward;
end if ;
if (key_q=x"1000" ) then ---B SHIFT THE DISPLAY AND CURSOR POSITION TO RIGHT
-- data_bus <= x"06" ; ------SHIFT CURSOR TO RIGHT
data_bus <= x"10" ; -----SHIFT CURSOR POSITION TO RIGHT
state <= drop_lcd_e;
next_command<=hour_coln_backward;
end if ;
when hour_coln_forward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"04"; -- Auto increment address and move cursor to the LEFT
data_bus <= x"14" ; ----SHIFT CURSOR POSTION TO LEFT
state <= drop_lcd_e;
next_command <=hour_coln_forward_delay ;
when hour_coln_backward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"06"; -- Auto increment address and move cursor to the right
data_bus <= x"10" ; ----SHIFT CURSOR POSTION TO RIGHT
state <= drop_lcd_e;
next_command <=hour_coln_backward_delay ;
when hour_coln_forward_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
if ( wait_1sec=60000) then ---- .5 sec wait
-- if ( wait_1sec=6) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count +1 ;
-- end if ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
if ( cursor_count =3) then
state<=enter_min1 ;
end if ;
when hour_coln_backward_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
if ( wait_1sec=60000) then ---- .5 sec wait
-- if ( wait_1sec=6) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count -1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
if ( cursor_count =1) then
state<= enter_h0;
end if ;
----------hour -----coln-----end -----------------------------------------
--------===============================================enter min 1 ----start ---------
when enter_min1 =>
if (key_q=x"0100" ) then ------ 0
data_bus <= x"30" ;
state <= drop_lcd_e;
next_command<=m1_0;
end if ;
if ( key_q =x"0004" ) then ------1
data_bus <= x"31" ;
state <= drop_lcd_e;
next_command<=m1_1;
end if ;
if ( key_q =x"0008") then ----- 2
data_bus <=x"32" ;
state <= drop_lcd_e;
next_command<=m1_2;
end if ;
if (key_q=x"0010" ) then -------3
data_bus <= x"33" ;
state <= drop_lcd_e;
next_command<=m1_3;
end if ;
if (key_q=x"0002" ) then -------4
data_bus <= x"34" ;
state <= drop_lcd_e;
next_command<=m1_4;
end if;
if (key_q=x"0040" ) then ------5
data_bus <= x"35" ;
state <= drop_lcd_e;
next_command<=m1_5;
end if ;
if (key_q=x"0200" ) then --------------6
data_bus <= x"36" ;
state <= drop_lcd_e;
next_command<=m1_6;
end if ;
if (key_q=x"0001" ) then ------ 7
data_bus <= x"37" ;
state <= drop_lcd_e;
next_command<=m1_7;
end if ;
if (key_q=x"0080" ) then ----- 8
data_bus <= x"38" ;
state <= drop_lcd_e;
next_command<=m1_8;
end if ;
if (key_q=x"0400" ) then ------ 9
data_bus <= x"39" ;
state <= drop_lcd_e;
next_command<=m1_9;
end if ;
if (key_q=x"0020" ) then ----A SHIFT THE CURSOR TO THE LIFT
-- data_bus <= x"04" ; ------SHIFT CURSOR TO LEFT
data_bus <= x"14" ; -----SHIFT CURSOR POSITION TO LEFT
state <= drop_lcd_e;
next_command<=m1_forward;
end if ;
if (key_q=x"1000" ) then ---B SHIFT THE DISPLAY AND CURSOR POSITION TO RIGHT
-- data_bus <= x"06" ; ------SHIFT CURSOR TO RIGHT
data_bus <= x"10" ; -----SHIFT CURSOR POSITION TO RIGHT
state <= drop_lcd_e;
next_command<=m1_backward;
end if ;
-------min1 _state definition
when m1_0=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"30"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m1_delay ;
when m1_1=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"31"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m1_delay ;
when m1_2=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"32"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m1_delay ;
when m1_3=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"33"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m1_delay ;
when m1_4=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"34"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m1_delay ;
when m1_5 =>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"35"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m1_delay ;
when m1_6=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"36"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m1_delay ;
when m1_7=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"37"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m1_delay ;
when m1_8=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"38"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m1_delay ;
when m1_9=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"39"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m1_delay ;
when m1_delay=>
lcd_e <= '0';
lcd_rs <= '1';
lcd_rw_int <= '0';
m1_reg <=key_q ;
wait_1sec <= wait_1sec+1 ;
if ( wait_1sec=60000) then ---- .5 sec wait
-- if ( wait_1sec=6) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count +1 ;
-- end if ;
end if ;
if ( cursor_count=4) then
state <=enter_min0 ;
end if ;
when m1_forward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"04"; -- Auto increment address and move cursor to the LEFT
data_bus <= x"14" ; ----SHIFT CURSOR POSTION TO LEFT
state <= drop_lcd_e;
next_command <=m1_forward_cursor_delay ;
when m1_backward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"06"; -- Auto increment address and move cursor to the right
data_bus <= x"10" ; ----SHIFT CURSOR POSTION TO RIGHT
state <= drop_lcd_e;
next_command <=m1_backward_cursor_delay ;
when m1_forward_cursor_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
if ( wait_1sec=60000) then ---- .5 sec wait
-- if ( wait_1sec=6) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count +1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
if ( cursor_count=4) then
state<=enter_min0 ;
end if ;
when m1_backward_cursor_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- wait_1sec <= wait_1sec+1 ;
if ( wait_1sec=60000) then ---- .5 sec wait
-- if ( wait_1sec=6) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count -1 ;
--
else
wait_1sec <= wait_1sec+1 ;
end if ;
if ( cursor_count =2) then
state<= hour_coln;
end if ;
-------min1___-definition -----
--------===============================================enter min 1 ----end ---------
--------===============================================enter min 0 ----start ---------
when enter_min0 =>
if (key_q=x"0100" ) then ------ 0
data_bus <= x"30" ;
state <= drop_lcd_e;
next_command<=m0_0;
end if ;
if ( key_q =x"0004" ) then ------1
data_bus <= x"31" ;
state <= drop_lcd_e;
next_command<=m0_1;
end if ;
if ( key_q =x"0008") then ----- 2
data_bus <=x"32" ;
state <= drop_lcd_e;
next_command<=m0_2;
end if ;
if (key_q=x"0010" ) then -------3
data_bus <= x"33" ;
state <= drop_lcd_e;
next_command<=m0_3;
end if ;
if (key_q=x"0002" ) then -------4
data_bus <= x"34" ;
state <= drop_lcd_e;
next_command<=m0_4;
end if;
if (key_q=x"0040" ) then ------5
data_bus <= x"35" ;
state <= drop_lcd_e;
next_command<=m0_5;
end if ;
if (key_q=x"0200" ) then --------------6
data_bus <= x"36" ;
state <= drop_lcd_e;
next_command<=m0_6;
end if ;
if (key_q=x"0001" ) then ------ 7
data_bus <= x"37" ;
state <= drop_lcd_e;
next_command<=m0_7;
end if ;
if (key_q=x"0080" ) then ----- 8
data_bus <= x"38" ;
state <= drop_lcd_e;
next_command<=m0_8;
end if ;
if (key_q=x"0400" ) then ------ 9
data_bus <= x"39" ;
state <= drop_lcd_e;
next_command<=m0_9;
end if ;
if (key_q=x"0020" ) then ----A SHIFT THE CURSOR TO THE LIFT
-- data_bus <= x"04" ; ------SHIFT CURSOR TO LEFT
data_bus <= x"14" ; -----SHIFT CURSOR POSITION TO LEFT
state <= drop_lcd_e;
next_command<=m0_forward;
end if ;
if (key_q=x"1000" ) then ---B SHIFT THE DISPLAY AND CURSOR POSITION TO RIGHT
-- data_bus <= x"06" ; ------SHIFT CURSOR TO RIGHT
data_bus <= x"10" ; -----SHIFT CURSOR POSITION TO RIGHT
state <= drop_lcd_e;
next_command<=m0_backward;
end if ;
-------min0 definition started ----===========================
when m0_0=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"30"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m0_delay ;
when m0_1=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"31"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m0_delay ;
when m0_2=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"32"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m0_delay ;
when m0_3=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"33"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m0_delay ;
when m0_4=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"34"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m0_delay ;
when m0_5 =>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"35"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m0_delay ;
when m0_6=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"36"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m0_delay ;
when m0_7=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"37"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m0_delay ;
when m0_8=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"38"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m0_delay ;
when m0_9=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"39"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=m0_delay ;
when m0_delay=>
lcd_e <= '0';
lcd_rs <= '1';
lcd_rw_int <= '0';
m0_reg <=key_q ;
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count +1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
if ( cursor_count=5) then
state<=min_coln ;
end if ;
when m0_forward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"04"; -- Auto increment address and move cursor to the LEFT
data_bus <= x"14" ; ----SHIFT CURSOR POSTION TO LEFT
state <= drop_lcd_e;
next_command <=m0_forward_cursor_delay ;
when m0_backward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"06"; -- Auto increment address and move cursor to the right
data_bus <= x"10" ; ----SHIFT CURSOR POSTION TO RIGHT
state <= drop_lcd_e;
next_command <=m0_backward_cursor_delay ;
when m0_forward_cursor_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count +1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
if ( cursor_count=5) then
state <=min_coln ;
end if ;
when m0_backward_cursor_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count -1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
if ( cursor_count=3) then
state<=enter_min1;
end if ;
--------===============================================enter min 0 ----end ---------
------======================min_coln start ---=========================
when min_coln=>
if (key_q=x"0020" ) then ----A SHIFT THE CURSOR TO THE LIFT
-- data_bus <= x"04" ; ------SHIFT CURSOR TO LEFT
data_bus <= x"14" ; -----SHIFT CURSOR POSITION TO LEFT
state <= drop_lcd_e;
next_command<=min_coln_forward;
end if ;
if (key_q=x"1000" ) then ---B SHIFT THE DISPLAY AND CURSOR POSITION TO RIGHT
-- data_bus <= x"06" ; ------SHIFT CURSOR TO RIGHT
data_bus <= x"10" ; -----SHIFT CURSOR POSITION TO RIGHT
state <= drop_lcd_e;
next_command<=min_coln_backward;
end if ;
when min_coln_forward=>
wait_1sec <= 0 ;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"04"; -- Auto increment address and move cursor to the LEFT
data_bus <= x"14" ; ----SHIFT CURSOR POSTION TO LEFT
state <= drop_lcd_e;
next_command <=min_coln_forward_delay ;
when min_coln_backward=>
wait_1sec <= 0 ;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"06"; -- Auto increment address and move cursor to the right
data_bus <= x"10" ; ----SHIFT CURSOR POSTION TO RIGHT
state <= drop_lcd_e;
next_command <=min_coln_backward_delay ;
when min_coln_forward_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count +1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
if ( cursor_count=6) then
state <=enter_sec1;
end if ;
when min_coln_backward_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- wait_1sec <= wait_1sec+1 ;
if ( wait_1sec=60000) then ---- .5 sec wait
-- if ( wait_1sec=6) then ---- .5 sec wait
wait_1sec <=0 ;
cursor_count <= cursor_count -1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
if ( cursor_count =4) then
state<= enter_min0;
end if ;
-------========================================min _coln end ----====================
-------------------==================sec1-----start ---=================
when enter_sec1 =>
if (key_q=x"0100" ) then ------ 0
data_bus <= x"30" ;
state <= drop_lcd_e;
next_command<=s1_0;
end if ;
if ( key_q =x"0004" ) then ------1
data_bus <= x"31" ;
state <= drop_lcd_e;
next_command<=s1_1;
end if ;
if ( key_q =x"0008") then ----- 2
data_bus <=x"32" ;
state <= drop_lcd_e;
next_command<=s1_2;
end if ;
if (key_q=x"0010" ) then -------3
data_bus <= x"33" ;
state <= drop_lcd_e;
next_command<=s1_3;
end if ;
if (key_q=x"0002" ) then -------4
data_bus <= x"34" ;
state <= drop_lcd_e;
next_command<=s1_4;
end if;
if (key_q=x"0040" ) then ------5
data_bus <= x"35" ;
state <= drop_lcd_e;
next_command<=s1_5;
end if ;
if (key_q=x"0200" ) then --------------6
data_bus <= x"36" ;
state <= drop_lcd_e;
next_command<=s1_6;
end if ;
if (key_q=x"0001" ) then ------ 7
data_bus <= x"37" ;
state <= drop_lcd_e;
next_command<=s1_7;
end if ;
if (key_q=x"0080" ) then ----- 8
data_bus <= x"38" ;
state <= drop_lcd_e;
next_command<=s1_8;
end if ;
if (key_q=x"0400" ) then ------ 9
data_bus <= x"39" ;
state <= drop_lcd_e;
next_command<=s1_9;
end if ;
if (key_q=x"0020" ) then ----A SHIFT THE CURSOR TO THE LIFT
-- data_bus <= x"04" ; ------SHIFT CURSOR TO LEFT
data_bus <= x"14" ; -----SHIFT CURSOR POSITION TO LEFT
state <= drop_lcd_e;
next_command<=s1_forward;
end if ;
if (key_q=x"1000" ) then ---B SHIFT THE DISPLAY AND CURSOR POSITION TO RIGHT
-- data_bus <= x"06" ; ------SHIFT CURSOR TO RIGHT
data_bus <= x"10" ; -----SHIFT CURSOR POSITION TO RIGHT
state <= drop_lcd_e;
next_command<=s1_backward;
end if ;
---------sec1 definiton ---======
when s1_0=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"30"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s1_delay ;
when s1_1=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"31"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s1_delay ;
when s1_2=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"32"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s1_delay ;
when s1_3=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"33"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s1_delay ;
when s1_4=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"34"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s1_delay ;
when s1_5 =>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"35"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s1_delay ;
when s1_6=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"36"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s1_delay ;
when s1_7=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"37"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s1_delay ;
when s1_8=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"38"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s1_delay ;
when s1_9=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"39"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s1_delay ;
when s1_delay=>
lcd_e <= '0';
lcd_rs <= '1';
lcd_rw_int <= '0';
s1_reg <=key_q ;
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
state<=enter_sec0 ;
cursor_count <= cursor_count +1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
when s1_forward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"04"; -- Auto increment address and move cursor to the LEFT
data_bus <= x"14" ; ----SHIFT CURSOR POSTION TO LEFT
state <= drop_lcd_e;
next_command <=s1_forward_cursor_delay ;
when s1_backward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"06"; -- Auto increment address and move cursor to the right
data_bus <= x"10" ; ----SHIFT CURSOR POSTION TO RIGHT
state <= drop_lcd_e;
next_command <=s1_backward_cursor_delay ;
when s1_forward_cursor_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
wait_1sec <= wait_1sec+1 ;
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
state <=enter_sec0 ;
cursor_count <= cursor_count +1 ;
end if ;
when s1_backward_cursor_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
if ( wait_1sec=60000) then ---- .5 sec wait
-- if ( wait_1sec=3) then ---- .5 sec wait
wait_1sec <=0 ;
state <=min_coln ;
cursor_count <= cursor_count -1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
--------==================end sec1--=============================
when enter_sec0 =>
if ( cursor_count=8) then
cursor_count <="0000" ;
next_command <=l2;
end if ;
if (key_q=x"0100" ) then ------ 0
data_bus <= x"30" ;
state <= drop_lcd_e;
next_command<=s0_0;
end if ;
if ( key_q =x"0004" ) then ------1
data_bus <= x"31" ;
state <= drop_lcd_e;
next_command<=s0_1;
end if ;
if ( key_q =x"0008") then ----- 2
data_bus <=x"32" ;
state <= drop_lcd_e;
next_command<=s0_2;
end if ;
if (key_q=x"0010" ) then -------3
data_bus <= x"33" ;
state <= drop_lcd_e;
next_command<=s0_3;
end if ;
if (key_q=x"0002" ) then -------4
data_bus <= x"34" ;
state <= drop_lcd_e;
next_command<=s0_4;
end if;
if (key_q=x"0040" ) then ------5
data_bus <= x"35" ;
state <= drop_lcd_e;
next_command<=s0_5;
end if ;
if (key_q=x"0200" ) then --------------6
data_bus <= x"36" ;
state <= drop_lcd_e;
next_command<=s0_6;
end if ;
if (key_q=x"0001" ) then ------ 7
data_bus <= x"37" ;
state <= drop_lcd_e;
next_command<=s0_7;
end if ;
if (key_q=x"0080" ) then ----- 8
data_bus <= x"38" ;
state <= drop_lcd_e;
next_command<=s0_8;
end if ;
if (key_q=x"0400" ) then ------ 9
data_bus <= x"39" ;
state <= drop_lcd_e;
next_command<=s0_9;
end if ;
if (key_q=x"0020" ) then ----A SHIFT THE CURSOR TO THE LIFT
-- data_bus <= x"04" ; ------SHIFT CURSOR TO LEFT
data_bus <= x"14" ; -----SHIFT CURSOR POSITION TO LEFT
state <= drop_lcd_e;
next_command<=s0_forward;
end if ;
if (key_q=x"1000" ) then ---B SHIFT THE DISPLAY AND CURSOR POSITION TO RIGHT
-- data_bus <= x"06" ; ------SHIFT CURSOR TO RIGHT
data_bus <= x"10" ; -----SHIFT CURSOR POSITION TO RIGHT
state <= drop_lcd_e;
next_command<=s0_backward;
end if ;
--=============s0----sefiniton
---------sec1 definiton ---======
when s0_0=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"30"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s0_delay ;
when s0_1=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"31"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s0_delay ;
when s0_2=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"32"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s0_delay ;
when s0_3=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"33"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s0_delay ;
when s0_4=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"34"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s0_delay ;
when s0_5 =>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"35"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s0_delay ;
when s0_6=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"36"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s0_delay ;
when s0_7=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"37"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s0_delay ;
when s0_8=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"38"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s0_delay ;
when s0_9=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"39"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=s0_delay ;
when s0_delay=>
lcd_e <= '0';
lcd_rs <= '1';
lcd_rw_int <= '0';
s0_reg <=key_q ;
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
state<=timesave ;
cursor_count <= cursor_count +1 ; --- comented working
else
wait_1sec <= wait_1sec+1 ;
end if ;
when s0_forward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"04"; -- Auto increment address and move cursor to the LEFT
data_bus <= x"14" ; ----SHIFT CURSOR POSTION TO LEFT
state <= drop_lcd_e;
next_command <=s0_forward_cursor_delay ;
when s0_backward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"06"; -- Auto increment address and move cursor to the right
data_bus <= x"10" ; ----SHIFT CURSOR POSTION TO RIGHT
state <= drop_lcd_e;
next_command <=s0_backward_cursor_delay ;
when s0_forward_cursor_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
state<=timesave ;
cursor_count <= cursor_count +1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
when s0_backward_cursor_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
state<=enter_sec1;
cursor_count <= cursor_count -1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
----------=========end sec0----====================
when timesave=>
h1_q <= h1_reg ;
h0_q <=h0_reg ;
m1_q <=m1_reg ;
m0_q<=m0_reg ;
s1_q<=s1_reg ;
s0_q <=s0_reg ;
if (key_q=x"1000" ) then ---B SHIFT THE DISPLAY AND CURSOR POSITION TO RIGHT
-- data_bus <= x"06" ; ------SHIFT CURSOR TO RIGHT
data_bus <= x"10" ; -----SHIFT CURSOR POSITION TO RIGHT
state <= drop_lcd_e;
next_command<=time_save_backward;
end if ;
if (key_q=x"0800" ) then ----# go to timave save state
state <= drop_lcd_e;
next_command<=power_up ;
end if ;
if (key_q=x"8000" ) then -------save and exit *
state <= drop_lcd_e;
next_command<=rst1;
end if ;
when time_save_backward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"06"; -- Auto increment address and move cursor to the right
data_bus <= x"10" ; ----SHIFT CURSOR POSTION TO RIGHT
state <= drop_lcd_e;
next_command <=time_save_backward_cursor_delay ;
when time_save_backward_cursor_delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
state<=enter_sec0;
cursor_count <= cursor_count -1 ;
else
wait_1sec <= wait_1sec+1 ;
end if ;
---------------------------------------------------------------------xxx-----------------------------------------------------------------------------
------------xxx ene kepad entry -----------------------------------------------------------------------------------------
when second_linedata=>
-- next_command<=l2;
if ( key_q =x"0004" ) then ------1
data_bus <= x"31" ;
state <= drop_lcd_e;
next_command<=one;
end if ;
if ( key_q =x"0008") then ----- 2
data_bus <=x"32" ;
state <= drop_lcd_e;
next_command<=two;
end if ;
if (key_q=x"0010" ) then -------3
data_bus <= x"33" ;
state <= drop_lcd_e;
next_command<=three;
end if ;
if (key_q=x"0002" ) then -------4
data_bus <= x"34" ;
state <= drop_lcd_e;
next_command<=four;
end if;
if (key_q=x"0040" ) then ------5
data_bus <= x"35" ;
state <= drop_lcd_e;
next_command<=five;
end if ;
if (key_q=x"0200" ) then --------------6
data_bus <= x"36" ;
state <= drop_lcd_e;
next_command<=six;
end if ;
if (key_q=x"0001" ) then ------ 7
data_bus <= x"37" ;
state <= drop_lcd_e;
next_command<=seven;
end if ;
if (key_q=x"0080" ) then ----- 8
data_bus <= x"38" ;
state <= drop_lcd_e;
next_command<=eight;
end if ;
if (key_q=x"0400" ) then ------ 9
data_bus <= x"39" ;
state <= drop_lcd_e;
next_command<=nine;
end if ;
if (key_q=x"0100" ) then ------ 0
data_bus <= x"30" ;
state <= drop_lcd_e;
next_command<=zero;
end if ;
if (key_q=x"0020" ) then ----A SHIFT THE CURSOR TO THE LIFT
-- data_bus <= x"04" ; ------SHIFT CURSOR TO LEFT
data_bus <= x"14" ; -----SHIFT CURSOR POSITION TO LEFT
state <= drop_lcd_e;
next_command<=forward;
end if ;
if (key_q=x"1000" ) then ---B SHIFT THE DISPLAY AND CURSOR POSITION TO RIGHT
-- data_bus <= x"06" ; ------SHIFT CURSOR TO RIGHT
data_bus <= x"10" ; -----SHIFT CURSOR POSITION TO RIGHT
state <= drop_lcd_e;
next_command<=backward;
end if ;
if (key_q=x"8000" ) then -------save and exit *
state <= drop_lcd_e;
next_command<=power_up;
end if ;
if (key_q=x"0800" ) then ----# go to rst1 state
state <= drop_lcd_e;
next_command<=rst1;
end if ;
if (key_q=x"4000" ) then ----# d to rst1 state clear and restart the system
state <= drop_lcd_e;
next_command<=power_up;
end if ;
when one=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"31"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=data_delay ;
when two=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"32"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=data_delay ;
when three=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"33"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=data_delay ;
when four=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"34"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=data_delay ;
when five =>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"35"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=data_delay ;
when six=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"36"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=data_delay ;
when seven=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"37"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=data_delay ;
when eight=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"38"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=data_delay ;
when nine=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"39"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=data_delay ;
when zero=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"30"; -- Auto increment address and move cursor to the right
state <= drop_lcd_e;
next_command <=data_delay ;
when forward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"04"; -- Auto increment address and move cursor to the LEFT
data_bus <= x"14" ; ----SHIFT CURSOR POSTION TO LEFT
cursor_count1 <= cursor_count1 +1 ;
if ( cursor_count1 = "0111" ) then
cursor_count1 <="0000" ;
end if ;
state <= drop_lcd_e;
next_command <=delay ;
when backward=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= x"06"; -- Auto increment address and move cursor to the right
data_bus <= x"10" ; ----SHIFT CURSOR POSTION TO RIGHT
cursor_count2 <= cursor_count2 - 1 ;
if ( cursor_count2 =0) then
cursor_count2 <="0111" ;
end if ;
state <= drop_lcd_e;
next_command <=delay ;
when data_delay=>
lcd_e <= '0';
lcd_rs <= '1';
lcd_rw_int <= '0';
-- data_bus <=x"20";
wait_1sec <= wait_1sec+1 ;
if ( wait_1sec=60000) then ---- .5 sec wait
-- if ( wait_1sec=6) then ---- .5 sec wait
wait_1sec <=0 ;
state<=second_linedata ; -----working
end if ;
when delay=>
lcd_e <= '0';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <=x"20";
wait_1sec <= wait_1sec+1 ;
if ( wait_1sec=60000) then ---- .5 sec wait
wait_1sec <=0 ;
state<=second_linedata ; ----working
end if ;
when time_save=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"02"; ----just now commented
next_command<=message_enter;
end case ;
end if ;
end process ;
end Behavioral;-- Company:
---------------------------------------------------------------------------------------------
No comments:
Post a Comment