MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / normalize_rotation

Function normalize_rotation

shared.py:28–43  ·  view source on GitHub ↗

Normalize a screen_reversed config value to a rotation angle (0, 90, 180, 270). Accepts booleans (legacy: True→180, False→0), integers, or string representations.

(value)

Source from the content-addressed store, hash-verified

26
27
28def normalize_rotation(value):
29 """Normalize a screen_reversed config value to a rotation angle (0, 90, 180, 270).
30
31 Accepts booleans (legacy: True→180, False→0), integers, or string representations.
32 """
33 if isinstance(value, bool):
34 return 180 if value else 0
35 try:
36 angle = int(value)
37 if angle in (0, 90, 180, 270):
38 return angle
39 except (ValueError, TypeError):
40 pass
41 if str(value).lower() in ('true', '1'):
42 return 180
43 return 0
44from datetime import datetime
45
46_detected_wifi_interface = None

Callers 4

_show_epaper_transitionFunction · 0.90
update_configFunction · 0.90
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected