1- """ Base class for all RGB Display devices """
1+ # The MIT License (MIT)
2+ #
3+ # Copyright (c) 2017 Radomir Dopieralski and Adafruit Industries
4+ #
5+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6+ # of this software and associated documentation files (the "Software"), to deal
7+ # in the Software without restriction, including without limitation the rights
8+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+ # copies of the Software, and to permit persons to whom the Software is
10+ # furnished to do so, subject to the following conditions:
11+ #
12+ # The above copyright notice and this permission notice shall be included in
13+ # all copies or substantial portions of the Software.
14+ #
15+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+ # THE SOFTWARE.
22+ """
23+ `adafruit_RGB_Display.rgb`
24+ ====================================================
25+
26+ Base class for all RGB Display devices
27+
28+ * Author(s): Radomir Dopieralski, Michael McWethy
29+ """
30+
231import time
332from micropython import const
433try :
1746
1847
1948def color565 (r , g , b ):
20- """Format color code for device"""
49+ """Convert red, green and blue values (0-255) into a 16-bit 565 encoding. As
50+ a convenience this is also available in the parent adafruit_rgb_display
51+ package namespace."""
2152 return (r & 0xf8 ) << 8 | (g & 0xfc ) << 3 | b >> 3
2253
2354
2455class DummyPin :
25- """A fake gpio pin for when you want to skip pins ."""
56+ """Can be used in place of a ``Pin()`` when you don't want to skip it ."""
2657 def init (self , * args , ** kwargs ):
2758 """Dummy Pin init"""
2859 pass
@@ -37,7 +68,10 @@ def high(self):
3768
3869
3970class Display : #pylint: disable-msg=no-member
40- """Base class for all RGB display devices"""
71+ """Base class for all RGB display devices
72+ :param width: number of pixels wide
73+ :param height: number of pixels high
74+ """
4175 _PAGE_SET = None
4276 _COLUMN_SET = None
4377 _RAM_WRITE = None
@@ -83,7 +117,7 @@ def _decode_pixel(self, data):
83117 return color565 (* struct .unpack (self ._DECODE_PIXEL , data ))
84118
85119 def pixel (self , x , y , color = None ):
86- """Read or write a pixel."""
120+ """Read or write a pixel at a given position ."""
87121 if color is None :
88122 return self ._decode_pixel (self ._block (x , y , x , y ))
89123
@@ -93,7 +127,8 @@ def pixel(self, x, y, color=None):
93127
94128 #pylint: disable-msg=too-many-arguments
95129 def fill_rectangle (self , x , y , width , height , color ):
96- """Draw a filled rectangle."""
130+ """Draw a rectangle at specified position with specified width and
131+ height, and fill it with the specified color."""
97132 x = min (self .width - 1 , max (0 , x ))
98133 y = min (self .height - 1 , max (0 , y ))
99134 width = min (self .width - x , max (1 , width ))
@@ -109,7 +144,7 @@ def fill_rectangle(self, x, y, width, height, color):
109144 #pylint: enable-msg=too-many-arguments
110145
111146 def fill (self , color = 0 ):
112- """Fill whole screen ."""
147+ """Fill the whole display with the specified color ."""
113148 self .fill_rectangle (0 , 0 , self .width , self .height , color )
114149
115150 def hline (self , x , y , width , color ):
0 commit comments