Skip to content

Commit

Permalink
Fix comments to be compatible with mkdocstring #34
Browse files Browse the repository at this point in the history
  • Loading branch information
christopolise committed Aug 24, 2023
1 parent da6c94b commit 1ae6fb0
Showing 1 changed file with 55 additions and 40 deletions.
95 changes: 55 additions & 40 deletions display/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ class Display:
def __init__(self, board_objects, x_width, y_height):
"""Constructor
board_objects -- 2d array of seven segment objects oriented how the sign is put together, i.e. [[panel0, panel1],[panel2,panel3]]
x_width -- number of digits in the display on the x axis
y_height -- number of pixels on the y axis (each vertical digit is split into two pixels)
Args:
board_objects (int[][]): 2d array of seven segment objects oriented how the sign is put together, i.e. [[panel0, panel1],[panel2,panel3]]
x_width (int): number of digits in the display on the x axis
y_height (int): number of pixels on the y axis (each vertical digit is split into two pixels)
"""
self.board_objects = board_objects
self.x_width = int(x_width)
Expand All @@ -22,10 +23,11 @@ def __init__(self, board_objects, x_width, y_height):
def draw_raw(self, x, y, value, push=False):
"""Draw to a specific segment on the screen
x -- x coordinate
y -- y coordinate
value -- which leds to turn on for the segment
push -- when true all the recent changes are pushed to the display
Args:
x (int): x coordinate
y (int): y coordinate
value (int): which leds to turn on for the segment
push (bool): when true all the recent changes are pushed to the display
"""
self.display_buf[y][x] = value
self.changed_list.append((x, y))
Expand All @@ -35,19 +37,24 @@ def draw_raw(self, x, y, value, push=False):
def get_raw(self, x, y):
"""Get the value of the segment
x -- x coordinate
y -- y coordinate
Args:
x (int): x coordinate
y (int): y coordinate
Returns:
(int): value of the segment
"""
return self.display_buf[y][x]

def draw_pixel(self, x, y, value, combine=True, push=False):
"""Draw shape to one pixel location
x -- x coordinate
y -- y coordinate
value -- which leds to turn on for the pixel (1 for bottom, 2 for left, 4 for top, 8 for right, add sides together for multiple sides)
combine -- digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit
push -- when true all the recent changes are pushed to the display
Args:
x (int): x coordinate
y (int): y coordinate
value (int): which leds to turn on for the pixel (1 for bottom, 2 for left, 4 for top, 8 for right, add sides together for multiple sides)
combine (bool): digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit
push (bool): when true all the recent changes are pushed to the display
"""
half_height = y // 2
if value == 0 and combine:
Expand Down Expand Up @@ -86,8 +93,12 @@ def draw_pixel(self, x, y, value, combine=True, push=False):
def get_pixel(self, x, y):
"""Get the value already at the pixel
x -- x coordinate
y -- y coordinate
Args:
x (int): x coordinate
y (int): y coordinate
Returns:
(int): value of the pixel
"""
half_height = y // 2
value = self.display_buf[half_height][x]
Expand Down Expand Up @@ -135,12 +146,13 @@ def clear(self):
def draw_hline(self, start_x, start_y, length, top=True, combine=True, push=False):
"""Draw horizontal line
start_x -- x coordinate
start_y -- y coordinate
length -- length of line to draw
top -- draw horizontal line on the top or bottom of the pixel
combine -- digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit
push -- when true all the recent changes are pushed to the display
Args:
start_x (int): x coordinate
start_y (int): y coordinate
length (int): length of line to draw
top (int): draw horizontal line on the top or bottom of the pixel
combine (int): digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit
push (int): when true all the recent changes are pushed to the display
"""
half_height = start_y // 2
if start_y % 2:
Expand Down Expand Up @@ -183,12 +195,13 @@ def draw_hline(self, start_x, start_y, length, top=True, combine=True, push=Fals
def draw_vline(self, start_x, start_y, length, left=True, combine=True, push=False):
"""Draw vertical line
start_x -- x coordinate
start_y -- y coordinate
length -- length of line to draw
left -- draw vertial line on the left or right of the pixel
combine -- digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit
push -- when true all the recent changes are pushed to the display
Args:
start_x (int): x coordinate
start_y (int): y coordinate
length (int): length of line to draw
left (int): draw vertial line on the left or right of the pixel
combine (bool): digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit
push (bool): when true all the recent changes are pushed to the display
"""
for y in range(length):
y_loc = start_y + y
Expand Down Expand Up @@ -232,13 +245,14 @@ def draw_shape_line(
):
"""Draw line with given value at each pixel, can be diagonal
start_x -- starting x coordinate
start_y -- starting y coordinate
end_x -- ending x coordinate
end_y -- ending y coordiante
value -- which leds to turn on for the pixel (1 for bottom, 2 for left, 4 for top, 8 for right, add sides together for multiple sides)
combine -- digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit
push -- when true all the recent changes are pushed to the display
Args:
start_x (int): starting x coordinate
start_y (int): starting y coordinate
end_x (int): ending x coordinate
end_y (int): ending y coordiante
value (int): which leds to turn on for the pixel (1 for bottom, 2 for left, 4 for top, 8 for right, add sides together for multiple sides)
combine (bool): digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit
push (bool): when true all the recent changes are pushed to the display
"""
if start_x != end_x:
slope = (end_y - start_y) / (end_x - start_x)
Expand All @@ -254,11 +268,12 @@ def draw_shape_line(
def draw_text(self, x, y, msg, combine=True, push=False):
"""Print a message to the screen, y_height-2 is lowest y value accepted without error
x -- x coordinate
y -- y coordinate
msg -- string message to print
combine -- digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit
push -- when true all the recent changes are pushed to the display
Args:
x (int): x coordinate
y (int): y coordinate
msg (int): string message to print
combine (bool): digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit
push (bool): when true all the recent changes are pushed to the display
"""
if y % 2:
for pos, char in enumerate(msg):
Expand Down

0 comments on commit 1ae6fb0

Please sign in to comment.