Peripherals/ascii_to_HD44780_driver: Added support for the \e[H and \e[2J escape codes to clear the screen after the i2c_bootloader is done

This commit is contained in:
(Tim) Efthimis Kritikos 2024-02-11 04:35:44 +00:00
parent aac55f7038
commit c527a053a6
2 changed files with 143 additions and 5 deletions

View File

@ -84,6 +84,10 @@ jz rom_read_end
jmp rom_read_loop jmp rom_read_loop
rom_read_end: rom_read_end:
mov bx,#clear_code
call print
MOV AX,#0xC000 MOV AX,#0xC000
JMP AX JMP AX
@ -173,6 +177,7 @@ sixty_prc_txt: .ASCII '60%\r\0'
seventy_prc_txt: .ASCII '70%\r\0' seventy_prc_txt: .ASCII '70%\r\0'
eighty_prc_txt: .ASCII '80%\r\0' eighty_prc_txt: .ASCII '80%\r\0'
ninty_prc_txt: .ASCII '90%\r\0' ninty_prc_txt: .ASCII '90%\r\0'
clear_code: DB 0x1B,0x5B,0x48,0x1B,0x5B,0x32,0x4a,0x00
.ORG 0xFFF0 .ORG 0xFFF0
MOV AX,#0xF800 MOV AX,#0xF800

View File

@ -67,6 +67,8 @@ reg [7:0] driver_state =0;
reg next_line; reg next_line;
reg [7:0]clear_count;
always @(posedge clock) begin always @(posedge clock) begin
if(rst_n==0)begin if(rst_n==0)begin
in_data_ready<=0; in_data_ready<=0;
@ -97,14 +99,18 @@ always @(posedge clock) begin
cmd_data<=1'b0; cmd_data<=1'b0;
next_line<=1; next_line<=1;
end else if(data_write_req==1)begin end else if(data_write_req==1)begin
if(in_ascii_data==8'h0A)begin if(in_ascii_data==8'h0A)begin // '\n'
driver_state<=8'd6; driver_state<=8'd6;
cmd_data<=1'b0; cmd_data<=1'b0;
next_line<=1; next_line<=1;
end else if(in_ascii_data==8'h0D)begin end else if(in_ascii_data==8'h0D)begin // '\r'
driver_state<=8'd6; driver_state<=8'd6;
cmd_data<=1'b0; cmd_data<=1'b0;
next_line<=0; next_line<=0;
end else if(in_ascii_data==8'h1b)begin // '\e'
driver_state<=8'd13;
cmd_data<=1'b1;
in_data_ready<=0;
end else begin end else begin
if (in_ascii_data[7:5]==3'b000||in_ascii_data[7:7]==1'b1) if (in_ascii_data[7:5]==3'b000||in_ascii_data[7:7]==1'b1)
if(in_ascii_data==8'h00) if(in_ascii_data==8'h00)
@ -204,12 +210,139 @@ always @(posedge clock) begin
if(done_writing) if(done_writing)
driver_state<=8'd0; driver_state<=8'd0;
end end
8'd13:begin // Escape sequence start
if(data_write_req==1'b0)begin
driver_state<=8'd14;
in_data_ready<=1;
end
end
8'd14:begin
if(data_write_req==1'b1)begin
in_data_ready<=1'b0;
case(in_ascii_data[7:0])
8'h5b:begin// '['
driver_state<=8'd16;
end
default:begin
driver_state<=8'd15;
end
endcase
end
end
8'd15:begin
if(data_write_req==1'b0)begin
driver_state<=8'd0;
end
end
8'd16:begin // Second part of escape sequency
if(data_write_req==1'b0)begin
in_data_ready<=1'b1;
driver_state<=8'd17;
end
end
8'd17:begin
if(data_write_req==1'b1)begin
driver_state<=8'd17;
in_data_ready<=1'b0;
case(in_ascii_data[7:0])
8'h48:begin// 'H'
driver_state<=8'd25;
cmd_data<=1'b0;
clear_count<=8'd80;
end
8'h32:begin// '2'
driver_state<=8'd23;
end
default: begin
driver_state<=8'd15;
end
endcase
end
end
8'd18:begin
data<=4'h2;
if(!done_writing)begin
driver_state<=8'd19;
write_req<=1'b0;
end else
write_req<=1'b1;
end
8'd19:begin
if(done_writing==1)
driver_state<=8'd20;
end
8'd20:begin
data<=4'h0;
if(!done_writing)begin
driver_state<=8'd21;
write_req<=1'b0;
end else
write_req<=1'b1;
end
8'd21:begin
if(done_writing)begin
driver_state<=8'd22;
clear_count<=clear_count-8'd1;
end
end
8'd22:begin
if(clear_count==8'd0)begin
driver_state<=8'd0;
end else begin
driver_state<=8'd18;
end
end
8'd23:begin
if(data_write_req==1'b0)begin
in_data_ready<=1'b1;
driver_state<=8'd24;
end
end
8'd24:begin
if(data_write_req==1'b1)begin
driver_state<=8'd17;
in_data_ready<=1'b0;
case(in_ascii_data[7:0])
8'h4a:begin// 'J'
driver_state<=8'd18;
clear_count<=8'd80;
end
default:begin
driver_state<=8'd0;
end
endcase
end
end
8'd25:begin
data<=4'h8;
if(!done_writing)begin
driver_state<=8'd26;
write_req<=1'b0;
end else
write_req<=1'b1;
end
8'd26:begin
if(done_writing==1)
driver_state<=8'd27;
end
8'd27:begin
data<=4'h0;
if(!done_writing)begin
driver_state<=8'd28;
write_req<=1'b0;
end else
write_req<=1'b1;
end
8'd28:begin
if(done_writing)begin
driver_state<=8'd0;
col<=0;
line<=0;
end
end
default: begin driver_state<=0; end default: begin driver_state<=0; end
endcase endcase
end end
end end
endmodule endmodule