Skip to content

Added DisplayOrientation option. If set to "inverted" display is inverted. #23

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

Merged
merged 5 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions config.yaml.default
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ AgileCap: 101
DisplayType: inkyphat
# supported display types are "blinkt" or "inkyphat".

DisplayOrientation: standard
# supported orientations are "standard" or "inverted". Only relevant for Inky pHat.
# "Standard" means with the Inky pHat connector at the top and ribbon on the right.

DNORegion: B
# Permitted regions are:
# A = East England
Expand Down
14 changes: 14 additions & 0 deletions eco_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ def update_inky(conf: dict, inky_data: dict, demo: bool):
draw.line((x_pos, average_line_ypos, x_pos + 2, average_line_ypos),
inky_display.BLACK)

# Flip orientation if option is set
if conf['DisplayOrientation'] == 'inverted':
img=img.rotate(180)

inky_display.set_image(img)
inky_display.show()

Expand Down Expand Up @@ -529,6 +533,16 @@ def get_config(filename: str) -> dict:
elif _config['DisplayType'] == 'inkyphat':
print('Inky pHAT display selected.')

if _config['DisplayOrientation'] is None:
_config['DisplayOrientation'] = 'standard'
print('Standard display orientation.')
elif _config['DisplayOrientation'] == 'standard':
print('Standard display orientation.')
elif _config['DisplayOrientation'] == 'inverted':
print('Inverted display orientation.')
else:
raise SystemExit('Error: Unknown display orientation found in ' + filename + ': ' + _config['DisplayOrientation'])

conf_highprice = deep_get(_config, ['InkyPHAT', 'HighPrice'])
if not (isinstance(conf_highprice, (int, float)) and 0 <= conf_highprice <= 35):
print('Misconfigured high price value: ' + str(conf_highprice) +
Expand Down