Skip to content

Commit

Permalink
Merge pull request #78 from ZeroPhone/driver_name_quickfix
Browse files Browse the repository at this point in the history
fixes emulator/luma fields consistency
  • Loading branch information
CRImier committed Jan 5, 2018
2 parents a939dea + a98901b commit ce9975d
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions output/drivers/luma_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
except ImportError:
from luma.core.serial import spi, i2c #Compatilibity with older luma.oled version
from luma.core.render import canvas
from time import sleep
from threading import Event

from backlight import *


def delayMicroseconds(microseconds):
seconds = microseconds / float(1000000) # divide microseconds by 1 million for seconds
sleep(seconds)
Expand Down Expand Up @@ -49,10 +49,10 @@ def __init__(self, hw = "spi", port=None, address = 0, debug = False, buffering
self.busy_flag = Event()
self.width = 128
self.height = 64
self.charwidth = 6
self.charheight = 8
self.cols = self.width/self.charwidth
self.rows = self.height/self.charheight
self.char_width = 6
self.char_height = 8
self.cols = self.width / self.char_width
self.rows = self.height / self.char_height
self.debug = debug
self.init_display(**kwargs)
BacklightManager.init_backlight(self, **kwargs)
Expand Down Expand Up @@ -90,10 +90,11 @@ def display_data(self, *args):
draw = canvas(self.device)
d = draw.__enter__()
if self.cursor_enabled:
dims = (self.cursor_pos[0]-1+2, self.cursor_pos[1]-1, self.cursor_pos[0]+self.charwidth+2, self.cursor_pos[1]+self.charheight+1)
dims = (self.cursor_pos[0] - 1 + 2, self.cursor_pos[1] - 1, self.cursor_pos[0] + self.char_width + 2,
self.cursor_pos[1] + self.char_height + 1)
d.rectangle(dims, outline="white")
for line, arg in enumerate(args):
y = (line*self.charheight - 1) if line != 0 else 0
y = (line * self.char_height - 1) if line != 0 else 0
d.text((2, y), arg, fill="white")
self.busy_flag.clear()
self.display_image(draw.image)
Expand All @@ -109,7 +110,7 @@ def clear(self):

def setCursor(self, row, col):
""" Set current input cursor to ``row`` and ``column`` specified """
self.cursor_pos = (col*self.charwidth, row*self.charheight)
self.cursor_pos = (col * self.char_width, row * self.char_height)

def createChar(self, char_num, char_contents):
"""Stores a character in the LCD memory so that it can be used later.
Expand Down

0 comments on commit ce9975d

Please sign in to comment.