Skip to content

adding some icons and metadata for fruitjam os #3064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Binary file added Metro/Metro_RP2350_Breakout/icon.bmp
Binary file not shown.
4 changes: 4 additions & 0 deletions Metro/Metro_RP2350_Breakout/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Breakout",
"icon": "icon.bmp"
}
Binary file added Metro/Metro_RP2350_Chips_Challenge/icon.bmp
Binary file not shown.
4 changes: 4 additions & 0 deletions Metro/Metro_RP2350_Chips_Challenge/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Chip'sChall",
"icon": "icon.bmp"
}
Binary file added Metro/Metro_RP2350_CircuitPython_Matrix/icon.bmp
Binary file not shown.
4 changes: 4 additions & 0 deletions Metro/Metro_RP2350_CircuitPython_Matrix/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Matrix",
"icon": "icon.bmp"
}
31 changes: 8 additions & 23 deletions Metro/Metro_RP2350_FlappyNyanCat/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
import random
import sys
import terminalio
from displayio import Group, TileGrid, Bitmap, release_displays, Palette
from displayio import Group, TileGrid, Bitmap, Palette
import supervisor
import bitmaptools
from adafruit_display_text.bitmap_label import Label
import picodvi
import framebufferio
import board
from micropython import const
import adafruit_imageload
from adafruit_fruitjam.peripherals import request_display_config
from adafruit_pathlib import Path

# how strong the gravity is
FALL_SPEED = 1
Expand All @@ -42,23 +41,8 @@
# current score
score = 0

# initialize display
release_displays()

fb = picodvi.Framebuffer(
320,
240,
clk_dp=board.CKP,
clk_dn=board.CKN,
red_dp=board.D0P,
red_dn=board.D0N,
green_dp=board.D1P,
green_dn=board.D1N,
blue_dp=board.D2P,
blue_dn=board.D2N,
color_depth=16,
)
display = framebufferio.FramebufferDisplay(fb)
request_display_config(320,240)
display = supervisor.runtime.display

# initialize groups to hold visual elements
main_group = Group()
Expand Down Expand Up @@ -607,10 +591,11 @@ def shift_post(post):

# if player pressed p
if "p" in cur_btn_val:
supervisor.set_next_code_file(__file__)
supervisor.set_next_code_file(__file__,
working_directory=Path(__file__).parent.absolute())
supervisor.reload()

# if player pressed q
elif "q" in cur_btn_val:
print("exiting")
break
supervisor.reload()
Binary file added Metro/Metro_RP2350_FlappyNyanCat/icon.bmp
Binary file not shown.
4 changes: 4 additions & 0 deletions Metro/Metro_RP2350_FlappyNyanCat/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "FlapyNyan🐱",
"icon": "icon.bmp"
}
Binary file added Metro/Metro_RP2350_Match3/match3_game/icon.bmp
Binary file not shown.
4 changes: 4 additions & 0 deletions Metro/Metro_RP2350_Match3/match3_game/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Match3",
"icon": "icon.bmp"
}
92 changes: 51 additions & 41 deletions Metro/Metro_RP2350_Memory/memory_game/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import array
import random
import time
import atexit
from displayio import Group, OnDiskBitmap, TileGrid
from adafruit_display_text.bitmap_label import Label
from adafruit_display_text.text_box import TextBox
Expand All @@ -18,6 +19,9 @@
import supervisor
import terminalio
import usb.core
from adafruit_fruitjam.peripherals import request_display_config
import adafruit_usb_host_descriptors
from adafruit_pathlib import Path


def random_selection(lst, count):
Expand All @@ -40,7 +44,7 @@ def update_score_text():
Update the score text on the display for each player
"""
for _ in range(2):
out_str = f"p{_+1} score: {player_scores[_]}"
out_str = f"p{_ + 1} score: {player_scores[_]}"
score_lbls[_].text = out_str


Expand All @@ -58,34 +62,8 @@ def update_score_text():
# initial state is title screen
CUR_STATE = STATE_TITLE

# pylint: disable=ungrouped-imports
if hasattr(supervisor.runtime, "display") and supervisor.runtime.display is not None:
# use the built-in HSTX display for Metro RP2350
display = supervisor.runtime.display
else:
# pylint: disable=ungrouped-imports
from displayio import release_displays
import picodvi
import board
import framebufferio

# initialize display
release_displays()

fb = picodvi.Framebuffer(
320,
240,
clk_dp=board.CKP,
clk_dn=board.CKN,
red_dp=board.D0P,
red_dn=board.D0N,
green_dp=board.D1P,
green_dn=board.D1N,
blue_dp=board.D2P,
blue_dn=board.D2N,
color_depth=16,
)
display = framebufferio.FramebufferDisplay(fb)
request_display_config(320, 240)
display = supervisor.runtime.display

# main group will hold all the visual elements
main_group = Group()
Expand Down Expand Up @@ -312,24 +290,55 @@ def update_score_text():
# wait a second for USB devices to be ready
time.sleep(1)

mouse_interface_index, mouse_endpoint_address = None, None
mouse = None

# scan for connected USB devices
for device in usb.core.find(find_all=True):
# print information about the found devices
print(f"{device.idVendor:04x}:{device.idProduct:04x}")
print(device.manufacturer, device.product)
print(device.serial_number)

# assume this device is the mouse
mouse = device
config_descriptor = adafruit_usb_host_descriptors.get_configuration_descriptor(
device, 0
)

# detach from kernel driver if active
_possible_interface_index, _possible_endpoint_address = (
adafruit_usb_host_descriptors.find_boot_mouse_endpoint(device))

if _possible_interface_index is not None and _possible_endpoint_address is not None:
mouse = device
mouse_interface_index = _possible_interface_index
mouse_endpoint_address = _possible_endpoint_address
print(f"mouse interface: {mouse_interface_index}", end="")
print(f"endpoint_address: {hex(mouse_endpoint_address)}")

mouse_was_attached = None
if mouse is not None:
# detach the kernel driver if needed
if mouse.is_kernel_driver_active(0):
mouse_was_attached = True
mouse.detach_kernel_driver(0)
else:
mouse_was_attached = False

# set the mouse configuration so it can be used
# set configuration on the mouse so we can use it
mouse.set_configuration()


def atexit_callback():
"""
re-attach USB devices to kernel if needed.
:return:
"""
print("inside atexit callback")
if mouse_was_attached and not mouse.is_kernel_driver_active(0):
mouse.attach_kernel_driver(0)


atexit.register(atexit_callback)

# Buffer to hold data read from the mouse
# Boot mice have 4 byte reports
buf = array.array("b", [0] * 4)
Expand All @@ -354,7 +363,7 @@ def update_score_text():
try:
# try to read data from the mouse, small timeout so the code will move on
# quickly if there is no data
data_len = mouse.read(0x81, buf, timeout=10)
data_len = mouse.read(mouse_endpoint_address, buf, timeout=20)

# if there was data, then update the mouse cursor on the display
# using min and max to keep it within the bounds of the display
Expand Down Expand Up @@ -391,8 +400,8 @@ def update_score_text():

# if both cards were the same i.e. they found a match
if (
card_tgs[cards_flipped_this_turn[0]][0]
== card_tgs[cards_flipped_this_turn[1]][0]
card_tgs[cards_flipped_this_turn[0]][0]
== card_tgs[cards_flipped_this_turn[1]][0]
):

# set the cards tile index to show a blank spot instead of a card
Expand All @@ -409,8 +418,8 @@ def update_score_text():
# of cards then the code knows the game is over because each pair is worth 1
# point
if (
player_scores[0] + player_scores[1]
>= (grid_size[0] * grid_size[1]) // 2
player_scores[0] + player_scores[1]
>= (grid_size[0] * grid_size[1]) // 2
):

# if the player's scores are equal
Expand Down Expand Up @@ -493,12 +502,13 @@ def update_score_text():
# button bounding box
if play_again_btn.contains(coords):
# set next code file to this one
supervisor.set_next_code_file(__file__)
supervisor.set_next_code_file(__file__,
working_directory=Path(__file__).parent.absolute())
# reload
supervisor.reload()

# if the mouse point is within the exit
# button bounding box
if exit_btn.contains(coords):
# break to exit out of this script
break
# restart back to code.py
supervisor.reload()
Binary file added Metro/Metro_RP2350_Memory/memory_game/icon.bmp
Binary file not shown.
4 changes: 4 additions & 0 deletions Metro/Metro_RP2350_Memory/memory_game/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Memory",
"icon": "icon.bmp"
}
30 changes: 5 additions & 25 deletions Metro/Metro_RP2350_Snake/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import sys
import time
from micropython import const
import board
import picodvi
import framebufferio
import supervisor
import displayio
import terminalio
from adafruit_display_text.text_box import TextBox
from adafruit_fruitjam.peripherals import request_display_config
from snake_helpers import World, Snake, GameOverException, SpeedAdjuster

# state machine constant
Expand All @@ -34,26 +32,8 @@
# variable for the players score
score = 0

# initialize display
displayio.release_displays()
fb = picodvi.Framebuffer(
320,
240,
clk_dp=board.CKP,
clk_dn=board.CKN,
red_dp=board.D0P,
red_dn=board.D0N,
green_dp=board.D1P,
green_dn=board.D1N,
blue_dp=board.D2P,
blue_dn=board.D2N,
color_depth=16,
)
display = framebufferio.FramebufferDisplay(fb)

# In future release the default HSTX display
# will get initialized by default by circuitpython
# display = supervisor.runtime.display
request_display_config(320,240)
display = supervisor.runtime.display

# load title splash screen bitmap
title_bmp = displayio.OnDiskBitmap("snake_splash.bmp")
Expand Down Expand Up @@ -263,5 +243,5 @@
supervisor.reload()
# if the q button is pressed for exit
if cur_btn_val in {"q", "Q"}:
# break out of main while True loop.
break
# reload to go back to code.py
supervisor.reload()
Binary file added Metro/Metro_RP2350_Snake/icon.bmp
Binary file not shown.
4 changes: 4 additions & 0 deletions Metro/Metro_RP2350_Snake/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "🐍 Snake 🐍",
"icon": "icon.bmp"
}