def __init__(self, spi, rst, ce, dc, light, pwr=None): self.width = 84 self.height = 48 self.power = self.POWER_DOWN self.addressing = self.ADDRESSING_HORIZ self.instr = self.INSTR_BASIC self.display_mode = self.DISPLAY_BLANK self.temp_coeff = self.TEMP_COEFF_0 self.bias = self.BIAS_1_11 self.voltage = 3060 # init the SPI bus and pins spi.init(spi.MASTER, baudrate=328125, bits=8, polarity=0, phase=1, firstbit=spi.MSB) if "OUT_PP" in dir(rst): # pyBoard style rst.init(rst.OUT_PP, rst.PULL_NONE) # Reset line ce.init(ce.OUT_PP, ce.PULL_NONE) # Chip Enable dc.init(dc.OUT_PP, dc.PULL_NONE) # Data(1) / Command(0) mode light.init(light.OUT_PP, light.PULL_NONE) if pwr: pwr.init(pwr.OUT_PP, pwr.PULL_NONE) else: # WiPy style rst.init(rst.OUT, None) ce.init(ce.OUT, None) dc.init(dc.OUT, None) light.init(light.OUT, None) if pwr: pwr.init(pwr.OUT, None) self.spi = spi self.rst = rst self.ce = ce self.dc = dc self.light = light self.pwr = pwr self.light_off() self.power_on() self.ce.value(1) # set chip to disable (don't listen to input) self.reset() self.set_contrast(0xbf) self.command([0x21, 0]) self.command([0xb0, 0]) self.command([0x20, 0]) self.clear() self.lcd_font = font.FONT6_8() self.lcd_pictuer = pictuer.pictuer() self.hc = [[0 for i in range(84)] for j in range(6)] self.tab1 = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80]
def __init__(self, spi, cs, dc, rst=None): self.width = 84 self.height = 48 self.spi = spi self.cs = cs # chip enable, active LOW self.dc = dc # data HIGH, command LOW self.rst = rst # reset, active LOW self.lcd_font = font.FONT6_8() self.chinese = chinese.CN_UTF8() self.chinese1 = chinese1.CN_UTF8() self.cs.init(self.cs.OUT, value=1) self.dc.init(self.dc.OUT, value=0) if self.rst: self.rst.init(self.rst.OUT, value=1) self.reset() self.init()