예제 #1
0
def display_curdata(temperature,pressure,humidity):
    # Hardware SPI usage:
    disp = LCD.PCD8544(DC, RST, spi=SPIDEV)
    # Initialize library.
    disp.begin(contrast=DEFAULT_CONTRAST)
    # Clear display.
    disp.clear()
    disp.display()
    
    # Create blank image for drawing.
    # Make sure to create image with mode '1' for 1-bit color.
    image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))
    
    # Get drawing object to draw on image.
    draw = ImageDraw.Draw(image)
    
    # Draw a white filled box to clear the image.
    draw.rectangle((0,0,LCD.LCDWIDTH,LCD.LCDHEIGHT), outline=255, fill=255)
    
    # Load font.
    font_path='dotmatrixnormal.ttf'
    font = ImageFont.truetype(font_path,8)

    datastring='T = %6.1f C' % temperature
    draw.text((4,8), datastring, font=font)
    datastring='P = %6.1f Pa' % pressure
    draw.text((4,20), datastring, font=font)
    datastring='HR= %6.1f %%' % humidity
    draw.text((4,32), datastring, font=font)
    
    # Display image.
    disp.image(image)
    disp.display()
예제 #2
0
파일: main.py 프로젝트: bcsedlon/v-plotter
    def init():
        if _GPIO_:
            #lcd.init()
            #lcd.cls()
            ##lcd.backlight(ON)
            #lcd.gotorc(0,0)
            #lcd.text("v-plotter")

            lcdHW.disp = LCD.PCD8544(DC,
                                     RST,
                                     spi=SPI.SpiDev(SPI_PORT,
                                                    SPI_DEVICE,
                                                    max_speed_hz=4000000))
            lcdHW.disp.begin(contrast=60)
            lcdHW.disp.clear()
            lcdHW.disp.display()

            # Make sure to create image with mode '1' for 1-bit color.
            lcdHW.image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))
            # Get drawing object to draw on image.
            lcdHW.draw = ImageDraw.Draw(lcdHW.image)
            # Draw a white filled box to clear the image.
            #draw.rectangle((0,0,LCD.LCDWIDTH,LCD.LCDHEIGHT), outline=255, fill=255)
            # Load default font.
            lcdHW.font = ImageFont.load_default()
def picture():
    # Hardware SPI usage:
    disp = LCD.PCD8544(DC,
                       RST,
                       spi=SPI.SpiDev(SPI_PORT,
                                      SPI_DEVICE,
                                      max_speed_hz=4000000))

    # Initialize library.
    disp.begin(contrast=60)

    # Clear display.
    disp.clear()
    disp.display()

    # Create blank image for drawing.
    # Make sure to create image with mode '1' for 1-bit color.
    image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))

    # Get drawing object to draw on image.
    draw = ImageDraw.Draw(image)

    #part picture
    image = Image.open('LogoIP_2.png').convert('1')

    # Display image.
    disp.image(image)
    disp.display()
예제 #4
0
def escreva(texto):
    DC = 23
    RST = 24
    SPI_PORT = 0
    SPI_DEVICE = 0
    # Hardware SPI usage:
    disp = LCD.PCD8544(DC,
                       RST,
                       spi=SPI.SpiDev(SPI_PORT,
                                      SPI_DEVICE,
                                      max_speed_hz=4000000))
    # Initialize library.
    disp.begin(contrast=90)
    # Clear display.
    disp.clear()
    disp.display()
    image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))
    # Get drawing object to draw on image.
    draw = ImageDraw.Draw(image)
    # Draw a white filled box to clear the image.
    draw.rectangle((0, 0, LCD.LCDWIDTH, LCD.LCDHEIGHT), outline=255, fill=255)
    # Load default font.
    font = ImageFont.load_default()
    # Write some text.
    draw.text((2, 10), texto, font=font)
    # Display image.
    disp.image(image)
    disp.display()
 def test_data_sets_dc_high(self):
     gpio = Mock()
     spi = Mock()
     lcd = LCD.PCD8544(1, 2, gpio=gpio, spi=spi)
     lcd.data(0xDE)
     gpio.set_high.assert_called_with(1)
     spi.write.assert_called_with([0xDE])
예제 #6
0
def Text(jam,date,data):
	# Hardware SPI usage:
	disp = LCD.PCD8544(DC, RST, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=4000000))

	# Initialize library.
	disp.begin(contrast=60)

	# Clear display.
	disp.clear()
	disp.display()

	# Create blank image for drawing.
	# Make sure to create image with mode '1' for 1-bit color.
	image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))

	# Get drawing object to draw on image.
	draw = ImageDraw.Draw(image)

	# Draw a white filled box to clear the image.
	draw.rectangle((0,0,LCD.LCDWIDTH,LCD.LCDHEIGHT), outline=255, fill=255)

	# Load default font.
	font = ImageFont.load_default()
			
	# Write some text.	
	draw.text((0,0),'{}'.format(jam),font=font)#Line 1
	draw.text((0,10),'{}'.format(date),font=font)#Line 2			
	draw.text((0,25),'Pilih Lagu:',font=font)#Line 4
	draw.text((0,35),'{}'.format(data),font=font)#Line 5

	# Display image.
	disp.clear()
	disp.image(image)
	disp.display()						
예제 #7
0
def LCD_Draw(P, B, S):
    DC = 23
    RST = 24
    SPI_PORT = 0
    SPI_DEVICE = 0

    disp = LCD.PCD8544(DC,
                       RST,
                       spi=SPI.SpiDev(SPI_PORT,
                                      SPI_DEVICE,
                                      max_speed_hz=4000000))
    disp.begin(contrast=60)

    disp.clear()
    disp.display()
    image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))

    draw = ImageDraw.Draw(image)

    # Draw a white filled box to clear the image.
    draw.rectangle((0, 0, LCD.LCDWIDTH, LCD.LCDHEIGHT), outline=255, fill=255)

    font = ImageFont.load_default()

    draw.text((0, 2), 'Find: ' + 'Patrat' if P else 'Lillipup', font=font)
    draw.text((0, 15), 'Cap: ' + 'yes' if not B else 'no', font=font)
    draw.text((0, 30), S, font=font)

    disp.image(image)
    disp.display()
    def __init__(self):
        if appDebug:
            print('initializing display class')
        # Initialize library.
        self.disp = LCD.PCD8544(self.DC_PORT,
                                self.RST_PORT,
                                spi=SPI.SpiDev(self.SPI_PORT,
                                               self.SPI_DEVICE,
                                               max_speed_hz=self.MAX_SPEED_HZ))
        self.disp.begin(contrast=self.CONTRAST)
        self.image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))

        try:
            #self.font = ImageFont.load_path(self.customFont)
            #self.font = ImageFont.truetype(font=self.customFont, size=10, index=0, encoding='')
            self.font = ImageFont.truetype("arial.ttf", 12)
        except IOError:
            if appDebug:
                print('ttf font not loaded, falling back to default font')
            self.font = ImageFont.load_default()

        self.draw = ImageDraw.Draw(self.image)
        self.draw.rectangle((0, 0, LCD.LCDWIDTH, LCD.LCDHEIGHT),
                            outline=255,
                            fill=255)

        # Clear display.
        self.disp.clear()
        self.disp.display()
        if appDebug:
            print('display class initialized')
예제 #9
0
    def __init__(self, SCLK = _SCLK, DIN = _DIN, DC = _DC, RST = _RST, CS = _CS,
                 CONTRAST = _CONTRAST, FONT_SIZE = 10):
        self._SCLK = SCLK
        self._DIN = DIN
        self._RST = RST
        self._CS = CS
        self._DC = DC
        self._CONTRAST = CONTRAST
        self._FONT_SIZE = FONT_SIZE
        # Software SPI usage (defaults to bit-bang SPI interface):
        self._disp = LCD.PCD8544(self._DC, self._RST, self._SCLK, self._DIN, self._CS)

        # Initialize library.
        self._disp.begin(contrast=127)

        # Create blank image for drawing.
        # Make sure to create image with mode '1' for 1-bit color.
        self._image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))
        # Clear display.
        self._disp.clear()
        self._disp.display()

        draw = ImageDraw.Draw(self._image)
        # Draw a white filled box to clear the image.
        draw.rectangle((0,0,LCD.LCDWIDTH,LCD.LCDHEIGHT), outline=255, fill=255)
 def test_command_sets_dc_low(self):
     gpio = Mock()
     spi = Mock()
     lcd = LCD.PCD8544(1, 2, gpio=gpio, spi=spi)
     lcd.command(0xDE)
     gpio.set_low.assert_called_with(1)
     spi.write.assert_called_with([0xDE])
 def __init__(self):
     self.disp = LCD.PCD8544(DC, RST, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=4000000))
     self.disp.begin(contrast=60)
     self.disp.clear()
     self.disp.display()
     self.font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf", 8)
     self.image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))
     self.draw = ImageDraw.Draw(self.image)
     self.bigFont = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf", 9)
예제 #12
0
 def beginLCD(self):
     GPIO.setmode(GPIO.BCM)
     GPIO.setup(self.LCD_BL, GPIO.OUT)
     GPIO.output(self.LCD_BL, GPIO.HIGH)
     self.Display = LCD.PCD8544(self.LCD_DC,
                                self.LCD_RST,
                                spi=SPI.SpiDev(0, 0, max_speed_hz=4000000))
     self.Display.begin(contrast=60)
     self.Display.clear()
     self.Display.display()
예제 #13
0
    def __init__(self):
        self.disp = LCD.PCD8544(DC, RST, SCLK, DIN, CE)
        self.disp.begin(contrast=CONTRAST)

        self.disp.clear()
        self.disp.display()

        # Make sure to create image with mode '1' for 1-bit color.
        self.image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))

        # Get drawing object to draw on image.
        self.draw = ImageDraw.Draw(self.image)
예제 #14
0
 def __init__(self, SCLK=21, DIN=20, DC=16, RST=7, CS=12):
     self.SCLK = SCLK
     self.DIN = DIN
     self.DC = DC
     self.RST = RST
     self.CS = CS
     self.disp = LCD.PCD8544(DC, RST, SCLK, DIN, CS)
     self.disp.begin(contrast=60)
     self.font = ImageFont.load_default(
     )  #ImageFont.truetype('Minecraftia.ttf', 8)
     self.clear_scrn()
     self.empty_canvas()
예제 #15
0
def imagem():
    # Raspberry Pi hardware SPI config:
    DC = 23
    RST = 24
    SPI_PORT = 0
    SPI_DEVICE = 0

    # Raspberry Pi software SPI config:
    # SCLK = 4
    # DIN = 17
    # DC = 23
    # RST = 24
    # CS = 8

    # Beaglebone Black hardware SPI config:
    # DC = 'P9_15'
    # RST = 'P9_12'
    # SPI_PORT = 1
    # SPI_DEVICE = 0

    # Beaglebone Black software SPI config:
    # DC = 'P9_15'
    # RST = 'P9_12'
    # SCLK = 'P8_7'
    # DIN = 'P8_9'
    # CS = 'P8_11'

    # Hardware SPI usage:
    disp = LCD.PCD8544(DC,
                       RST,
                       spi=SPI.SpiDev(SPI_PORT,
                                      SPI_DEVICE,
                                      max_speed_hz=4000000))

    # Software SPI usage (defaults to bit-bang SPI interface):
    #disp = LCD.PCD8544(DC, RST, SCLK, DIN, CS)

    # Initialize library.
    disp.begin(contrast=60)

    # Clear display.
    disp.clear()
    disp.display()

    # Load image and convert to 1 bit color.
    image = Image.open('capturar2.ppm').convert('1')

    # Alternatively load a different format image, resize it, and convert to 1 bit color.
    #image = Image.open('happycat.png').resize((LCD.LCDWIDTH, LCD.LCDHEIGHT), Image.ANTIALIAS).convert('1')

    # Display image.
    disp.image(image)
    disp.display()
예제 #16
0
    def __init__(self):
        super(Nokia, self).__init__()
        GPIO.setup(Config.LIGHT, GPIO.OUT)
        self._toggle = False

        self._display = LCD.PCD8544(Config.DC,
                                    Config.RST,
                                    spi=SPI.SpiDev(Config.SPI_PORT,
                                                   Config.SPI_DEVICE,
                                                   max_speed_hz=4000000))
        self._display.begin(contrast=Config.CONTRAST)
        self.clear()

        pass
예제 #17
0
	def __init__(self):
		# Raspberry Pi software SPI config:
		self.SCLK = 2
		self.DIN = 3
		self.DC = 14
		self.RST = 15
		self.CS = 8

		# Software SPI usage (defaults to bit-bang SPI interface):
		self.disp = LCD.PCD8544(self.DC, self.RST, self.SCLK, self.DIN, self.CS)

		self.disp.begin(contrast=50)

		self.highlight = "top"
예제 #18
0
    def __init__(self, graph, uri, pi, din, clk, dc, rst):
        super(Lcd8544, self).__init__(graph, uri, pi, None)


        import RPi.GPIO
        import Adafruit_Nokia_LCD
        import Adafruit_GPIO.SPI
        self.lcd = Adafruit_Nokia_LCD.PCD8544(
            dc=8, rst=7,
            spi=Adafruit_GPIO.SPI.BitBang(
                Adafruit_Nokia_LCD.GPIO.RPiGPIOAdapter(RPi.GPIO),
                sclk=clk,
                mosi=din))
        self.lcd.begin(contrast=60)
 def test_begin_initializes_lcd(self):
     gpio = Mock()
     spi = Mock()
     lcd = LCD.PCD8544(1, 2, gpio=gpio, spi=spi)
     lcd.begin(40)
     # Verify RST is set low then high.
     gpio.assert_has_calls([call.set_low(2), call.set_high(2)])
     # Verify SPI calls.
     spi.assert_has_calls([
         call.write([0x21]),
         call.write([0x14]),
         call.write([0xA8]),
         call.write([0x20]),
         call.write([0x0c])
     ])
예제 #20
0
    def __init__(self):
        SPI_PORT = 0
        SPI_DEVICE = 0
        SCLK = 4
        DIN = 17
        DC = 23
        RST = 24
        CS = 8
        # Hardware SPI usage:
        self.disp = LCD.PCD8544(DC,
                                RST,
                                spi=SPI.SpiDev(SPI_PORT,
                                               SPI_DEVICE,
                                               max_speed_hz=4000000))

        # Software SPI usage (defaults to bit-bang SPI interface):
        #disp = LCD.PCD8544(DC, RST, SCLK, DIN, CS)

        # Load default font.
        # Alternatively load a TTF font.
        # Some nice fonts to try: http://www.dafont.com/bitmap.php
        # self.font = ImageFont.truetype('arial.ttf', 8)

        self.font = ImageFont.load_default()

        # Initialize library.
        self.disp.begin(contrast=30)

        # Clear display.
        #disp.clear()
        self.disp.display()

        # Create blank image for drawing.
        # Make sure to create image with mode '1' for 1-bit color.
        self.image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))

        # Get drawing object to draw on image.
        self.draw = ImageDraw.Draw(self.image)

        # Draw a white filled box to clear the image.
        self.draw.rectangle((0, 0, LCD.LCDWIDTH, LCD.LCDHEIGHT),
                            outline=255,
                            fill=255)

        f = 255 * np.ones(12)
        self.print_bars(f)
예제 #21
0
파일: clocknokia.py 프로젝트: cakebot/mypi
def setup_screen():
    # turn buzzer off by default
    GPIO.output(buzzer, False)
    # Hardware SPI usage:
    disp = LCD.PCD8544(DC,
                       RST,
                       spi=SPI.SpiDev(SPI_PORT,
                                      SPI_DEVICE,
                                      max_speed_hz=4000000))

    # Initialize library.
    disp.begin(contrast=60)

    # Clear display.
    disp.clear()
    disp.display()
    return disp
예제 #22
0
def display_image(image_file):
    # Hardware SPI usage:
    disp = LCD.PCD8544(DC, RST, spi=SPIDEV)
    # Initialize library.
    disp.begin(contrast=DEFAULT_CONTRAST)
    
    # Clear display.
    disp.clear()
    disp.display()
    
    # Load image and convert to 1 bit color and resize
    image = Image.open(image_file).convert('1').resize((LCD.LCDWIDTH, LCD.LCDHEIGHT))
    # Force black and white
    imgbw=image.point(lambda x: 0 if x<230 else 255, '1')

    # Display image.
    disp.image(imgbw)
    disp.display()
def initLCD():

    global display
    global image
    global draw
    global font

    #Hardware SPI usage:
    display = LCD.PCD8544(DC, RST, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=4000000))

    #Initialize library
    display.begin(contrast = 60)

    image = Image.new("1",(LCD.LCDWIDTH, LCD.LCDHEIGHT))
    draw=ImageDraw.Draw(image)

    font=ImageFont.load_default()
    mode = GPIO.getmode()
예제 #24
0
def lcd_display(T,RH):
	DC = 23
	RST = 24
	SPI_PORT = 0
	SPI_DEVICE = 0
	disp = LCD.PCD8544(DC, RST, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=4000000))
	disp.begin(contrast=60)
	disp.clear()
	disp.display()
	image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))
	draw = ImageDraw.Draw(image)
	draw.rectangle((0,0,LCD.LCDWIDTH,LCD.LCDHEIGHT), outline=255, fill=255)
	font = ImageFont.load_default()
	draw.text((2,10),"temp"+str(T), font=font)
	draw.text((2,30), "punna"+str(RH), font=font)
	disp.image(image)
	disp.display()
	print('Press Ctrl-C to quit.')
예제 #25
0
def main():
    global broker_ip
    global cycle_temperature
    global temp_counter
    global start_time
    global log_cnt
    global activity_cnt
    global mqttc

    globals.init()

    if lcd_type == 2:
        globals.disp = LCD.PCD8544(23,
                                   24,
                                   spi=SPI.SpiDev(0, 0, max_speed_hz=4000000))

    RecordSet = [0, 0, "Welcome to**PrivateEyePi", 5, 0, 0, 0, 0]
    DisplayLCD(RecordSet)

    temp_counter = 0
    mqttc = paho.Client()
    mqttc.on_message = on_message
    mqttc.connect(broker_ip, 1883, 60)
    mqttc.subscribe("alarm_activity", 0)
    mqttc.subscribe("temperature", 0)
    start_time = time.time()

    rc = 0
    while rc == 0:
        ProcessMessageThread(rc)
        elapsed_time = time.time() - start_time
        if (elapsed_time > 10):
            log_cnt = activity_cnt
            if cycle_temperature:
                DisplayNextTemperature()
                start_time = time.time()
        if button_gpio > 0:
            PollGPIO()

        time.sleep(.2)

    return 0
예제 #26
0
def weatherWriter(connexion):
    weather_dict = {}
    #Hardware setup
    DC = 23
    RST = 24
    SPI_PORT = 0
    SPI_DEVICE = 0
    display = LCD.PCD8544(DC,RST, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=4000000))
    display.begin(contrast=60)
    display.clear()
    font = ImageFont.load('Tamsyn5x9r.pil')
    fontBig = ImageFont.load('Tamsyn6x12r.pil')
    fontSuperBig = ImageFont.truetype('vcr.ttf', 20)

    while True:
        if connexion.poll(None):
            weather_dict = connexion.recv()

        current_conditions = []
        try:
            current_conditions.append(weather_dict['currently']['summary'])
        except (KeyError):
            continue
        current_conditions.append("{0}C".format(str(weather_dict['currently']['temperature'])))
        current_conditions.append("Rain:" + str(weather_dict['currently']['precipProbability']) + " chance")

        con_icon = IMAGE_DIR + weather_dict['currently']['icon'] + ".png"
        icon = Image.open(con_icon)
        for item in current_conditions:
            display.clear()
            image = Image.new("1", (LCD.LCDWIDTH, LCD.LCDHEIGHT))
            draw = ImageDraw.Draw(image)
            draw.rectangle((0,0,LCD.LCDWIDTH, LCD.LCDHEIGHT), fill=255, outline=255)
            image.paste(icon, (0,0,LCD.LCDHEIGHT, LCD.LCDHEIGHT))
            itemWrapped = textwrap.wrap(item, 7)
            y = 0
            for line in itemWrapped:
                draw.text((48,y), line ,font=font)
                y+=7
            display.image(image)
            display.display()
            time.sleep(2)
예제 #27
0
 def __init__(self,
              pin_DC="P9_26",
              pin_RST="P9_25",
              pin_SCE="P9_11",
              contrast=0xbb):
     self.SCE = pin_SCE
     spi_port = 1
     spi_device = 0
     spi = SPI.SpiDev(spi_port, spi_device, max_speed_hz=4000000)
     self.lcd = LCD.PCD8544(pin_DC, pin_RST, spi=spi)
     self.contrast = contrast
     GPIO.setup(pin_SCE, GPIO.OUT)
     GPIO.output(pin_SCE, GPIO.HIGH)
     self.pix_width = 84
     self.pix_height = 48
     self.buffer = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))
     self.draw = ImageDraw.Draw(self.buffer)
     self.cursor = (0, 0)
     self.line_height = 8
     self.font = ImageFont.truetype("nokiafc22.ttf", self.line_height)
예제 #28
0
 def __init__(self):
     self.DC = 23
     self.RST = 24
     self.SPI_PORT = 0
     self.SPI_DEVICE = 0
     self.disp = LCD.PCD8544(self.DC,
                             self.RST,
                             spi=SPI.SpiDev(self.SPI_PORT,
                                            self.SPI_DEVICE,
                                            max_speed_hz=4000000))
     self.disp.begin(contrast=40)
     self.disp.clear()
     self.disp.display()
     self.image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))
     self.draw = ImageDraw.Draw(self.image)
     self.draw.rectangle((0, 0, LCD.LCDWIDTH, LCD.LCDHEIGHT),
                         outline=255,
                         fill=255)
     self.fuente = ImageFont.load_default()
     self.contador = 1
예제 #29
0
def setup():
  global devices, params, name, disp, imageText, draw, font
  devices = [InputDevice(i) for i in list_devices()]
  devices = {dev.fd: dev for dev in devices if dev.name.startswith('rotary@')}
  labels = ['Param 1', 'Param 2', 'Param 3', 'Param 4']
  params = {f: [labels[i], 0] for i,f in enumerate(devices)}

  ASSET_DIR=os.path.join(os.path.dirname(__file__), 'assets')
  disp = LCD.PCD8544(23, 24, spi=SPI.SpiDev(0, 0, max_speed_hz=4000000))
  font = ImageFont.truetype('%s/ProFontWindows.ttf' % ASSET_DIR, 6)
  imageText = Image.new('1',(LCD.LCDWIDTH, LCD.LCDHEIGHT))
  imageWait = Image.open('%s/please_wait.ppm' % ASSET_DIR).convert('1')
  draw = ImageDraw.Draw(imageText)
  name='EFFECT NAME'

  disp.begin(contrast=60)
  disp.clear()
  disp.image(imageWait)
  disp.display()
  time.sleep(1)
예제 #30
0
  def __init__(self):
    self.DC = 23
    self.RST = 24
    self.SPI_PORT = 0
    self.SPI_DEVICE = 0

    # Hardware SPI usage:
    self.disp = LCD.PCD8544(
        self.DC, self.RST, 
        spi=SPI.SpiDev(self.SPI_PORT, self.SPI_DEVICE, 
        max_speed_hz=4000000))

    # Software SPI usage (defaults to bit-bang SPI interface):
    #disp = LCD.PCD8544(DC, RST, SCLK, DIN, CS)

    # Initialize library.
    self.disp.begin(contrast=60)

    # Clear display.
    self.disp.clear()
    self.disp.display()

    # Raspberry Pi software SPI config:
    # SCLK = 4
    # DIN = 17
    # DC = 23
    # RST = 24
    # CS = 8


    # Create blank image for drawing.
    # Make sure to create image with mode '1' for 1-bit color.
    self.image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))

    # Get drawing object to draw on image.
    self.draw = ImageDraw.Draw(self.image)

    # Draw a white filled box to clear the image.
    self.draw.rectangle(
        (0,0,LCD.LCDWIDTH,LCD.LCDHEIGHT), outline=255, fill=255)