-
Notifications
You must be signed in to change notification settings - Fork 2
/
ugfx.h
79 lines (64 loc) · 1.86 KB
/
ugfx.h
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
/* Copyright (C) 2016 Sean D'Epagnier <seandepagnier@gmail.com>
*
* This Program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*/
unsigned int color(int r, int g, int b);
class surface
{
public:
surface(surface *s);
surface(int w, int h, int internal_bypp, const char *data32);
surface(const char* filename, int bypp);
virtual ~surface();
void load(const char *filename, int bypp);
void store_grey(const char *filename);
void blit(surface *src, int xoff, int yoff, bool flip=false);
void magnify(surface *src, int factor);
void putpixel(int x, int y, unsigned int c);
void line(int x1, int y1, int x2, int y2, unsigned int c);
void hline(int x1, int x2, int y, unsigned int c);
void vline(int x, int y1, int y2, unsigned int c);
void box(int x1, int y1, int x2, int y2, unsigned int c);
void invert(int x1, int y1, int x2, int y2);
void fill(unsigned int c);
virtual void refresh() {}
void binary_write_sw(int sclk, int mosi);
int width, height, bypp;
char *p;
int getpixel(int x, int y);
char *ptr() { return p; }
int xoffset, yoffset, line_length;
protected:
int allocated_size;
surface() {}
};
#ifdef __linux__
#include <linux/fb.h>
// linux framebuffer surface
class screen : public surface
{
public:
screen(const char *device);
virtual ~screen();
struct fb_fix_screeninfo finfo;
struct fb_var_screeninfo vinfo;
char *fbp;
int fbfd;
long int screensize;
};
#endif
// nokia5110 spi device
class spilcd;
class spiscreen : public surface
{
public:
spiscreen(int driver=-1);
virtual ~spiscreen();
void refresh();
int contrast;
private:
spilcd *disp;
};