@@ -41,6 +41,7 @@ class RaspberryPi:
4141 DC_PIN = 25
4242 CS_PIN = 8
4343 BUSY_PIN = 24
44+ PWR_PIN = 18
4445
4546 def __init__ (self ):
4647 import spidev
@@ -70,7 +71,10 @@ def module_init(self):
7071 self .GPIO .setup (self .RST_PIN , self .GPIO .OUT )
7172 self .GPIO .setup (self .DC_PIN , self .GPIO .OUT )
7273 self .GPIO .setup (self .CS_PIN , self .GPIO .OUT )
74+ self .GPIO .setup (self .PWR_PIN , self .GPIO .OUT )
7375 self .GPIO .setup (self .BUSY_PIN , self .GPIO .IN )
76+
77+ self .GPIO .output (self .PWR_PIN , 1 )
7478
7579 # SPI device, bus = 0, device = 0
7680 self .SPI .open (0 , 0 )
@@ -85,8 +89,9 @@ def module_exit(self):
8589 logger .debug ("close 5V, Module enters 0 power consumption ..." )
8690 self .GPIO .output (self .RST_PIN , 0 )
8791 self .GPIO .output (self .DC_PIN , 0 )
92+ self .GPIO .output (self .PWR_PIN , 0 )
8893
89- self .GPIO .cleanup ([self .RST_PIN , self .DC_PIN , self .CS_PIN , self .BUSY_PIN ])
94+ self .GPIO .cleanup ([self .RST_PIN , self .DC_PIN , self .CS_PIN , self .BUSY_PIN , self . PWR_PIN ])
9095
9196
9297class JetsonNano :
@@ -95,6 +100,7 @@ class JetsonNano:
95100 DC_PIN = 25
96101 CS_PIN = 8
97102 BUSY_PIN = 24
103+ PWR_PIN = 18
98104
99105 def __init__ (self ):
100106 import ctypes
@@ -137,7 +143,11 @@ def module_init(self):
137143 self .GPIO .setup (self .RST_PIN , self .GPIO .OUT )
138144 self .GPIO .setup (self .DC_PIN , self .GPIO .OUT )
139145 self .GPIO .setup (self .CS_PIN , self .GPIO .OUT )
146+ self .GPIO .setup (self .PWR_PIN , self .GPIO .OUT )
140147 self .GPIO .setup (self .BUSY_PIN , self .GPIO .IN )
148+
149+ self .GPIO .output (self .PWR_PIN , 1 )
150+
141151 self .SPI .SYSFS_software_spi_begin ()
142152 return 0
143153
@@ -148,8 +158,9 @@ def module_exit(self):
148158 logger .debug ("close 5V, Module enters 0 power consumption ..." )
149159 self .GPIO .output (self .RST_PIN , 0 )
150160 self .GPIO .output (self .DC_PIN , 0 )
161+ self .GPIO .output (self .PWR_PIN , 0 )
151162
152- self .GPIO .cleanup ([self .RST_PIN , self .DC_PIN , self .CS_PIN , self .BUSY_PIN ])
163+ self .GPIO .cleanup ([self .RST_PIN , self .DC_PIN , self .CS_PIN , self .BUSY_PIN , self . PWR_PIN ])
153164
154165
155166class SunriseX3 :
@@ -158,6 +169,7 @@ class SunriseX3:
158169 DC_PIN = 25
159170 CS_PIN = 8
160171 BUSY_PIN = 24
172+ PWR_PIN = 18
161173 Flag = 0
162174
163175 def __init__ (self ):
@@ -192,8 +204,11 @@ def module_init(self):
192204 self .GPIO .setup (self .RST_PIN , self .GPIO .OUT )
193205 self .GPIO .setup (self .DC_PIN , self .GPIO .OUT )
194206 self .GPIO .setup (self .CS_PIN , self .GPIO .OUT )
207+ self .GPIO .setup (self .PWR_PIN , self .GPIO .OUT )
195208 self .GPIO .setup (self .BUSY_PIN , self .GPIO .IN )
196209
210+ self .GPIO .output (self .PWR_PIN , 1 )
211+
197212 # SPI device, bus = 0, device = 0
198213 self .SPI .open (2 , 0 )
199214 self .SPI .max_speed_hz = 4000000
@@ -210,8 +225,9 @@ def module_exit(self):
210225 self .Flag = 0
211226 self .GPIO .output (self .RST_PIN , 0 )
212227 self .GPIO .output (self .DC_PIN , 0 )
228+ self .GPIO .output (self .PWR_PIN , 0 )
213229
214- self .GPIO .cleanup ([self .RST_PIN , self .DC_PIN , self .CS_PIN , self .BUSY_PIN ])
230+ self .GPIO .cleanup ([self .RST_PIN , self .DC_PIN , self .CS_PIN , self .BUSY_PIN ], self . PWR_PIN )
215231
216232
217233if os .path .exists ('/sys/bus/platform/drivers/gpiomem-bcm2835' ):
0 commit comments