-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframebuf.py
192 lines (149 loc) · 6.78 KB
/
framebuf.py
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
"""
Module: 'framebuf' on esp32 1.11.0
"""
# MCU: (sysname='esp32', nodename='esp32', release='1.11.0', version='v1.11-580-g973f68780 on 2019-11-17', machine='ESP32 module with ESP32')
# Stubber: 1.3.2
GS2_HMSB = 5
"""Grayscale (2-bit) color format"""
GS4_HMSB = 2
"""Grayscale (4-bit) color format"""
GS8 = 6
"""Grayscale (8-bit) color format"""
MONO_HLSB = 3
"""Monochrome (1-bit) color format This defines a mapping where the bits in a byte are horizontally mapped. Each byte occupies 8 horizontal pixels with bit 0 being the leftmost. Subsequent bytes appear at successive horizontal locations until the rightmost edge is reached. Further bytes are rendered on the next row, one pixel lower."""
MONO_HMSB = 4
"""Monochrome (1-bit) color format This defines a mapping where the bits in a byte are horizontally mapped. Each byte occupies 8 horizontal pixels with bit 7 being the leftmost. Subsequent bytes appear at successive horizontal locations until the rightmost edge is reached. Further bytes are rendered on the next row, one pixel lower."""
MONO_VLSB = 0
"""Monochrome (1-bit) color format This defines a mapping where the bits in a byte are vertically mapped with bit 0 being nearest the top of the screen. Consequently each byte occupies 8 vertical pixels. Subsequent bytes appear at successive horizontal locations until the rightmost edge is reached. Further bytes are rendered at locations starting at the leftmost edge, 8 pixels lower."""
MVLSB = 0
RGB565 = 1
"""Red Green Blue (16-bit, 5+6+5) color format"""
class FrameBuffer:
"""
The FrameBuffer class provides a pixel buffer which can be drawn upon with pixels, lines, rectangles, text and even other FrameBuffer’s. It is useful when generating output for displays.
Parameters
----------
- buffer : an object with a buffer protocol which must be large enough to contain every pixel defined by the width, height and format of the FrameBuffer;
- width : the width of the FrameBuffer in pixels;
- height : the height of the FrameBuffer in pixels;
- format : specifies the type of pixel used in the FrameBuffer; permissible values are listed under Constants below. These set the number of bits used to encode a color value and the layout of these bits in buffer. Where a color value c is passed to a method, c is a small integer with an encoding that is dependent on the format of the FrameBuffer;
- stride=width : the number of pixels between each horizontal line of pixels in the FrameBuffer. This defaults to width but may need adjustments when implementing a FrameBuffer within another larger FrameBuffer or screen. The buffer size must accommodate an increased step size.
http://docs.micropython.org/en/latest/library/framebuf.html#framebuf.FrameBuffer
"""
def blit(self, fbuf, x, y, key):
"""
Draw another FrameBuffer on top of the current one at the given coordinates. If key is specified then it should be a color integer and the corresponding color will be considered transparent: all pixels with that color value will not be drawn.
This method works between FrameBuffer instances utilising different formats, but the resulting colors may be unexpected due to the mismatch in color formats.
Parameters
----------
- fbuf
- x
- y
- [key]
http://docs.micropython.org/en/latest/library/framebuf.html#framebuf.FrameBuffer.blit
"""
pass
def fill(self, c):
"""
Fill the entire FrameBuffer with the specified color.
Parameters
----------
- c : color code
http://docs.micropython.org/en/latest/library/framebuf.html#framebuf.FrameBuffer.fill
"""
pass
def fill_rect(self, x, y, w, h, c):
"""
Draw a rectangle at the given location, size and color. The rect method draws only a 1 pixel outline whereas the fill_rect method draws both the outline and interior.
Parameters
----------
- x
- y
- w
- h
- c : color code
http://docs.micropython.org/en/latest/library/framebuf.html#framebuf.FrameBuffer.fill_rect
"""
pass
def hline(self, x, y, w, c):
"""
Horizontal line
Parameters
----------
- x
- y
- w
- c : color code
http://docs.micropython.org/en/latest/library/framebuf.html#framebuf.FrameBuffer.hline
"""
pass
def line(self, x1, y1, x2, y2, c):
"""
Draw a line from a set of coordinates using the given color and a thickness of 1 pixel. The line method draws the line up to a second set of coordinates whereas the hline and vline methods draw horizontal and vertical lines respectively up to a given length.
Parameters
----------
- x1
- y1
- x2
- y2
- c : color code
http://docs.micropython.org/en/latest/library/framebuf.html#framebuf.FrameBuffer.line
"""
pass
def pixel(self, x, y, c):
"""
If c is not given, get the color value of the specified pixel. If c is given, set the specified pixel to the given color.
Parameters
----------
- x
- y
- [c] : color code
http://docs.micropython.org/en/latest/library/framebuf.html#framebuf.FrameBuffer.pixel
"""
pass
def rect(self, x, y, w, h, c):
"""
Parameters
----------
- x
- y
- w
- h
- c : color code
http://docs.micropython.org/en/latest/library/framebuf.html#framebuf.FrameBuffer.rect
"""
pass
def scroll(self, xstep, ystep):
"""
Shift the contents of the FrameBuffer by the given vector. This may leave a footprint of the previous colors in the FrameBuffer.
Parameters
----------
- xstep
- ystep
http://docs.micropython.org/en/latest/library/framebuf.html#framebuf.FrameBuffer.scroll
"""
pass
def text(self, s, x, y, c):
"""
Write text to the FrameBuffer using the the coordinates as the upper-left corner of the text. The color of the text can be defined by the optional argument but is otherwise a default value of 1. All characters have dimensions of 8x8 pixels and there is currently no way to change the font.
Parameters
----------
- string
- x
- y
- [c] : color code
http://docs.micropython.org/en/latest/library/framebuf.html#framebuf.FrameBuffer.text
"""
pass
def vline(self, x, y, h, c):
"""
Parameters
- x
- y
- h
- c
http://docs.micropython.org/en/latest/library/framebuf.html#framebuf.FrameBuffer.vline
"""
pass
def FrameBuffer1():
pass