Conversation
* Initial plan * Add Christmas countdown app with falling snowflakes Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> * Fix date calculation for leap years and year boundaries Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> * Reorder text layout and optimize performance Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> * Improve variable naming for clarity in next year calculation Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com>
…ice clock (#4) * Initial plan * Fix Christmas app to fetch date from internet instead of using local device time Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> * Address code review feedback: use HTTPS, proper resource cleanup, and clearer constant Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> * Fix cache timing, reduce timeout, add date parsing validation Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com>
* Initial plan * Add date display to Christmas app with network caching Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> * Fix bare except clause in date formatting Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com>
…app (#9) * Initial plan * Implement thinking state and network retry logic for Christmas app Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> * Fix code review comments: clarify return value and update comment Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> * Fix: prevent displaying 'thinking...' twice on screen Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com>
* Initial plan * Add network configuration to christmas app following badge app pattern Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> * Add explanatory comment for exception handling Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com>
* Initial plan * Replace worldtimeapi.org with NTP time sync Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> * Improve year validation for better future compatibility Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: atarukun <6511495+atarukun@users.noreply.github.com>
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
| # Main number (at top) | ||
| days_text = str(days) | ||
| w, h = screen.measure_text(days_text) | ||
| screen.text(days_text, 80 - (w // 2), 30) |
There was a problem hiding this comment.
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.
| import time | ||
| import random | ||
| import sys | ||
| from badgeware import screen, PixelFont, shapes, brushes, io, run, Matrix |
There was a problem hiding this comment.
The Matrix import is unused in the code. Consider removing it to keep imports clean.
| from badgeware import screen, PixelFont, shapes, brushes, io, run, Matrix | |
| from badgeware import screen, PixelFont, shapes, brushes, io, run |
| return False # Still waiting to retry | ||
|
|
||
| # Update last sync attempt timestamp | ||
| _last_sync_attempt = current_ticks |
There was a problem hiding this comment.
The global variable '_last_sync_attempt' is not used.
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.