MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / module_init

Method module_init

resources/waveshare_epd/epdconfig.py:86–117  ·  view source on GitHub ↗
(self, cleanup=False)

Source from the content-addressed store, hash-verified

84 return self.DEV_SPI.DEV_SPI_ReadData()
85
86 def module_init(self, cleanup=False):
87 self.GPIO_PWR_PIN.on()
88
89 if cleanup:
90 find_dirs = [
91 os.path.dirname(os.path.realpath(__file__)),
92 '/usr/local/lib',
93 '/usr/lib',
94 ]
95 self.DEV_SPI = None
96 for find_dir in find_dirs:
97 val = int(os.popen('getconf LONG_BIT').read())
98 # logging.debug("System is %d bit"%val)
99 if val == 64:
100 so_filename = os.path.join(find_dir, 'DEV_Config_64.so')
101 else:
102 so_filename = os.path.join(find_dir, 'DEV_Config_32.so')
103 if os.path.exists(so_filename):
104 self.DEV_SPI = CDLL(so_filename)
105 break
106 if self.DEV_SPI is None:
107 RuntimeError('Cannot find DEV_Config.so')
108
109 self.DEV_SPI.DEV_Module_Init()
110
111 else:
112 # SPI device, bus = 0, device = 0
113 self.SPI.open(0, 0)
114 # Read SPI clock speed from shared config (default 4 MHz — matches Waveshare official)
115 self.SPI.max_speed_hz = self._read_spi_clock_hz()
116 self.SPI.mode = 0b00
117 return 0
118
119 def _read_spi_clock_hz(self, default_mhz=4):
120 """Read spi_clock_mhz from shared_config.json; fall back to default_mhz."""

Callers

nothing calls this directly

Calls 3

_read_spi_clock_hzMethod · 0.95
openMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected