Skip to content

Commit

Permalink
python: update real compass experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
vpayno committed May 23, 2024
1 parent f1c378e commit 99b1e2b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions python/src/compass-real.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@


class Compass:
"""Attempts to mimic a real compass."""

DEGREES_N: int = 0
DEGREES_NE: int = 45
DEGREES_E: int = 90
Expand All @@ -20,6 +22,11 @@ def __init__(self) -> None:
print("If you don't see any output, please calibrate the compass.")

def run(self) -> None:
"""
1. Probe compass
2. Draw arrow
"""

# this call will make you play fill the screen/dots to calibrate
# the compas - when it's ready it will display a smily face
self.heading = compass.heading()
Expand Down Expand Up @@ -76,6 +83,8 @@ def run(self) -> None:
self.draw_arrows()

def draw_arrows(self) -> None:
"""Draws the "arrows" for the 4 bearings."""

display.clear()

self.north_arrow()
Expand All @@ -84,6 +93,8 @@ def draw_arrows(self) -> None:
self.east_arrow()

def north_arrow(self) -> None:
"""Draws the north "arrow" """

# 0,0 -> top-left corner
column: int = 0
row: int = 0
Expand Down Expand Up @@ -154,6 +165,8 @@ def north_arrow(self) -> None:
display.set_pixel(column - 2, row + 2, brightness - 6)

def south_arrow(self) -> None:
"""Draws the south "arrow" """

# 0,0 -> top-left corner
column: int = 0
row: int = 0
Expand Down Expand Up @@ -208,6 +221,8 @@ def south_arrow(self) -> None:
display.set_pixel(column, row, brightness)

def west_arrow(self) -> None:
"""Draws the west "arrow" """

# 0,0 -> top-left corner
column: int = 0
row: int = 0
Expand Down Expand Up @@ -262,6 +277,8 @@ def west_arrow(self) -> None:
display.set_pixel(column, row, brightness)

def east_arrow(self) -> None:
"""Draws the east "arrow" """

# 0,0 -> top-left corner
column: int = 0
row: int = 0
Expand Down

0 comments on commit 99b1e2b

Please sign in to comment.