1
+ """A simple driver for the SSD1331-based displays."""
1
2
from adafruit_rgb_display .rgb import DisplaySPI
3
+ from micropython import const
4
+
5
+ __version__ = "0.0.0-auto.0"
6
+ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git"
2
7
3
8
4
9
_DRAWLINE = const (0x21 )
@@ -37,23 +42,21 @@ class SSD1331(DisplaySPI):
37
42
"""
38
43
A simple driver for the SSD1331-based displays.
39
44
40
- >>> import busio
41
- >>> import digitalio
42
- >>> import board
43
- >>> from adafruit_rgb_display import color565
44
- >>> import adafruit_rgb_display.ssd1331 as ssd1331
45
- >>> spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
46
- >>> display = ssd1331.SSD1331(spi, cs=digitalio.DigitalInOut(board.GPIO0), dc=digitalio.DigitalInOut(board.GPIO15), rst=digitalio.DigitalInOut(board.GPIO16))
47
- >>> display.fill(0x7521)
48
- >>> display.pixel(32, 32, 0)
49
- >>>
50
- from machine import Pin, HSPI
51
- import ssd1331
52
- #spi = SPI(mosi=Pin(13), sck=Pin(14), polarity=1, phase=1)
53
- spi = HSPI(polarity=1, phase=1)
54
- display = ssd1331.SSD1331(spi, dc=Pin(2), cs=Pin(15), rst=Pin(16))
55
- display.fill(0x7521)
56
- display.pixel(32, 32, 0)
45
+ .. code-block:: python
46
+
47
+ import busio
48
+ import digitalio
49
+ import board
50
+ from adafruit_rgb_display import color565
51
+ import adafruit_rgb_display.ssd1331 as ssd1331
52
+ spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
53
+ display = ssd1331.SSD1331(spi, cs=digitalio.DigitalInOut(board.GPIO0),
54
+ dc=digitalio.DigitalInOut(board.GPIO15),
55
+ rst=digitalio.DigitalInOut(board.GPIO16))
56
+
57
+ display.fill(0x7521)
58
+ display.pixel(32, 32, 0)
59
+
57
60
"""
58
61
_COLUMN_SET = _SETCOLUMN
59
62
_PAGE_SET = _SETROW
@@ -62,31 +65,43 @@ class SSD1331(DisplaySPI):
62
65
_INIT = (
63
66
(_DISPLAYOFF , b'' ),
64
67
(_LOCK , b'\x0b ' ),
65
- (_SETREMAP , b'\x72 ' ), # RGB Color
68
+ (_SETREMAP , b'\x72 ' ), # RGB Color
66
69
(_STARTLINE , b'\x00 ' ),
67
70
(_DISPLAYOFFSET , b'\x00 ' ),
68
71
(_NORMALDISPLAY , b'' ),
69
- # (_FILL, b'\x01'),
72
+ # (_FILL, b'\x01'),
70
73
71
- # (_PHASEPERIOD, b'\x31'),
72
- # (_SETMULTIPLEX, b'\x3f'),
73
- # (_SETMASTER, b'\x8e'),
74
- # (_POWERMODE,b'\x0b'),
75
- # (_PRECHARGE, b'\x31'), # ;//0x1F - 0x31
76
- # (_CLOCKDIV, b'\xf0'),
77
- # (_VCOMH, b'\x3e'), # ;//0x3E - 0x3F
78
- # (_MASTERCURRENT, b'\x06 '), # ;//0x06 - 0x0F
79
- # (_PRECHARGEA, b'\x64'),
80
- # (_PRECHARGEB, b'\x78'),
81
- # (_PRECHARGEC, b'\x64'),
82
- # (_PRECHARGELEVEL, b'\x3a'), # 0x3A - 0x00
83
- # (_CONTRASTA, b'\x91'), # //0xEF - 0x91
84
- # (_CONTRASTB, b'\x50'), # ;//0x11 - 0x50
85
- # (_CONTRASTC, b'\x7d'), # ;//0x48 - 0x7D
74
+ (_PHASEPERIOD , b'\x31 ' ),
75
+ (_SETMULTIPLEX , b'\x3f ' ),
76
+ (_SETMASTER , b'\x8e ' ),
77
+ (_POWERMODE , b'\x0b ' ),
78
+ (_PRECHARGE , b'\x31 ' ), # ;//0x1F - 0x31
79
+ (_CLOCKDIV , b'\xf0 ' ),
80
+ (_VCOMH , b'\x3e ' ), # ;//0x3E - 0x3F
81
+ (_MASTERCURRENT , b'\x0c ' ), # ;//0x06 - 0x0F
82
+ (_PRECHARGEA , b'\x64 ' ),
83
+ (_PRECHARGEB , b'\x78 ' ),
84
+ (_PRECHARGEC , b'\x64 ' ),
85
+ (_PRECHARGELEVEL , b'\x3a ' ), # 0x3A - 0x00
86
+ (_CONTRASTA , b'\x91 ' ), # //0xEF - 0x91
87
+ (_CONTRASTB , b'\x50 ' ), # ;//0x11 - 0x50
88
+ (_CONTRASTC , b'\x7d ' ), # ;//0x48 - 0x7D
86
89
(_DISPLAYON , b'' ),
87
90
)
88
91
_ENCODE_PIXEL = ">H"
89
92
_ENCODE_POS = ">BB"
90
93
94
+ # pylint: disable-msg=useless-super-delegation, too-many-arguments
95
+ # super required to allow override of default values
96
+ # All arguments needed due to driver requiring all the given data to function
91
97
def __init__ (self , spi , dc , cs , rst = None , width = 96 , height = 64 ):
92
98
super ().__init__ (spi , dc , cs , rst , width , height )
99
+
100
+ def write (self , command = None , data = None ):
101
+ """write procedure specific to SSD1331"""
102
+ self .dc .value = command is None
103
+ with self .spi_device as spi :
104
+ if command is not None :
105
+ spi .write (bytearray ([command ]))
106
+ if data is not None :
107
+ spi .write (data )
0 commit comments