@@ -42,24 +42,21 @@ class SSD1331(DisplaySPI):
42
42
"""
43
43
A simple driver for the SSD1331-based displays.
44
44
45
- >>> import busio
46
- >>> import digitalio
47
- >>> import board
48
- >>> from adafruit_rgb_display import color565
49
- >>> import adafruit_rgb_display.ssd1331 as ssd1331
50
- >>> spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
51
- >>> display = ssd1331.SSD1331(spi, cs=digitalio.DigitalInOut(board.GPIO0),
52
- ... dc=digitalio.DigitalInOut(board.GPIO15), rst=digitalio.DigitalInOut(board.GPIO16))
53
- >>> display.fill(0x7521)
54
- >>> display.pixel(32, 32, 0)
55
- >>>
56
- from machine import Pin, HSPI
57
- import ssd1331
58
- #spi = SPI(mosi=Pin(13), sck=Pin(14), polarity=1, phase=1)
59
- spi = HSPI(polarity=1, phase=1)
60
- display = ssd1331.SSD1331(spi, dc=Pin(2), cs=Pin(15), rst=Pin(16))
61
- display.fill(0x7521)
62
- 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
+
63
60
"""
64
61
_COLUMN_SET = _SETCOLUMN
65
62
_PAGE_SET = _SETROW
@@ -68,31 +65,43 @@ class SSD1331(DisplaySPI):
68
65
_INIT = (
69
66
(_DISPLAYOFF , b'' ),
70
67
(_LOCK , b'\x0b ' ),
71
- (_SETREMAP , b'\x72 ' ), # RGB Color
68
+ (_SETREMAP , b'\x72 ' ), # RGB Color
72
69
(_STARTLINE , b'\x00 ' ),
73
70
(_DISPLAYOFFSET , b'\x00 ' ),
74
71
(_NORMALDISPLAY , b'' ),
75
72
# (_FILL, b'\x01'),
76
- # (_PHASEPERIOD, b'\x31'),
77
- # (_SETMULTIPLEX, b'\x3f'),
78
- # (_SETMASTER, b'\x8e'),
79
- # (_POWERMODE,b'\x0b'),
80
- # (_PRECHARGE, b'\x31'), #;//0x1F - 0x31
81
- # (_CLOCKDIV, b'\xf0'),
82
- # (_VCOMH, b'\x3e'), #;//0x3E - 0x3F
83
- # (_MASTERCURRENT, b'\x06'), # ;//0x06 - 0x0F
84
- # (_PRECHARGEA, b'\x64'),
85
- # (_PRECHARGEB, b'\x78'),
86
- # (_PRECHARGEC, b'\x64'),
87
- # (_PRECHARGELEVEL, b'\x3a'), # 0x3A - 0x00
88
- # (_CONTRASTA, b'\x91'), #//0xEF - 0x91
89
- # (_CONTRASTB, b'\x50'), #;//0x11 - 0x50
90
- # (_CONTRASTC, b'\x7d'), #;//0x48 - 0x7D
73
+
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
91
89
(_DISPLAYON , b'' ),
92
90
)
93
91
_ENCODE_PIXEL = ">H"
94
92
_ENCODE_POS = ">BB"
95
93
96
- #pylint: disable-msg=useless-super-delegation, too-many-arguments
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
97
97
def __init__ (self , spi , dc , cs , rst = None , width = 96 , height = 64 ):
98
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