PatchworkOS  3984a1d
A non-POSIX operating system.
Loading...
Searching...
No Matches
screen.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/config.h>
4#include <kernel/log/glyphs.h>
5
6#include <boot/boot_info.h>
7
8#include <stdint.h>
9
10/**
11 * @brief Screen logging
12 * @defgroup kernel_log_screen Screen
13 * @ingroup kernel_log
14 *
15 * @{
16 */
17
18/**
19 * @brief Number of spaces to indent when a line wraps.
20 *
21 * Header length (15) + 2 for indentation
22 */
23#define SCREEN_WRAP_INDENT 17
24
25/**
26 * @brief Maximum number of characters in a single line.
27 */
28#define SCREEN_LINE_MAX_LENGTH (130)
29
30/**
31 * @brief The stride of a screen line in pixels.
32 */
33#define SCREEN_LINE_STRIDE (SCREEN_LINE_MAX_LENGTH * GLYPH_WIDTH)
34
35/**
36 * @brief Represents a position on the screen in character coordinates.
37 */
38typedef struct
39{
43
44/**
45 * @brief A single line in the screen buffer.
46 */
47typedef struct
48{
49 uint8_t length; ///< The distance from the start of the line to the end of the furthest away char, in chars.
50 uint32_t pixels[GLYPH_HEIGHT * SCREEN_LINE_STRIDE]; ///< The pixel data for the line.
52
53/**
54 * @brief Initialize and enable the screen logging.
55 */
56void screen_init(void);
57
58/**
59 * @brief Show the screen logging.
60 */
61void screen_show(void);
62
63/**
64 * @brief Hide the screen logging.
65 */
66void screen_hide(void);
67
68/**
69 * @brief Get screen width in characters.
70 */
72
73/**
74 * @brief Get screen height in characters.
75 */
77
78/**
79 * @brief Write a string to the screen.
80 *
81 * @param screen The screen state.
82 * @param string The string to write.
83 * @param length The length of the string.
84 */
85void screen_write(const char* string, uint64_t length);
86
87/** @} */
#define GLYPH_HEIGHT
Definition glyphs.h:7
uint64_t screen_get_width(void)
Get screen width in characters.
Definition screen.c:213
uint64_t screen_get_height(void)
Get screen height in characters.
Definition screen.c:218
void screen_init(void)
Initialize and enable the screen logging.
Definition screen.c:80
void screen_write(const char *string, uint64_t length)
Write a string to the screen.
Definition screen.c:223
#define SCREEN_LINE_STRIDE
The stride of a screen line in pixels.
Definition screen.h:33
void screen_hide(void)
Hide the screen logging.
Definition screen.c:195
void screen_show(void)
Show the screen logging.
Definition screen.c:201
__UINT32_TYPE__ uint32_t
Definition stdint.h:15
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
__UINT8_TYPE__ uint8_t
Definition stdint.h:11
A single line in the screen buffer.
Definition screen.h:48
uint8_t length
The distance from the start of the line to the end of the furthest away char, in chars.
Definition screen.h:49
Represents a position on the screen in character coordinates.
Definition screen.h:39
uint8_t x
Definition screen.h:40
uint8_t y
Definition screen.h:41