-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
8,383 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
add_library(graphics INTERFACE) | ||
|
||
target_sources(graphics INTERFACE ${CMAKE_CURRENT_LIST_DIR}/graphics.c) | ||
|
||
#target_link_libraries(graphics INTERFACE | ||
#vga-nextgen | ||
#hdmi | ||
#tft | ||
#) | ||
|
||
target_include_directories(graphics INTERFACE ${CMAKE_CURRENT_LIST_DIR}) | ||
|
||
#pico_generate_pio_header(st7789 | ||
# ${CMAKE_CURRENT_LIST_DIR}/st7789.pio | ||
#) |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "graphics.h" | ||
#include <string.h> | ||
|
||
void draw_text(const char string[TEXTMODE_COLS + 1], uint32_t x, uint32_t y, uint8_t color, uint8_t bgcolor) { | ||
uint8_t* t_buf = text_buffer + TEXTMODE_COLS * 2 * y + 2 * x; | ||
for (int xi = TEXTMODE_COLS * 2; xi--;) { | ||
if (!*string) break; | ||
*t_buf++ = *string++; | ||
*t_buf++ = bgcolor << 4 | color & 0xF; | ||
} | ||
} | ||
|
||
void draw_window(const char title[TEXTMODE_COLS + 1], uint32_t x, uint32_t y, uint32_t width, uint32_t height) { | ||
char line[width + 1]; | ||
memset(line, 0, sizeof line); | ||
width--; | ||
height--; | ||
// Рисуем рамки | ||
|
||
memset(line, 0xCD, width); // ═══ | ||
|
||
|
||
line[0] = 0xC9; // ╔ | ||
line[width] = 0xBB; // ╗ | ||
draw_text(line, x, y, 11, 1); | ||
|
||
line[0] = 0xC8; // ╚ | ||
line[width] = 0xBC; // ╝ | ||
draw_text(line, x, height + y, 11, 1); | ||
|
||
memset(line, ' ', width); | ||
line[0] = line[width] = 0xBA; | ||
|
||
for (int i = 1; i < height; i++) { | ||
draw_text(line, x, y + i, 11, 1); | ||
} | ||
|
||
snprintf(line, width - 1, " %s ", title); | ||
draw_text(line, x + (width - strlen(line)) / 2, y, 14, 3); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "stdbool.h" | ||
#include "stdio.h" | ||
#include "stdint.h" | ||
|
||
#ifdef TFT | ||
#include "st7789.h" | ||
#endif | ||
#ifdef HDMI | ||
#include "hdmi.h" | ||
#endif | ||
#ifdef VGA | ||
#include "vga.h" | ||
#endif | ||
#ifdef TV | ||
#include "tv.h" | ||
#endif | ||
|
||
#include "font6x8.h" | ||
#include "font8x8.h" | ||
#include "font8x16.h" | ||
|
||
enum graphics_mode_t { | ||
TEXTMODE_DEFAULT, | ||
GRAPHICSMODE_DEFAULT, | ||
|
||
TEXTMODE_53x30, | ||
|
||
TEXTMODE_160x100, | ||
|
||
CGA_160x200x16, | ||
CGA_320x200x4, | ||
CGA_640x200x2, | ||
|
||
TGA_320x200x16, | ||
EGA_320x200x16x4, | ||
VGA_320x240x256, | ||
VGA_320x200x256x4, | ||
// planar VGA | ||
}; | ||
|
||
// Буффер текстового режима | ||
extern uint8_t* text_buffer; | ||
|
||
void graphics_init(); | ||
|
||
void graphics_set_mode(enum graphics_mode_t mode); | ||
|
||
void graphics_set_buffer(uint8_t* buffer, uint16_t width, uint16_t height); | ||
|
||
void graphics_set_offset(int x, int y); | ||
|
||
void graphics_set_palette(uint8_t i, uint32_t color); | ||
|
||
void graphics_set_textbuffer(uint8_t* buffer); | ||
|
||
void graphics_set_bgcolor(uint32_t color888); | ||
|
||
void graphics_set_flashmode(bool flash_line, bool flash_frame); | ||
|
||
void draw_text(const char string[TEXTMODE_COLS + 1], uint32_t x, uint32_t y, uint8_t color, uint8_t bgcolor); | ||
void draw_window(const char title[TEXTMODE_COLS + 1], uint32_t x, uint32_t y, uint32_t width, uint32_t height); | ||
|
||
void clrScr(uint8_t color); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
add_library(hdmi INTERFACE) | ||
|
||
target_sources(hdmi INTERFACE ${CMAKE_CURRENT_LIST_DIR}/hdmi.c) | ||
|
||
target_link_libraries(hdmi INTERFACE hardware_pio hardware_clocks hardware_dma) | ||
|
||
target_include_directories(hdmi INTERFACE | ||
${CMAKE_CURRENT_LIST_DIR} | ||
) | ||
|
Oops, something went wrong.