Skip to content

Conversation

@atarukun
Copy link

The interesting thing in this app is that it shows more examples of how to configure your network, as well as how to use NTP to get a good date set as the device doesn't store date and constantly resets to 01 Jan 2021 on reboot.

Copilot AI and others added 6 commits October 29, 2025 18:04
* Initial plan

* Add Christmas countdown app with falling snowflakes

Co-authored-by: atarukun <[email protected]>

* Fix date calculation for leap years and year boundaries

Co-authored-by: atarukun <[email protected]>

* Reorder text layout and optimize performance

Co-authored-by: atarukun <[email protected]>

* Improve variable naming for clarity in next year calculation

Co-authored-by: atarukun <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: atarukun <[email protected]>
…ice clock (#4)

* Initial plan

* Fix Christmas app to fetch date from internet instead of using local device time

Co-authored-by: atarukun <[email protected]>

* Address code review feedback: use HTTPS, proper resource cleanup, and clearer constant

Co-authored-by: atarukun <[email protected]>

* Fix cache timing, reduce timeout, add date parsing validation

Co-authored-by: atarukun <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: atarukun <[email protected]>
* Initial plan

* Add date display to Christmas app with network caching

Co-authored-by: atarukun <[email protected]>

* Fix bare except clause in date formatting

Co-authored-by: atarukun <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: atarukun <[email protected]>
…app (#9)

* Initial plan

* Implement thinking state and network retry logic for Christmas app

Co-authored-by: atarukun <[email protected]>

* Fix code review comments: clarify return value and update comment

Co-authored-by: atarukun <[email protected]>

* Fix: prevent displaying 'thinking...' twice on screen

Co-authored-by: atarukun <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: atarukun <[email protected]>
* Initial plan

* Add network configuration to christmas app following badge app pattern

Co-authored-by: atarukun <[email protected]>

* Add explanatory comment for exception handling

Co-authored-by: atarukun <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: atarukun <[email protected]>
* Initial plan

* Replace worldtimeapi.org with NTP time sync

Co-authored-by: atarukun <[email protected]>

* Improve year validation for better future compatibility

Co-authored-by: atarukun <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: atarukun <[email protected]>
Copilot AI review requested due to automatic review settings October 30, 2025 19:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new Christmas countdown app to the badge that displays the number of days remaining until Christmas. The app features animated falling snowflakes as a visual backdrop and uses NTP to sync the system time over WiFi.

Key Changes:

  • Created a Christmas countdown app with animated snowflakes and date-based countdown functionality
  • Implemented NTP time synchronization with retry logic for reliable date retrieval
  • Added WiFi connection handling with SSID scanning and timeout mechanisms

Reviewed Changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 4 comments.

File Description
badge/apps/christmas/icon.png Added application icon for the Christmas countdown app
badge/apps/christmas/init.py Core application logic including snowflake animation, NTP sync, countdown calculation, and UI rendering

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


# Sanity check: if year is unreasonable, NTP didn't actually work
# Valid range: 2025-2100 (the badge was created in 2025)
if year < 2025 or year > 2100:
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded year range (2025-2100) uses a magic number for the upper bound. Consider using a constant like MAX_VALID_YEAR = 2100 to make this value more maintainable and its purpose clearer.

Copilot uses AI. Check for mistakes.
# Main number (at top)
days_text = str(days)
w, h = screen.measure_text(days_text)
screen.text(days_text, 80 - (w // 2), 30)
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The screen dimensions (80 for center X, various Y positions) are hardcoded throughout the code. Consider defining constants like SCREEN_CENTER_X = 80 and SCREEN_WIDTH = 160 to improve maintainability and make the code self-documenting.

Copilot uses AI. Check for mistakes.
import time
import random
import sys
from badgeware import screen, PixelFont, shapes, brushes, io, run, Matrix
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Matrix import is unused in the code. Consider removing it to keep imports clean.

Suggested change
from badgeware import screen, PixelFont, shapes, brushes, io, run, Matrix
from badgeware import screen, PixelFont, shapes, brushes, io, run

Copilot uses AI. Check for mistakes.
return False # Still waiting to retry

# Update last sync attempt timestamp
_last_sync_attempt = current_ticks
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The global variable '_last_sync_attempt' is not used.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant