Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Test Character testing #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions inkyshot/update-display.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ def temp_to_str(temp, scale):
while message_does_not_fit == True:
test_message = ""
message_width = 0
FONT_SIZE -= 1
FONT = ImageFont.truetype(FONT_SELECTED, FONT_SIZE)

if FONT_SIZE <= 17:
FONT_SIZE = 8
if FONT_SIZE <= 12:
FONT_SIZE = 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been testing and I think here you might be making changes specific to the Waveshare display, the pixel font in size 10 on the InkyPHAT isn't readable at all, and the same goes for allowing the selected font to go down to 12, probably because the display is a slightly different resolution. I'd be happy to merge the optimisations but we'll need to make them specific to that display when it comes to sizes. We could also consider default values specific to the display type, but user-configurable too.

FONT = ImageFont.truetype("/usr/app/fonts/Grand9KPixel.ttf", FONT_SIZE)

# We're using the test character here to work out how many characters
Expand All @@ -384,9 +384,12 @@ def temp_to_str(temp, scale):
if len(word_list) <= max_lines:
message_does_not_fit = False

if FONT_SIZE < 9:
if FONT_SIZE <= 10:
message_does_not_fit = False

if message_does_not_fit:
FONT_SIZE -= 1

logging.info("Font size: %s", FONT_SIZE)
offset_x, offset_y = FONT.getoffset(message)

Expand Down Expand Up @@ -417,4 +420,4 @@ def temp_to_str(temp, scale):
if MODE == 'alternate':
set_current_display(target_display)

sys.exit(0)
sys.exit(0)