Skip to content

Commit

Permalink
Fixing oled displays. #232
Browse files Browse the repository at this point in the history
  • Loading branch information
theyosh committed Jan 13, 2019
1 parent 4c5817d commit c5eeb7d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions terrariumDisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,22 +421,24 @@ def display_message(self,text_lines):
if self.get_title():
title = text_lines.pop(0)

while len(text_lines) > self.get_max_lines() - (1 if self.get_title() else 0):
while len(text_lines) >= self.get_max_lines() - (1 if self.get_title() else 0):
with canvas(self.device) as draw:
draw.rectangle(self.device.bounding_box, outline='white', fill='black')
linenr = 0

if self.get_title():
draw.rectangle((0,0,self.resolution[0],self.font_size), fill='white')
draw.text((1, linenr * self.font_size), title, font=self.font, fill='black')
linenr += 1
draw.text((1,0), title, font=self.font, fill='black')
print(title)

while linenr < len(text_lines) and linenr < self.get_max_lines():
draw.text((1, linenr * self.font_size), text_lines[linenr], font=self.font, fill='white')
linenr = 0
while linenr < len(text_lines) and linenr < self.get_max_lines()- (1 if self.get_title() else 0):
draw.text((1, (linenr + (1 if self.get_title() else 0)) * self.font_size), text_lines[linenr], font=self.font, fill='white')
print(text_lines[linenr])
linenr += 1

print('')
text_lines.pop(0)
sleep(1)
sleep(0.75)

self.animating = False

Expand Down

0 comments on commit c5eeb7d

Please sign in to comment.