diff options
author | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-12-03 21:46:19 +0100 |
---|---|---|
committer | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-12-03 21:46:19 +0100 |
commit | 08b7ee440269c881546421da6efe1b6ae122b566 (patch) | |
tree | d3140184165f36acf49116e3a7886c15e5895e27 | |
parent | d46862a5bd2319c595b11427f781201ca063d194 (diff) |
Change pixel format
-rw-r--r-- | include/tft.h | 5 | ||||
-rw-r--r-- | src/menu.c | 5 | ||||
-rw-r--r-- | src/tft.c | 12 | ||||
-rw-r--r-- | src/tty.c | 13 |
4 files changed, 26 insertions, 9 deletions
diff --git a/include/tft.h b/include/tft.h index 22303a1..1e2fce2 100644 --- a/include/tft.h +++ b/include/tft.h @@ -114,9 +114,8 @@ tft_ram_wr(void) static inline void tft_pixel(uint8_t r, uint8_t g, uint8_t b) { - tft_data = r; - tft_data = g; - tft_data = b; + tft_data = (r << 3) | ((g & 0x38) >> 3); + tft_data = ((g & 0x07) << 5) | b & 0x1F; } void @@ -230,9 +230,11 @@ _menu(void) draw_menu(); while (1) { - DI; while (!fifo_empty(&input_fifo)) { + DI; u8 event = fifo_pop(&input_fifo); + EI; + if (event == CW) { if (dir == HORIZONTAL) { if (++menu_index >= LENGTH(menu)) @@ -264,6 +266,5 @@ _menu(void) callbacks[event](); } } - EI; } } @@ -94,10 +94,16 @@ enum memory_access { ML = 0x10 }; +extern u8 blink; + void clear_screen(void) { DI; + u8 tmp = blink; + blink = 0; + EI; + tft_set_col_addr(0, TFT_WIDTH - 1); tft_set_page_addr(0, TFT_HEIGHT - 1); @@ -106,9 +112,11 @@ clear_screen(void) for (u16 j = 0; j < TFT_WIDTH; ++j) { tft_data = 0x00; tft_data = 0x00; - tft_data = 0x00; } } + + DI; + blink = tmp; EI; } @@ -124,7 +132,7 @@ tft_init(void) tft_set_rgb_interface(); - tft_pixel_format(BIT18, BIT18); + tft_pixel_format(BIT16, BIT16); tft_memory_access_ctrl(MV | 0x0C); tft_sleep_out(); @@ -23,11 +23,12 @@ extern const uint8_t font[97][8]; static uint8_t cursor = 0; static uint8_t timer = 0; +u8 blink = 0; void blink_cursor(void) __critical __interrupt(3) { - if (++timer >= 75) { + if (++timer >= 75 && blink) { uint8_t i; tft_set_area(8 * col, 8 * row, 8, 8); @@ -131,10 +132,18 @@ addch(char c) return; } - tft_set_area(8 * col, 8 * row, 8, 8); + DI; + u8 tmp = blink; + blink = 0; + EI; + tft_set_area(8 * col, 8 * row, 8, 8); draw(c); + DI; + blink = tmp; + EI; + buf[(head + row) % TTY_HEIGHT][col] = c; advance(); } |