Skip to content
Draft
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This project is for developing applications on the GitHub Universe 2025 hackable

## Project Structure

**Default launcher structure:**

```
/
├── badge/ # Badge firmware and apps (deployed to /system/ on device)
Expand All @@ -24,6 +26,22 @@ This project is for developing applications on the GitHub Universe 2025 hackable
└── README.md
```

**With menu subfolder support enabled:**

```
badge/apps/
├── games/ # Folder without __init__.py; appears as a submenu
│ ├── flappy/ # App (has __init__.py, icon.png)
│ └── snake/
├── utilities/
│ ├── wifi/
│ └── weather/
├── menu/ # Launcher logic (hidden from menu list)
└── startup/ # Boot animation (hidden from menu list)
```

When this structure is active, the launcher treats any directory lacking an `__init__.py` as a navigable folder, pins a back entry at the first slot inside subfolders, and continues to hide the `menu` and `startup` apps from the user-facing list.

## Hardware Specifications

- **Processor**: RP2350 Dual-core ARM Cortex-M33 @ 200MHz
Expand Down
24 changes: 18 additions & 6 deletions badge/apps/badge/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import sys
import os

sys.path.insert(0, "/system/apps/badge")
os.chdir("/system/apps/badge")
if "/system" not in sys.path:
sys.path.insert(0, "/system")

try:
from badge_app_runtime import ensure_app_path
except ImportError:
from badge_app_runtime import prepare_app_path as ensure_app_path

APP_DIR = ensure_app_path(globals(), "/system/apps/badge")


from badgeware import io, brushes, shapes, Image, run, PixelFont, screen, Matrix, file_exists
Expand All @@ -11,7 +18,6 @@
import network
from urllib.urequest import urlopen
import gc
import sys
import json


Expand Down Expand Up @@ -51,21 +57,27 @@ def get_connection_details(user):
# `secrets.py` can be imported on the device. Clean up sys.path afterwards.
sys.path.insert(0, "/")
try:
from secrets import WIFI_PASSWORD, WIFI_SSID, GITHUB_USERNAME, GITHUB_TOKEN
secrets = __import__("secrets")
finally:
# ensure we remove the path we inserted even if import fails
try:
sys.path.pop(0)
except Exception:
pass
except ImportError as e:

WIFI_PASSWORD = getattr(secrets, "WIFI_PASSWORD", None)
WIFI_SSID = getattr(secrets, "WIFI_SSID", None)
GITHUB_USERNAME = getattr(secrets, "GITHUB_USERNAME", None)
# Allow the token to be omitted entirely – treat missing as None/empty string
GITHUB_TOKEN = getattr(secrets, "GITHUB_TOKEN", None)
except ImportError:
# If the user hasn't created a secrets.py file, fall back to None so
# the rest of the app can detect missing credentials and show helpful UI.
WIFI_PASSWORD = None
WIFI_SSID = None
GITHUB_USERNAME = None
GITHUB_TOKEN = None
except Exception as e:
except Exception:
WIFI_PASSWORD = None
WIFI_SSID = None
GITHUB_USERNAME = None
Expand Down
13 changes: 9 additions & 4 deletions badge/apps/copilot-loop/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import sys
import os

sys.path.insert(0, "/system/apps/copilot-loop")
os.chdir("/system/apps/copilot-loop")
if "/system" not in sys.path:
sys.path.insert(0, "/system")

from badgeware import Image, screen, run, io
try:
from badge_app_runtime import ensure_app_path
except ImportError:
from badge_app_runtime import prepare_app_path as ensure_app_path

APP_DIR = ensure_app_path(globals(), "/system/apps/copilot-loop")

from badgeware import io, run, screen, Image, PixelFont, SpriteSheet


frame_index = 1
Expand Down
16 changes: 11 additions & 5 deletions badge/apps/crypto/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import sys
import os
import sys

if "/system" not in sys.path:
sys.path.insert(0, "/system")

try:
from badge_app_runtime import ensure_app_path
except ImportError:
from badge_app_runtime import prepare_app_path as ensure_app_path

sys.path.insert(0, "/system/apps/crypto")
os.chdir("/system/apps/crypto")
APP_DIR = ensure_app_path(globals(), "/system/apps/crypto")

from badgeware import io, brushes, shapes, screen, PixelFont, run
import network
from badgeware import io, brushes, shapes, screen, PixelFont, Image, run
from urllib.urequest import urlopen
import json
import gc
Expand Down
12 changes: 9 additions & 3 deletions badge/apps/flappy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import sys
import os

sys.path.insert(0, "/system/apps/flappy")
os.chdir("/system/apps/flappy")
if "/system" not in sys.path:
sys.path.insert(0, "/system")

try:
from badge_app_runtime import ensure_app_path
except ImportError:
from badge_app_runtime import prepare_app_path as ensure_app_path

APP_DIR = ensure_app_path(globals(), "/system/apps/flappy")

from badgeware import screen, Image, PixelFont, SpriteSheet, io, brushes, shapes, run, State
from mona import Mona
Expand Down
11 changes: 9 additions & 2 deletions badge/apps/gallery/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import sys
import os

sys.path.insert(0, "/system/apps/gallery")
os.chdir("/system/apps/gallery")
if "/system" not in sys.path:
sys.path.insert(0, "/system")

try:
from badge_app_runtime import ensure_app_path
except ImportError:
from badge_app_runtime import prepare_app_path as ensure_app_path

APP_DIR = ensure_app_path(globals(), "/system/apps/gallery")

from badgeware import PixelFont, Image, screen, run, io, brushes, shapes

Expand Down
12 changes: 9 additions & 3 deletions badge/apps/invaders/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import sys
import os
import random

sys.path.insert(0, "/system/apps/invaders")
os.chdir("/system/apps/invaders")
if "/system" not in sys.path:
sys.path.insert(0, "/system")

try:
from badge_app_runtime import ensure_app_path
except ImportError:
from badge_app_runtime import prepare_app_path as ensure_app_path

APP_DIR = ensure_app_path(globals(), "/system/apps/invaders")

from badgeware import screen, PixelFont, io, brushes, shapes, run

Expand Down
Loading