milestones

This commit is contained in:
2026-07-28 00:17:26 +03:00
parent 4f5473e0e1
commit 8b8d30da27
+9 -7
View File
@@ -58,14 +58,14 @@ def draw_clock_digits(x, y, size ,hours, minutes, blink_second, color=(0, 255, 0
draw_digits(x, y, size, current_time, color) draw_digits(x, y, size, current_time, color)
def draw_digits(x, y, size, digits, color=(0, 255, 0)): def draw_digits(x, y, size, digits, color=(0, 255, 0), anchor='la'):
""" """
Draws clock digits at the specified position. Draws clock digits at the specified position.
""" """
font_path = "/usr/share/fonts/truetype/dseg/DSEG14Classic-BoldItalic.ttf" font_path = "/usr/share/fonts/truetype/dseg/DSEG14Classic-BoldItalic.ttf"
font = ImageFont.truetype(font_path, int(CLOCK_HEIGHT_PIXELS * size)) font = ImageFont.truetype(font_path, int(CLOCK_HEIGHT_PIXELS * size))
draw.text((x, y), digits, font=font, fill=color) draw.text((x, y), digits, font=font, fill=color, anchor=anchor)
def status_clock_position(order): def status_clock_position(order):
""" """
@@ -88,17 +88,17 @@ def draw_clock():
#draw_label('Time:', x - MARGIN_PIXELS, y + CLOCK_HEIGHT_PIXELS) #draw_label('Time:', x - MARGIN_PIXELS, y + CLOCK_HEIGHT_PIXELS)
def draw_death_clock(order): def milestone_countdown(order, target_date, label):
x, y = status_clock_position(order) x, y = status_clock_position(order)
right_x = x + CLOCK_WIDTH_PIXELS * STATUS_SIZE_MULTIPLIER
death_date = datetime.strptime("08/23/2026", "%m/%d/%Y").date()
today = datetime.today().date() today = datetime.today().date()
days_until_death = (death_date - today).days days_until = (target_date - today).days
color = (0, 255, 0) color = (0, 255, 0)
draw_digits(x, y, STATUS_SIZE_MULTIPLIER, f'{days_until_death:4}', color) draw_digits(right_x, y, STATUS_SIZE_MULTIPLIER, f'{days_until}', color, anchor='ra')
draw_label('death:', x - MARGIN_PIXELS, y + CLOCK_HEIGHT_PIXELS * STATUS_SIZE_MULTIPLIER) draw_label(label, x - MARGIN_PIXELS, y + CLOCK_HEIGHT_PIXELS * STATUS_SIZE_MULTIPLIER)
def draw_journal_minutes(status, order): def draw_journal_minutes(status, order):
x, y = status_clock_position(order) x, y = status_clock_position(order)
@@ -158,6 +158,8 @@ while True:
draw_journal_minutes(status, order=0) draw_journal_minutes(status, order=0)
draw_fasting(status, order=1) draw_fasting(status, order=1)
milestone_countdown(order=5, target_date=datetime.strptime("09/01/2026", "%m/%d/%Y").date(), label='below 108kg:')
milestone_countdown(order=4, target_date=datetime.strptime("12/25/2026", "%m/%d/%Y").date(), label='below 95kg:')
except RequestException as e: except RequestException as e:
logging.error(f'Error fetching status data: {e}') logging.error(f'Error fetching status data: {e}')