Skip to content

Commit 645f01d

Browse files
sidewinder42jerbzz
andauthored
Added DisplayOrientation option. If set to "inverted" display is inverted. (#23)
* Update config.yaml.default * Update config.yaml.default * Update eco_indicator.py * Further explain config option * Handle missing DisplayOrientation and fix whitespace --------- Co-authored-by: James Herbert <james@artyzan.net>
1 parent 5335f1d commit 645f01d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

config.yaml.default

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ AgileCap: 101
1313
DisplayType: inkyphat
1414
# supported display types are "blinkt" or "inkyphat".
1515

16+
DisplayOrientation: standard
17+
# supported orientations are "standard" or "inverted". Only relevant for Inky pHat.
18+
# "Standard" means with the Inky pHat connector at the top and ribbon on the right.
19+
1620
DNORegion: B
1721
# Permitted regions are:
1822
# A = East England

eco_indicator.py

+14
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,10 @@ def update_inky(conf: dict, inky_data: dict, demo: bool):
435435
draw.line((x_pos, average_line_ypos, x_pos + 2, average_line_ypos),
436436
inky_display.BLACK)
437437

438+
# Flip orientation if option is set
439+
if conf['DisplayOrientation'] == 'inverted':
440+
img=img.rotate(180)
441+
438442
inky_display.set_image(img)
439443
inky_display.show()
440444

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

536+
if _config['DisplayOrientation'] is None:
537+
_config['DisplayOrientation'] = 'standard'
538+
print('Standard display orientation.')
539+
elif _config['DisplayOrientation'] == 'standard':
540+
print('Standard display orientation.')
541+
elif _config['DisplayOrientation'] == 'inverted':
542+
print('Inverted display orientation.')
543+
else:
544+
raise SystemExit('Error: Unknown display orientation found in ' + filename + ': ' + _config['DisplayOrientation'])
545+
532546
conf_highprice = deep_get(_config, ['InkyPHAT', 'HighPrice'])
533547
if not (isinstance(conf_highprice, (int, float)) and 0 <= conf_highprice <= 35):
534548
print('Misconfigured high price value: ' + str(conf_highprice) +

0 commit comments

Comments
 (0)