Skip to content

Commit

Permalink
vga-nextgen
Browse files Browse the repository at this point in the history
  • Loading branch information
xrip committed Feb 13, 2024
1 parent d69457e commit 48a9fc3
Show file tree
Hide file tree
Showing 44 changed files with 8,383 additions and 50 deletions.
15 changes: 15 additions & 0 deletions drivers/graphics/CMakeLists.txt
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
#)
261 changes: 261 additions & 0 deletions drivers/graphics/font6x8.h

Large diffs are not rendered by default.

261 changes: 261 additions & 0 deletions drivers/graphics/font8x16.h

Large diffs are not rendered by default.

260 changes: 260 additions & 0 deletions drivers/graphics/font8x8.h

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions drivers/graphics/graphics.c
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);
}
71 changes: 71 additions & 0 deletions drivers/graphics/graphics.h
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
10 changes: 10 additions & 0 deletions drivers/hdmi/CMakeLists.txt
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}
)

Loading

0 comments on commit 48a9fc3

Please sign in to comment.