-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreen.h
More file actions
101 lines (76 loc) · 2.19 KB
/
screen.h
File metadata and controls
101 lines (76 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef SCREEN_H
#define SCREEN_H
#define DEFAULT_FG COLOR_WHITE
#define DEFAULT_BG COLOR_BLACK
#include <stdint.h>
#include <linux/fb.h>
#include "fonts/8x16.h"
// ARGB for 32bpp
// Standard colors
#define COLOR_BLACK 0x00000000
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_RED 0xFFFF0000
#define COLOR_GREEN 0xFF00FF00
#define COLOR_BLUE 0xFF0000FF
#define COLOR_YELLOW 0xFFFFFF00
#define COLOR_MAGENTA 0xFFFF00FF
#define COLOR_CYAN 0xFF00FFFF
// Bright colors (higher intensity versions)
#define COLOR_BRIGHT_BLACK 0xFF4C4C4C
#define COLOR_BRIGHT_RED 0xFFFF6E6E
#define COLOR_BRIGHT_GREEN 0xFF6EFF6E
#define COLOR_BRIGHT_YELLOW 0xFFFFFF6E
#define COLOR_BRIGHT_BLUE 0xFF6E6EFF
#define COLOR_BRIGHT_MAGENTA 0xFFFF6EFF
#define COLOR_BRIGHT_CYAN 0xFF6EFFFF
#define COLOR_BRIGHT_WHITE 0xFFFFFFFF
typedef struct pt {
int x;
int y;
} pt_t;
typedef struct sz {
int w;
int h;
} sz_t;
typedef union rect {
struct {
int x;
int y;
int w;
int h;
};
struct {
pt_t pt;
sz_t sz;
};
} rect_t;
typedef struct screen {
int fd;
char sys_backlight[1024];
int max_bright;
struct fb_fix_screeninfo finfo;
struct fb_var_screeninfo vinfo;
uint32_t size;
uint8_t *mem;
int columns;
int rows;
pt_t cursor;
uint32_t fg_color;
uint32_t bg_color;
uint32_t cursor_color;
} screen_t;
int screen_open(screen_t *screen, const char *dev_fb, const char *sys_backlight);
int screen_open_virtual(screen_t *screen, int width, int height);
void screen_close(screen_t *screen);
void screen_backlight(const screen_t *screen, int percent);
void screen_redraw(screen_t *screen);
uint32_t screen_pixel_set(const screen_t *screen, int x, int y, uint32_t c);
void screen_fill(const screen_t *screen, const rect_t *rect, uint32_t c);
void screen_put_ch(const screen_t *screen, unsigned char c);
void screen_put_cursor(const screen_t *screen, uint32_t saved_cursor[font_h][font_w], int put);
void screen_move_clr(const screen_t *screen, const pt_t *dst, const rect_t *src);
void screen_scroll_v(const screen_t *screen, int offset);
void screen_scroll_h(const screen_t *screen, int offset);
void screen_clear(screen_t screen, int backlight_percent);
int screen_save_bmp(const screen_t *screen, const char *filename);
#endif