uart: draw lines above and below RX input

This commit is contained in:
Zihao Yu 2024-01-09 19:57:27 +08:00
parent 6feac794ed
commit 2f25106e0f
2 changed files with 11 additions and 4 deletions

View File

@ -120,7 +120,8 @@ static void render_keyboard(SDL_Renderer *renderer) {
const int key_gap = key_unit_width / 14;
const int h_keyboard = key_unit_width * 6 + key_gap * 5 + key_unit_width / 2;
const int x_top_left = WINDOW_WIDTH / 2 + 1;
const int y_top_left = WINDOW_HEIGHT / 2 + 16 + (WINDOW_HEIGHT / 2 - 16 - h_keyboard) / 2;
const int y_below_uart_rx = WINDOW_HEIGHT / 2 + 2 + 16;
const int y_top_left = y_below_uart_rx + (WINDOW_HEIGHT - y_below_uart_rx - h_keyboard) / 2;
const int key_gap_before_extend_keys = key_unit_width / 3;
SDL_Surface *s_1p0 = new_key_shape(key_unit_width, key_unit_width);

View File

@ -13,10 +13,10 @@ UART::UART(SDL_Renderer *rend, int cnt, int init_val, int ct, int x, int y, int
Component(rend, cnt, init_val, ct),
tx_state(0), rx_state(0), divisor(16), tx_update_gui(false) {
tx_term = new Term(rend, x, y, w, h);
rx_term = new Term(rend, x, y + h, w, 20);
rx_term = new Term(rend, x, y + h + 1, w, 16);
SDL_Rect *rect_ptr = new SDL_Rect;
*rect_ptr = (SDL_Rect){x, y + h, w, 20};
SDL_Rect *rect_ptr = new SDL_Rect; // rx terminal
*rect_ptr = (SDL_Rect){x, y + h + 1, w, 16};
set_rect(rect_ptr, 0);
uart_divisor_cnt = divisor - 1;
@ -28,6 +28,12 @@ UART::UART(SDL_Renderer *rend, int cnt, int init_val, int ct, int x, int y, int
rx_term->set_cursor_visibility(false);
rx_input = "";
rx_sending_str = "";
SDL_SetRenderDrawColor(rend, 0x00, 0x00, 0x00, 0);
SDL_RenderDrawLine(rend, x, y + h, x + w, y + h);
SDL_RenderDrawLine(rend, x, y + h + 1 + 16, x + w, y + h + 1 + 16);
SDL_SetRenderDrawColor(rend, 0xff, 0xff, 0xff, 0);
rx_update_gui = true;
pin_poke(UART_RX, 1);
}