diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 56afce79f..a9fc47259 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -86,7 +86,7 @@ jobs: run: | cd lib fail=0 - for example in pydevices_demo palettes_demo; do + for example in pydevices_demo; do echo "== $example ==" rc=0 PYTHONPATH=.:lib:utils timeout 10 ../.venv/bin/python "examples/${example}.py" || rc=$? diff --git a/.site/gallery/index.html b/.site/gallery/index.html index 431c56016..9ba0d584a 100644 --- a/.site/gallery/index.html +++ b/.site/gallery/index.html @@ -173,16 +173,6 @@

Appdev Encoder Test

Appdev Touch Coords

Guided touch capture via appdev (no LVGL). Prints coords on MOUSEBUTTONUP.

- -
- - - pygraphics - -
-

Appdev Touch Test

-

appdev_touch_test.py - Touch rotation test.

-
@@ -366,16 +356,6 @@

Feathers

Fonts

Test text_font_converter.py

- -
- - - pygraphics - -
-

Framebuf Simpletest

-

Simple test example to demonstrate pygraphics.FrameBuffer.

-
@@ -386,17 +366,6 @@

Framebuf Simpletest

Google Photos

Pick Google Photos on your phone; the board lists, views, and slideshows them.

- -
- - - palettes - pygraphics - -
-

Graphics Simpletest

-

Simple test example to demonstrate the use of pygraphics.

-
@@ -409,16 +378,6 @@

Graphics Simpletest

Hello

Test for text_font_converter.

- -
- - - pdwidgets - -
-

Joystick List Select

-

The joystick_list_select demo running in the browser via PyScript.

-
@@ -536,27 +495,6 @@

Noto Fonts

Paint

A simple paint application demonstrating the use of displaydev.

- -
- - - palettes - pygraphics - -
-

Palettes Demo

-

palettes_demo.py — Palette walk cycling wheel → cube → material (no env vars).

-
- -
- - - pygraphics - -
-

Pbm Create New

-

The pbm_create_new demo running in the browser via PyScript.

-
@@ -581,16 +519,6 @@

Pixel Sim Demos

Proverbs

Test for TrueType write_font_converter.

- -
- - - pygraphics - -
-

Pygraphics Landscape

-

A landscape drawn with pygraphics: a banded sky, a sun, two snow-capped

-
@@ -603,17 +531,6 @@

Pygraphics Landscape

Roku Remote

Launcher for the Roku remote stack.

- -
- - - palettes - pygraphics - -
-

Rotations

-

Rotates the display 0, 90, 180, and 270 degrees and displays the rotation

-
diff --git a/.site/gallery/python-files.json b/.site/gallery/python-files.json index d5817faeb..e92a681d9 100644 --- a/.site/gallery/python-files.json +++ b/.site/gallery/python-files.json @@ -5,7 +5,6 @@ "analog_clock_lvgl.py", "appdev_encoder_test.py", "appdev_touch_coords.py", - "appdev_touch_test.py", "audio_arpeggio.py", "audiolive_rack.py", "bouncing_balls.py", @@ -35,7 +34,6 @@ "drum_machine/drum_machine.py", "feathers.py", "fonts.py", - "framebuf_simpletest.py", "google_photos/__init__.py", "google_photos/__main__.py", "google_photos/assets/gen_sim_assets.py", @@ -43,9 +41,7 @@ "google_photos/gphotos_engine.py", "google_photos/gphotos_lvgl.py", "google_photos/gphotos_sim.py", - "graphics_simpletest.py", "hello.py", - "joystick_list_select.py", "logo.py", "lv_dynamic_fonts.py", "lv_gestures.py", @@ -61,8 +57,6 @@ "noto_fonts/__init__.py", "noto_fonts/noto_fonts.py", "paint.py", - "palettes_demo.py", - "pbm_create_new.py", "piano.py", "pixel_sim_demos.py", "proverbs/__init__.py", @@ -70,7 +64,6 @@ "proverbs/proverbs_20.py", "proverbs/proverbs_30.py", "pydevices_demo.py", - "pygraphics_landscape.py", "roku_remote/__init__.py", "roku_remote/__main__.py", "roku_remote/roku_engine.py", @@ -79,7 +72,6 @@ "roku_remote/roku_remote.py", "roku_remote/roku_sim.py", "roku_remote/roku_widgets.py", - "rotations.py", "scroll.py", "scroll_touch_test.py", "simon.py", diff --git a/.site/pyscript/index.html b/.site/pyscript/index.html index 240ffeb90..158532c51 100644 --- a/.site/pyscript/index.html +++ b/.site/pyscript/index.html @@ -173,16 +173,6 @@

Appdev Encoder Test

Appdev Touch Coords

Guided touch capture via appdev (no LVGL). Prints coords on MOUSEBUTTONUP.

- -
- - - pygraphics - -
-

Appdev Touch Test

-

appdev_touch_test.py - Touch rotation test.

-
@@ -366,16 +356,6 @@

Feathers

Fonts

Test text_font_converter.py

- -
- - - pygraphics - -
-

Framebuf Simpletest

-

Simple test example to demonstrate pygraphics.FrameBuffer.

-
@@ -386,17 +366,6 @@

Framebuf Simpletest

Google Photos

Pick Google Photos on your phone; the board lists, views, and slideshows them.

- -
- - - palettes - pygraphics - -
-

Graphics Simpletest

-

Simple test example to demonstrate the use of pygraphics.

-
@@ -409,16 +378,6 @@

Graphics Simpletest

Hello

Test for text_font_converter.

- -
- - - pdwidgets - -
-

Joystick List Select

-

The joystick_list_select demo running in the browser via PyScript.

-
@@ -536,27 +495,6 @@

Noto Fonts

Paint

A simple paint application demonstrating the use of displaydev.

- -
- - - palettes - pygraphics - -
-

Palettes Demo

-

palettes_demo.py — Palette walk cycling wheel → cube → material (no env vars).

-
- -
- - - pygraphics - -
-

Pbm Create New

-

The pbm_create_new demo running in the browser via PyScript.

-
@@ -581,16 +519,6 @@

Pixel Sim Demos

Proverbs

Test for TrueType write_font_converter.

- -
- - - pygraphics - -
-

Pygraphics Landscape

-

A landscape drawn with pygraphics: a banded sky, a sun, two snow-capped

-
@@ -603,17 +531,6 @@

Pygraphics Landscape

Roku Remote

Launcher for the Roku remote stack.

- -
- - - palettes - pygraphics - -
-

Rotations

-

Rotates the display 0, 90, 180, and 270 degrees and displays the rotation

-
diff --git a/docs/reference/screenshots.md b/docs/reference/screenshots.md index 71e1cdadd..ed9404b25 100644 --- a/docs/reference/screenshots.md +++ b/docs/reference/screenshots.md @@ -4,9 +4,8 @@ What the examples draw, captured from a desktop run, a phone or an installed PWA | Image | Image | Image | |-------|-------|-------| -| ![bmp565_simpletest.png](../screenshots/bmp565_simpletest.png) | ![bmp565_sprite.gif](../screenshots/bmp565_sprite.gif) | ![chango.png](../screenshots/chango.png) | -| ![color_test.png](../screenshots/color_test.png) | ![console_advanced_demo.gif](../screenshots/console_advanced_demo.gif) | ![displaybuf_simpletest.png](../screenshots/displaybuf_simpletest.png) | -| ![fonts.png](../screenshots/fonts.png) | ![framebuf_simpletest.png](../screenshots/framebuf_simpletest.png) | ![noto_fonts.png](../screenshots/noto_fonts.png) | +| ![chango.png](../screenshots/chango.png) | ![color_test.png](../screenshots/color_test.png) | ![console_advanced_demo.gif](../screenshots/console_advanced_demo.gif) | +| ![displaybuf_simpletest.png](../screenshots/displaybuf_simpletest.png) | ![fonts.png](../screenshots/fonts.png) | ![noto_fonts.png](../screenshots/noto_fonts.png) | | ![paint.png](../screenshots/paint.png) | ![proverbs.png](../screenshots/proverbs.png) | ![testris.png](../screenshots/testris.png) | | ![tiny_toasters.gif](../screenshots/tiny_toasters.gif) | ![piano.png](../screenshots/piano.png) | ![google_photos.png](../screenshots/google_photos.png) | | ![google_photos_view.png](../screenshots/google_photos_view.png) | ![google_photos_connect.png](../screenshots/google_photos_connect.png) | ![spectrum_800x480.gif](../screenshots/spectrum_800x480.gif) | diff --git a/docs/screenshots/bmp565_simpletest.png b/docs/screenshots/bmp565_simpletest.png deleted file mode 100644 index 0dc47e7ab..000000000 Binary files a/docs/screenshots/bmp565_simpletest.png and /dev/null differ diff --git a/docs/screenshots/bmp565_sprite.gif b/docs/screenshots/bmp565_sprite.gif deleted file mode 100644 index 9fbab2080..000000000 Binary files a/docs/screenshots/bmp565_sprite.gif and /dev/null differ diff --git a/docs/screenshots/framebuf_simpletest.png b/docs/screenshots/framebuf_simpletest.png deleted file mode 100644 index 0c1c39c62..000000000 Binary files a/docs/screenshots/framebuf_simpletest.png and /dev/null differ diff --git a/lib/examples/appdev_touch_test.py b/lib/examples/appdev_touch_test.py deleted file mode 100644 index 4eb490b8d..000000000 --- a/lib/examples/appdev_touch_test.py +++ /dev/null @@ -1,171 +0,0 @@ -# deps: pygraphics -""" -appdev_touch_test.py - Touch rotation test. -Tests the touch driver and finds the correct rotation masks for the touch screen. -Sets the rotation to each of 4 possible values and asks the user to touch the rectangle in each of the 4 corners. -Then it prints the touch_rotation_table that should be set in board_config.py. -""" - -from board_config import display_drv -import board_config -import appdev - -app = appdev.App(board_config) -import appdev -from pygraphics import round_rect, text16 - -demo = False - -FG_COLOR = -1 # white -BG_COLOR = 0 # black - -text = "Touch here" -text_width = len(text) * 8 - -SWAP_XY = 0b001 -REVERSE_X = 0b010 -REVERSE_Y = 0b100 - -_ZONE_MASKS = { - (0, 1, 2, 3): 0b0, - (1, 0, 3, 2): REVERSE_X, - (2, 3, 0, 1): REVERSE_Y, - (3, 2, 1, 0): REVERSE_X | REVERSE_Y, - (0, 2, 1, 3): SWAP_XY, - (2, 0, 3, 1): SWAP_XY | REVERSE_X, - (1, 3, 0, 2): SWAP_XY | REVERSE_Y, - (3, 1, 2, 0): SWAP_XY | REVERSE_X | REVERSE_Y, -} - - -def set_rotation_table(table): - if display_drv.touch_device is not None: - if display_drv.touch_device.type == appdev.POINTER: - display_drv.touch_device.rotation_table = table - - -def _draw_target(x, y, half_width, half_height): - round_rect( - display_drv, - x * half_width + 10, - y * half_height + 10, - half_width - 20, - half_height - 20, - 10, - FG_COLOR, - True, - ) - text16( - display_drv, - text, - x * half_width + ((half_width - text_width) // 2), - y * half_height + ((half_height - 8) // 2), - BG_COLOR, - ) - - -def _clear_target(x, y, half_width, half_height): - display_drv.fill_rect( - x * half_width, - y * half_height, - half_width - 1, - half_height - 1, - BG_COLOR, - ) - - -def _report(touch_rotation_table): - if not demo: - set_rotation_table(touch_rotation_table) - print("Set the `touch_rotation_table` in board_config.py to the following:") - else: - print("Demo complete.") - out_text = f"touch_rotation_table = {tuple(touch_rotation_table)}" - print(" ", out_text, "\n") - text16( - display_drv, - out_text, - (display_drv.width - len(out_text) * 8) // 2, - (display_drv.height - 8) // 2, - FG_COLOR, - ) - - -# Callback-driven state machine (one path for sync and async). -_st = { - "rotation": 0, - "x": 0, - "y": 0, - "touched_zones": [], - "touch_rotation_table": [], - "half_width": 0, - "half_height": 0, - "done": False, -} - - -def _show_current_target(): - _draw_target(_st["x"], _st["y"], _st["half_width"], _st["half_height"]) - - -def _advance_or_finish(): - _st["x"] += 1 - if _st["x"] > 1: - _st["x"] = 0 - _st["y"] += 1 - if _st["y"] > 1: - # finished one rotation - mask = _ZONE_MASKS.get(tuple(_st["touched_zones"])) - if mask is None: - print("Invalid touch sequence. Starting over...\n") - _start_over() - return - _st["touch_rotation_table"].append(mask) - print(f"rotation={_st['rotation']} {mask=} ({mask:#05b})\n") - _st["rotation"] += 90 - if _st["rotation"] >= 360: - _report(_st["touch_rotation_table"]) - _st["done"] = True - return - _st["touched_zones"] = [] - _st["x"] = 0 - _st["y"] = 0 - display_drv.rotation = _st["rotation"] - _st["half_width"] = display_drv.width // 2 - _st["half_height"] = display_drv.height // 2 - display_drv.fill_rect(0, 0, display_drv.width - 1, display_drv.height - 1, BG_COLOR) - _show_current_target() - - -def _start_over(): - _st["rotation"] = 0 - _st["x"] = 0 - _st["y"] = 0 - _st["touched_zones"] = [] - _st["touch_rotation_table"] = [] - display_drv.rotation = 0 - _st["half_width"] = display_drv.width // 2 - _st["half_height"] = display_drv.height // 2 - display_drv.fill_rect(0, 0, display_drv.width - 1, display_drv.height - 1, BG_COLOR) - print("Touch the rectangle in each corner for 4 rotations.\n") - _show_current_target() - - -def _on_click(e): - if _st["done"] or e.button != 1: - return - touched_point = e.pos - zone = (touched_point[1] // _st["half_height"]) * 2 + ( - touched_point[0] // _st["half_width"] - ) - _st["touched_zones"].append(zone) - print(f"{touched_point=} in {zone=}") - _clear_target(_st["x"], _st["y"], _st["half_width"], _st["half_height"]) - _advance_or_finish() - - -if not demo: - set_rotation_table((0, 0, 0, 0)) - -_start_over() -app.on(app.events.MOUSEBUTTONDOWN, _on_click) \ No newline at end of file diff --git a/lib/examples/assets/longstreet.bmp b/lib/examples/assets/longstreet.bmp deleted file mode 100644 index 92dea1ea1..000000000 Binary files a/lib/examples/assets/longstreet.bmp and /dev/null differ diff --git a/lib/examples/assets/micropython.pbm b/lib/examples/assets/micropython.pbm deleted file mode 100644 index 2bb093c6d..000000000 Binary files a/lib/examples/assets/micropython.pbm and /dev/null differ diff --git a/lib/examples/assets/runner.bmp b/lib/examples/assets/runner.bmp deleted file mode 100644 index 59e9ad72e..000000000 Binary files a/lib/examples/assets/runner.bmp and /dev/null differ diff --git a/lib/examples/bmp565_scroll.py b/lib/examples/bmp565_scroll.py deleted file mode 100644 index 3e42d65e6..000000000 --- a/lib/examples/bmp565_scroll.py +++ /dev/null @@ -1,49 +0,0 @@ -# deps: pygraphics -# gallery: binaries -from board_config import display_drv -import board_config -import appdev - -app = appdev.App(board_config) -from pygraphics import BMP565 - -display_drv.rotation = 0 - -image = BMP565("examples/assets/longstreet.bmp", streamed=True) -print(f"\n{image.width=}, {image.height=}, {image.bpp=}") - - -def draw_bg(dest_x, dest_y, source_x, source_y, source_image=image, width=image.width, height=1): - display_drv.blit_rect( - source_image[source_x : source_x + width, source_y : source_y + height], - dest_x, - dest_y, - width, - height, - ) - - -def main(): - st = {"phase": "fill", "j": 0, "i": display_drv.height} - - def _tick(_=None): - if app.quit_requested: - return - if st["phase"] == "fill": - j = st["j"] - if j < display_drv.height: - draw_bg(0, j, 0, j, height=1) - st["j"] = j + 1 - if st["j"] >= display_drv.height: - st["phase"] = "scroll" - return - # scroll phase - i = st["i"] - display_drv.vscsad(i % display_drv.height) - draw_bg(0, i % display_drv.height, 0, i % image.height) - st["i"] = i + 1 - - app.every(_tick, period=1) - - -main() \ No newline at end of file diff --git a/lib/examples/bmp565_scroll_sprite.py b/lib/examples/bmp565_scroll_sprite.py deleted file mode 100644 index 7fbc00523..000000000 --- a/lib/examples/bmp565_scroll_sprite.py +++ /dev/null @@ -1,124 +0,0 @@ -# deps: pygraphics -# gallery: binaries -from collections import namedtuple - -from board_config import display_drv -import board_config -import appdev - -app = appdev.App(board_config) -from pygraphics import BMP565 - -point = namedtuple("point", "x y") - -display_drv.rotation = 90 - -display_drv.fill(0) - -image = BMP565("examples/assets/longstreet.bmp", streamed=True, mirrored=True) -print(f"\n{image.width=}, {image.height=}, {image.bpp=}") - - -def draw_bg(dest_x, source_y, count=1, source=image): - # 1D row slice is ``count * source.width`` pixels; blit as a vertical - # strip (width=count, height=source.width). Do not use display_drv.height — - # tall panels (e.g. Android after rotation) are larger than the bitmap. - display_drv.blit_rect( - source[source_y : source_y + count], dest_x, 0, count, source.width - ) - - -char_sprites = BMP565("examples/assets/runner.bmp", streamed=True) -print(f"\n{char_sprites.width=}, {char_sprites.height=}, {char_sprites.bpp=}") -char_height = char_sprites.height // 3 -char_width = char_sprites.width // 6 -bg = char_sprites[0] -print(f"{char_width=}, {char_height=} {bg=:#0x}\n") - -run_sprites = [point(x * char_width, 0) for x in range(6)] -shoot_sprites = [point(x * char_width, char_height) for x in range(6)] -jump_sprites = [point(x * char_width, char_height * 2) for x in range(2)] -jump_shoot_sprites = [point((x + 2) * char_width, char_height * 2) for x in range(2)] -shot_sprite = point(4 * char_width, char_height * 2) - - -def draw_sprite( - dest_x, dest_y, source_x, source_y, source=char_sprites, width=char_width, height=char_height -): - display_drv.blit_rect( - source[source_x : source_x + width, source_y : source_y + height], - dest_x, - dest_y, - width, - height, - ) - - -def main(): - st = { - "i": 0, - "scroll": 0, - "char_y": display_drv.height - char_height, - "char_x": 200, - "shot_location": 0, - "sprites": run_sprites, - } - - def _on_motion(event): - if not event.buttons[0]: - st["sprites"] = run_sprites - return - touched_point = event.pos - if touched_point[1] < display_drv.height // 2: - st["sprites"] = jump_shoot_sprites - if not st["shot_location"]: - st["shot_location"] = 1 - elif touched_point[0] < display_drv.width // 2: - st["sprites"] = jump_sprites - elif touched_point[0] > display_drv.width // 2: - st["sprites"] = shoot_sprites - if not st["shot_location"]: - st["shot_location"] = 1 - else: - st["sprites"] = run_sprites - - def _tick(_=None): - # Auto-service handles QUIT; never poll from on_tick. - if app.quit_requested: - return - i = st["i"] - if i > display_drv.width: - st["scroll"] = i % display_drv.width - display_drv.vscsad(st["scroll"]) - draw_bg(i % display_drv.width, i % image.height, 1) - st["i"] = i + 1 - if i < display_drv.width: - return - - draw_x = st["scroll"] + st["char_x"] - sprite = st["sprites"][st["i"] % len(st["sprites"])] - draw_sprite(draw_x, st["char_y"], sprite.x, sprite.y) - if st["shot_location"]: - draw_sprite( - draw_x + char_width + st["shot_location"], - st["char_y"], - shot_sprite.x, - shot_sprite.y, - ) - st["shot_location"] += 8 - if st["shot_location"] > (display_drv.width - char_width) // 2: - display_drv.fill_rect( - draw_x + char_width + st["shot_location"], - st["char_y"], - char_width, - char_height, - bg, - ) - st["shot_location"] = 0 - - app.on(app.events.MOUSEMOTION, _on_motion) - # ~20 fps once scrolling; first columns also tick so quit is always serviced. - app.every(_tick, period=50) - - -main() \ No newline at end of file diff --git a/lib/examples/bmp565_simpletest.py b/lib/examples/bmp565_simpletest.py deleted file mode 100644 index ce280a8ff..000000000 --- a/lib/examples/bmp565_simpletest.py +++ /dev/null @@ -1,42 +0,0 @@ -# deps: pygraphics -# gallery: binaries -# Loads the full bitmap into memory before blitting it to the display. -# Will raise a MemoryError on low memory boards such as RP2040. -# See bmp565_scroll_sprite.py for an example of streaming one line at -# a time instead of the full bitmap. -# -# Shows both blit styles: a full-window slice, then ``bmp[:]`` with a -# short pause between (same patterns formerly in bmp565_blit.py). -from board_config import display_drv -from pygraphics import BMP565, hline - -try: - from time import sleep_ms -except ImportError: - from time import sleep - - def sleep_ms(milliseconds): - sleep(milliseconds / 1000) - - -try: - bmp = BMP565("examples/assets/warrior.bmp") -except MemoryError: - raise MemoryError("this board doesn't have enough RAM to load the full image") - -print(f"{bmp.width=}, {bmp.height=}, {bmp.bpp=}") - -display_drv.fill(0x0) -display_drv.show() -display_drv.blit_rect(bmp[0 : bmp.width, 0 : bmp.height], 0, 0, bmp.width, bmp.height) -display_drv.show() -sleep_ms(1000) - -display_drv.fill(0x0) -display_drv.show() -sleep_ms(250) - -hline(bmp, 0, bmp.height // 2, bmp.width, 0xFFFF) -display_drv.blit_rect(bmp[:], 0, 0, bmp.width, bmp.height) -display_drv.show() -sleep_ms(1000) diff --git a/lib/examples/bmp565_sprite.py b/lib/examples/bmp565_sprite.py deleted file mode 100644 index 3f8adfa02..000000000 --- a/lib/examples/bmp565_sprite.py +++ /dev/null @@ -1,106 +0,0 @@ -# deps: pygraphics -# gallery: binaries -from collections import namedtuple - -try: - from random import choice -except ImportError: - - def choice(seq): - return seq[0] - - -from board_config import display_drv -import board_config -import appdev - -app = appdev.App(board_config) -from pygraphics import BMP565 - -image = BMP565("examples/assets/warrior.bmp", streamed=True) -print(f"\n{image.width=}, {image.height=}, {image.bpp=}") -sprite_height = image.height // 4 -sprite_width = image.width // 3 -bg = image[0] -print(f"{sprite_width=}, {sprite_height=} {bg=:#0x}\n") - -back, right, fwd, left = [x * sprite_height for x in range(4)] -directions = [fwd, left, right, back] -a, b, c = [x * sprite_width for x in range(3)] -positions = [a, b, c, b] -print("Sprite coordinates:") -for col in [fwd, left, right, back]: - print(f"{(a, col)} {(b, col)} {(c, col)} {(b, col)}") - - -def draw_sprite( - dest_x, - dest_y, - source_x, - source_y, - source_image=image, - width=sprite_width, - height=sprite_height, -): - display_drv.blit_rect( - source_image[source_x : source_x + width, source_y : source_y + height], - dest_x, - dest_y, - width, - height, - ) - - -display_drv.fill(bg) - -point = namedtuple("point", "x y") -step = 3 -st = { - "location": point(0, 0), - "dir": choice(directions), - "pos_i": 0, -} - -draw_sprite(*st["location"], a, fwd) - - -def _tick(_=None): - if app.quit_requested if app else False: - return - location = st["location"] - direction = st["dir"] - if st["pos_i"] == 0 and choice((True, False, False, False, False)): - direction = choice(directions) - st["dir"] = direction - if direction == fwd and location.y + sprite_height > display_drv.height - step * 4: - return - if direction == back and location.y < step * 4: - return - if direction == left and location.x < step * 4: - return - if direction == right and location.x + sprite_width > display_drv.width - step * 4: - return - - pos = positions[st["pos_i"]] - if direction == fwd: - display_drv.fill_rect(location.x, location.y, sprite_width, step, bg) - location = point(location.x, location.y + step) - elif direction == back: - display_drv.fill_rect( - location.x, location.y + sprite_height - step, sprite_width, step, bg - ) - location = point(location.x, location.y - step) - elif direction == left: - display_drv.fill_rect( - location.x + sprite_width - step, location.y, step, sprite_height, bg - ) - location = point(location.x - step, location.y) - elif direction == right: - display_drv.fill_rect(location.x, location.y, step, sprite_height, bg) - location = point(location.x + step, location.y) - st["location"] = location - draw_sprite(*location, pos, direction) - st["pos_i"] = (st["pos_i"] + 1) % len(positions) - - -app.every(_tick, period=100) \ No newline at end of file diff --git a/lib/examples/font_list.py b/lib/examples/font_list.py deleted file mode 100644 index 102fd2633..000000000 --- a/lib/examples/font_list.py +++ /dev/null @@ -1,70 +0,0 @@ -# gallery: binaries -# deps: pygraphics -# SPDX-FileCopyrightText: 2024 Brad Barnett -# -# SPDX-License-Identifier: MIT -""" -This script gathers font files from a specified directory and displays them on a display driver. -It uses the Font class to load and render the fonts. -The font files should have a naming convention of "fontname_WxH.bin", where W is the width and H is the height of the font. -The script iterates through the font files, creates a framebuffer, and renders the font on it. -The rendered font is then displayed on the display driver. -""" - -from board_config import display_drv -from pygraphics import Font, FrameBuffer, RGB565 -import os - - -EXPORT = False # Set to True to export the font to a .py file - -display_drv.fill(0) -y_pos = 0 - - -def main(): - global y_pos - - # Specify the directory containing the .bin files - directory = "examples/assets/" - - def gather_font_files(directory): - font_files = [] - for file in os.listdir(directory): - if file.endswith(".bin"): - file_path = "/".join([directory, file]) - font_files.append(file_path) - return font_files - - font_files = gather_font_files(directory) - - bg_color = 0 - fg_color = 0x07E0 - scale = 1 - - for font_file in font_files: - try: - font = Font(font_file) - except RuntimeError as e: - print(e) - continue - - if EXPORT: - font.export(font.font_data.replace(".bin", ".py")) - - height = font.height - font_name = font.font_name - - buffer = bytearray(display_drv.width * height * 2) - fb = FrameBuffer(buffer, display_drv.width, height, RGB565) - fb.fill(bg_color) - string = "".join([chr(i) for i in range(65, 91)]) + ": " + font_name.split("/")[-1] - font.text(fb, string, 0, 0, fg_color, scale) - display_drv.blit_rect(buffer, 0, y_pos % display_drv.height, display_drv.width, height) - y_pos += height - if y_pos > display_drv.height: - display_drv.vscsad((y_pos - display_drv.height) % display_drv.height) - display_drv.show() - - -main() \ No newline at end of file diff --git a/lib/examples/framebuf_simpletest.py b/lib/examples/framebuf_simpletest.py deleted file mode 100644 index 2f046ccbb..000000000 --- a/lib/examples/framebuf_simpletest.py +++ /dev/null @@ -1,80 +0,0 @@ -# deps: pygraphics -""" -Simple test example to demonstrate pygraphics.FrameBuffer. -""" - -from board_config import display_drv -from pygraphics import FrameBuffer, RGB565 -from array import array # for defining a polygon - -# If byte swapping is required and the display bus is capable of having byte swapping disabled, -# disable it and set a flag so we can swap the color bytes as they are created. -if display_drv.requires_byteswap: - needs_swap = display_drv.disable_auto_byteswap(True) -else: - needs_swap = False - -WIDTH = display_drv.width -HEIGHT = display_drv.height -FONT_WIDTH = 8 - -# Create a frame buffer -BPP = display_drv.color_depth // 8 # Bytes per pixel -ba = bytearray(WIDTH * HEIGHT * BPP) -fb = FrameBuffer(ba, WIDTH, HEIGHT, RGB565) - - -# Define color palette -class pal: - BLACK = 0x0000 - WHITE = 0xFFFF - RED = 0xF800 if not needs_swap else 0x00F8 - GREEN = 0x07E0 if not needs_swap else 0xE007 - BLUE = 0x001F if not needs_swap else 0xF800 - CYAN = 0x07FF if not needs_swap else 0xFF07 - MAGENTA = 0xF81F if not needs_swap else 0x1FF8 - YELLOW = 0xFFE0 if not needs_swap else 0xE0FF - ORANGE = 0xFD20 if not needs_swap else 0x20FD - PURPLE = 0x8010 if not needs_swap else 0x1080 - GREY = 0x8410 if not needs_swap else 0x1084 - - -# Define objects -triangle = array("h", [0, 0, WIDTH // 2, -HEIGHT // 4, WIDTH - 1, 0]) - - -# Main loop -def main(scroll=False, animate=False, text1="framebuf", text2="simpletest", poly=triangle): - y_range = range(HEIGHT - 1, -1, -1) if animate else [HEIGHT - 1] - for y in y_range: - fb.fill(pal.BLACK) - fb.poly(0, y, poly, pal.YELLOW, True) - fb.fill_rect(WIDTH // 6, HEIGHT // 3, WIDTH * 2 // 3, HEIGHT // 3, pal.GREY) - fb.line(0, 0, WIDTH - 1, HEIGHT - 1, pal.GREEN) - fb.rect(0, 0, 15, 15, pal.RED, True) - fb.rect(WIDTH - 15, HEIGHT - 15, 15, 15, pal.BLUE, True) - fb.hline(WIDTH // 8, HEIGHT // 2, WIDTH * 3 // 4, pal.MAGENTA) - fb.vline(WIDTH // 2, HEIGHT // 4, HEIGHT // 2, pal.CYAN) - fb.pixel(WIDTH // 2, HEIGHT * 1 // 8, pal.WHITE) - fb.ellipse(WIDTH // 2, HEIGHT // 2, WIDTH // 4, HEIGHT // 8, pal.BLACK, True, 0b1111) - fb.text(text1, (WIDTH - FONT_WIDTH * len(text1)) // 2, HEIGHT // 2 - 8, pal.WHITE) - fb.text(text2, (WIDTH - FONT_WIDTH * len(text2)) // 2, HEIGHT // 2, pal.WHITE) - display_drv.blit_rect(ba, 0, 0, WIDTH, HEIGHT) - display_drv.show() - - fb.hline(0, 0, WIDTH, pal.BLACK) - fb.vline(0, 0, HEIGHT, pal.BLACK) - - scroll_range = range(min(WIDTH, HEIGHT)) if scroll else [0] - for _ in scroll_range: - fb.scroll(1, 1) - display_drv.blit_rect(ba, 0, 0, WIDTH, HEIGHT) - display_drv.show() - - -launch = lambda: main(animate=False) # noqa: E731 - -wipe = lambda: main(scroll=False) # noqa: E731 - -main() -display_drv.show() diff --git a/lib/examples/graphics_simpletest.py b/lib/examples/graphics_simpletest.py deleted file mode 100644 index 06cd68e9b..000000000 --- a/lib/examples/graphics_simpletest.py +++ /dev/null @@ -1,74 +0,0 @@ -# deps: palettes, pygraphics -""" -Simple test example to demonstrate the use of pygraphics. -""" - -from board_config import display_drv -from array import array # for defining a polygon -from palettes import get_palette -import pygraphics - - -# If byte swapping is required and the display bus is capable of having byte swapping disabled, -# disable it and set a flag so we can swap the color bytes as they are created. -if display_drv.requires_byteswap: - needs_swap = display_drv.disable_auto_byteswap(True) -else: - needs_swap = False - -WIDTH = display_drv.width -HEIGHT = display_drv.height -FONT_WIDTH = 8 - -# Define color palette -pal = get_palette(swapped=needs_swap) - -# Define objects -triangle = array("h", [0, 0, WIDTH // 2, -HEIGHT // 4, WIDTH - 1, 0]) - - -# Main loop -def main(animate=False, text1="Shapes", text2="simpletest", poly=triangle): - y_range = range(HEIGHT - 1, -1, -1) if animate else [HEIGHT - 1] - for y in y_range: - pygraphics.fill(display_drv, pal.BLACK) - pygraphics.poly(display_drv, 0, y, poly, pal.YELLOW, True) - pygraphics.fill_rect( - display_drv, - WIDTH // 6, - HEIGHT // 3, - WIDTH * 2 // 3, - HEIGHT // 3, - pal.GREY, - ) - pygraphics.line(display_drv, 0, 0, WIDTH - 1, HEIGHT - 1, pal.GREEN) - pygraphics.rect(display_drv, 0, 0, 15, 15, pal.RED, True) - pygraphics.rect(display_drv, WIDTH - 15, HEIGHT - 15, 15, 15, pal.BLUE, True) - pygraphics.hline(display_drv, WIDTH // 8, HEIGHT // 2, WIDTH * 3 // 4, pal.MAGENTA) - pygraphics.vline(display_drv, WIDTH // 2, HEIGHT // 4, HEIGHT // 2, pal.CYAN) - pygraphics.pixel(display_drv, WIDTH // 2, HEIGHT * 1 // 8, pal.WHITE) - pygraphics.ellipse( - display_drv, - WIDTH // 2, - HEIGHT // 2, - WIDTH // 4, - HEIGHT // 8, - pal.BLACK, - True, - 0b1111, - ) - pygraphics.text( - display_drv, text1, (WIDTH - FONT_WIDTH * len(text1)) // 2, HEIGHT // 2 - 8, pal.WHITE - ) - pygraphics.text( - display_drv, text2, (WIDTH - FONT_WIDTH * len(text2)) // 2, HEIGHT // 2, pal.WHITE - ) - - pygraphics.hline(display_drv, 0, 0, WIDTH, pal.BLACK) - pygraphics.vline(display_drv, 0, 0, HEIGHT, pal.BLACK) - - -launch = lambda: main(animate=False) # noqa: E731 - -main() -display_drv.show() diff --git a/lib/examples/joystick_list_select.py b/lib/examples/joystick_list_select.py deleted file mode 100644 index 4d552934a..000000000 --- a/lib/examples/joystick_list_select.py +++ /dev/null @@ -1,41 +0,0 @@ -# deps: pdwidgets -import board_config -import appdev -import pdwidgets as pd - -app = appdev.App(board_config) - -display = pd.Display(board_config.display_drv, app,40) -screen = pd.Screen(display, visible=False) - -top, bottom, main = screen.top, screen.bottom, screen.main - -pd.Label(top,value="Select an Item") - -list_view = pd.ListView(main, w=int(main.width * .9), h=int(main.height * .9), align=pd.ALIGN.CENTER) - -items = [pd.Label(list_view,value=i) for i in ["Item 1", "Item 2", "Item 3"]] -selected = 0 -items[selected].bg = list_view.color_theme.secondary - -screen.visible = True - - - -def select_item(up: bool): - global selected - if up and selected > 0: - selected -= 1 - elif not up and selected < len(items) - 1: - selected += 1 - for i in items: - i.bg = list_view.color_theme.secondary if i == items[selected] else list_view.color_theme.transparent - list_view.invalidate() - -def joystick_callback(event): - if event.type == pd.events.JOYHATMOTION: - if event.hat == 0: - if event.value[1] != 0: - select_item(event.value[1] > 0) - -app.on(pd.events.JOYHATMOTION, joystick_callback) diff --git a/lib/examples/palettes_demo.py b/lib/examples/palettes_demo.py deleted file mode 100644 index da0af2c23..000000000 --- a/lib/examples/palettes_demo.py +++ /dev/null @@ -1,152 +0,0 @@ -# deps: palettes, pygraphics -""" -palettes_demo.py — Palette walk cycling wheel → cube → material (no env vars). -""" -from board_config import display_drv -import board_config -import appdev - -app = appdev.App(board_config) -from pygraphics import FrameBuffer, RGB565 -from palettes import get_palette - -if display_drv.requires_byteswap: - needs_swap = display_drv.disable_auto_byteswap(True) -else: - needs_swap = False - -display_drv.rotation = 0 - -MODES = ("wheel", "cube", "material") -# Brief hold after a static material draw before advancing. -MATERIAL_HOLD_TICKS = 60 - - -def _setup(): - st = { - "mode_idx": 0, - "mode": None, - # wheel - "wheel_colors": None, - "wheel_ci": 0, - "wheel_i": 0, - "wheel_lh": 2, - # cube - "cube_palette": None, - "cube_entries": None, - "cube_fb": None, - "cube_ba": None, - "cube_idx": 0, - "cube_y": 0, - "cube_scroll": 0, - "cube_lh": 20, - "cube_last": 0, - # material - "mat_hold": 0, - "mat_drawn": False, - } - - def enter_mode(mode): - st["mode"] = mode - display_drv.vscsad(0) - display_drv.fill(0) - if mode == "wheel": - palette = get_palette(name="wheel", swapped=needs_swap, length=256, saturation=1.0) - st["wheel_colors"] = list(palette) - st["wheel_ci"] = 0 - st["wheel_i"] = 0 - elif mode == "cube": - palette = get_palette(name="cube", size=5, color_depth=16, swapped=needs_swap) - lh = st["cube_lh"] - bpp = display_drv.color_depth // 8 - ba = bytearray(display_drv.width * lh * bpp) - st["cube_palette"] = palette - st["cube_entries"] = list(enumerate(palette)) - st["cube_ba"] = ba - st["cube_fb"] = FrameBuffer(ba, display_drv.width, lh, RGB565) - st["cube_idx"] = 0 - st["cube_y"] = 0 - st["cube_scroll"] = 0 - st["cube_last"] = display_drv.height - lh - else: - st["mat_drawn"] = False - st["mat_hold"] = 0 - - def advance(): - st["mode_idx"] = (st["mode_idx"] + 1) % len(MODES) - enter_mode(MODES[st["mode_idx"]]) - - def poll_wheel(): - colors = st["wheel_colors"] - n = len(colors) - lh = st["wheel_lh"] - if st["wheel_i"] >= display_drv.height: - # One full screen painted — advance mode. - advance() - return - display_drv.fill_rect( - 0, - st["wheel_i"] % display_drv.height, - display_drv.width, - lh, - colors[st["wheel_ci"]], - ) - st["wheel_i"] += lh - st["wheel_ci"] = (st["wheel_ci"] + 1) % n - - def poll_cube(): - entries = st["cube_entries"] - n = len(entries) - palette = st["cube_palette"] - lh = st["cube_lh"] - index, color = entries[st["cube_idx"]] - if st["cube_y"] - st["cube_scroll"] - st["cube_last"] > 0: - st["cube_scroll"] = (st["cube_y"] - st["cube_last"]) % display_drv.height - display_drv.vscsad(st["cube_scroll"]) - name = f"{index} - {palette.color_name(index)}" - text_color = palette.WHITE if palette.brightness(index) < 0.4 else palette.BLACK # noqa: PLR2004 - st["cube_fb"].fill(color) - st["cube_fb"].text16(name, 2, 2, text_color) - display_drv.blit_rect( - st["cube_ba"], 0, st["cube_y"] % display_drv.height, display_drv.width, lh - ) - st["cube_y"] += lh - st["cube_idx"] = (st["cube_idx"] + 1) % n - # One full walk of the cube palette (and enough rows to fill a screen). - if st["cube_idx"] == 0 and st["cube_y"] >= display_drv.height: - advance() - - def poll_material(): - if not st["mat_drawn"]: - palette = get_palette(name="material_design", color_depth=16, swapped=needs_swap) - for i, color in enumerate(palette): - display_drv.fill_rect(0, i, display_drv.width, 1, color) - st["mat_drawn"] = True - st["mat_hold"] = 0 - return - st["mat_hold"] += 1 - if st["mat_hold"] >= MATERIAL_HOLD_TICKS: - advance() - - def poll(): - mode = st["mode"] - if mode == "wheel": - poll_wheel() - elif mode == "cube": - poll_cube() - else: - poll_material() - return False - - enter_mode(MODES[0]) - return poll - - -poll = _setup() - - -def _tick(_=None): - poll() - - -app.every(_tick, period=1) \ No newline at end of file diff --git a/lib/examples/pbm_create_new.py b/lib/examples/pbm_create_new.py deleted file mode 100644 index 954df11ad..000000000 --- a/lib/examples/pbm_create_new.py +++ /dev/null @@ -1,73 +0,0 @@ -# deps: pygraphics -from board_config import display_drv -from pygraphics import Draw, FrameBuffer, MONO_HLSB, RGB565 - - -def draw_logo(logo): - w = logo.width - h = logo.height - black = background = 0 - blue = amber = 1 - center_x = w // 2 - center_y = h // 2 - unit = min(w, h) // 2 - draw = Draw(logo) - - logo.fill(background) - - draw.circle(center_x, center_y, unit, blue, True) - draw.circle(center_x, center_y, int(unit * 0.9), black, True) - draw.circle(center_x, center_y, int(unit * 0.8), amber, True) - - left = int(center_x - (unit * 1.2) // 2) - top = int(center_y - (unit * 1.0) // 2) - draw.round_rect(left, top, int(unit * 1.2), int(unit * 1.0), unit // 7, black, True) - - left = int(center_x - (unit * 1.1) // 2) - top = int(center_y - (unit * 0.9) // 2) - draw.round_rect(left, top, int(unit * 1.1), int(unit * 0.9), unit // 9, amber, True) - - left = center_x - (unit * 3 // 8) - top = center_y - (unit * 3 // 8) - size = unit // 4 - - draw.fill_rect(left, top, size, size, black) - draw.fill_rect(w - (left + size), h - (top + size), size, size, black) - - size = size // 2 - draw.circle(w - (left + size), top + size, size, black, True) - draw.circle(left + size, h - (top + size), size, black, True) - - -display_drv.fill(0xF800) - -w = h = 64 -logo = FrameBuffer(bytearray((w + 7) // 8 * h), w, h, MONO_HLSB) -draw_logo(logo) - -buf = bytearray(w * h * 2) -fb = FrameBuffer(buf, w, h, RGB565) -palette = FrameBuffer(memoryview(bytearray(2 * 2)), 2, 1, RGB565) - -# White on black — left and middle columns (opaque top, chromakey bottom). -palette.pixel(0, 0, 0x0000) -palette.pixel(1, 0, 0xFFFF) -fb.blit(logo, 0, 0, -1, palette) -display_drv.blit_rect(buf, 0, 0, w, h) -display_drv.blit_transparent(buf, 0, display_drv.height // 2, w, h, 0x0) -display_drv.blit_rect(buf, display_drv.width // 3, 0, w, h) -display_drv.blit_transparent( - buf, display_drv.width // 3, display_drv.height // 2, w, h, 0x0 -) - -# Green / white on blue staging — right column. -palette.pixel(0, 0, 0x0FF0) -palette.pixel(1, 0, 0xFFFF) -fb.fill(0x000F) -fb.blit(logo, 0, 0, -1, palette) -display_drv.blit_rect(buf, display_drv.width * 2 // 3, 0, w, h) -display_drv.blit_transparent( - buf, display_drv.width * 2 // 3, display_drv.height // 2, w, h, 0x000F -) - -display_drv.show() diff --git a/lib/examples/pbm_simpletest.py b/lib/examples/pbm_simpletest.py deleted file mode 100644 index babfda013..000000000 --- a/lib/examples/pbm_simpletest.py +++ /dev/null @@ -1,38 +0,0 @@ -# deps: pygraphics -# utils: framebuf -# gallery: binaries -from board_config import display_drv -from pygraphics import FrameBuffer, RGB565, pbm_to_framebuffer - - -display_drv.fill(0xF800) -logo = pbm_to_framebuffer("examples/assets/micropython.pbm") - -# Colorize mono → RGB565 via a 2-entry palette, then blit to the display. -buf = bytearray(logo.width * logo.height * 2) -fb = FrameBuffer(buf, logo.width, logo.height, RGB565) -palette = FrameBuffer(memoryview(bytearray(2 * 2)), 2, 1, RGB565) - -# Set bits → white; unset bits stay 0 (used as chromakey below). -palette.pixel(0, 0, 0x0000) -palette.pixel(1, 0, 0xFFFF) -fb.fill(0x0000) -fb.blit(logo, 0, 0, -1, palette) - -display_drv.blit_rect(buf, display_drv.width // 3, 0, logo.width, logo.height) -display_drv.blit_transparent( - buf, display_drv.width // 3, display_drv.height // 2, logo.width, logo.height, 0x0 -) - -# Green / white on blue; transparent blit keys on the staging fill color 0x000F. -palette.pixel(0, 0, 0x0FF0) -palette.pixel(1, 0, 0xFFFF) -fb.fill(0x000F) -fb.blit(logo, 0, 0, -1, palette) - -display_drv.blit_rect(buf, display_drv.width * 2 // 3, 0, logo.width, logo.height) -display_drv.blit_transparent( - buf, display_drv.width * 2 // 3, display_drv.height // 2, logo.width, logo.height, 0x000F -) - -display_drv.show() \ No newline at end of file diff --git a/lib/examples/pygraphics_landscape.py b/lib/examples/pygraphics_landscape.py deleted file mode 100644 index a5192d7cf..000000000 --- a/lib/examples/pygraphics_landscape.py +++ /dev/null @@ -1,93 +0,0 @@ -# deps: pygraphics -""" -A landscape drawn with pygraphics: a banded sky, a sun, two snow-capped -mountains, a red house on the grass, and a caption. - -The picture scales to whatever display the board config provides, from a -small OLED to a desktop window, and is drawn in horizontal bands so it fits -the memory of a small board: each band is drawn into a FrameBuffer and -copied to the display before the next one. -""" - -from board_config import display_drv -import board_config -import appdev -import sys - -import pygraphics -from multimer import ticks_diff, ticks_ms -from pygraphics import RGB565, FrameBuffer - -app = appdev.App(board_config) - -# The picture is designed at 320x240 and scaled to the display. -W, H = display_drv.width, display_drv.height -SX, SY = W / 320, H / 240 -S = min(SX, SY) -BAND = max(1, min(H, 12800 // W)) # rows per band: about 25 KB of RGB565 - -# Colours go to the panel in its own byte order, so nothing is swapped later. -SWAP = getattr(display_drv, "requires_byteswap", False) -if SWAP: - display_drv.disable_auto_byteswap(True) - - -def rgb(r, g, b): - c = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3) - return ((c & 0xFF) << 8) | (c >> 8) if SWAP else c - - -SKY = [rgb(10, 20, 90), rgb(20, 50, 140), rgb(40, 90, 190), - rgb(70, 130, 220), rgb(110, 170, 240), rgb(160, 205, 250)] -SUN, SUN_RING = rgb(255, 220, 0), rgb(255, 150, 0) -ROCK, SNOW = rgb(110, 110, 130), rgb(250, 250, 250) -GRASS, GRASS_DARK = rgb(40, 160, 60), rgb(20, 110, 40) -WALL, ROOF, DOOR = rgb(220, 60, 50), rgb(120, 40, 30), rgb(80, 50, 20) -WHITE, BLACK = rgb(255, 255, 255), rgb(0, 0, 0) - - -def x(v): - return int(v * SX) - - -def y(v, y0): - return int(v * SY) - y0 - - -def scene(fb, y0): - """The whole picture, drawn y0 rows up; the band clips what falls outside.""" - for i, c in enumerate(SKY): - fb.fill_rect(0, y(i * 27, y0), W, int(27 * SY) + 1, c) - fb.circle(x(255), y(58, y0), int(34 * S), SUN_RING, True) - fb.circle(x(255), y(58, y0), int(28 * S), SUN, True) - fb.triangle(x(-20), y(170, y0), x(90), y(60, y0), x(200), y(170, y0), ROCK, True) - fb.triangle(x(70), y(80, y0), x(90), y(60, y0), x(110), y(80, y0), SNOW, True) - fb.triangle(x(110), y(170, y0), x(210), y(85, y0), x(330), y(170, y0), ROCK, True) - fb.triangle(x(192), y(100, y0), x(210), y(85, y0), x(228), y(100, y0), SNOW, True) - fb.fill_rect(0, y(162, y0), W, H - int(162 * SY), GRASS) - fb.fill_rect(0, y(162, y0), W, max(1, int(4 * SY)), GRASS_DARK) - fb.fill_rect(x(220), y(160, y0), x(70), int(50 * SY), WALL) - fb.triangle(x(212), y(160, y0), x(255), y(126, y0), x(298), y(160, y0), ROOF, True) - fb.fill_rect(x(248), y(182, y0), max(1, x(14)), int(28 * SY), DOOR) - if W >= 160: # captions need room; a tiny display gets the picture alone - fb.round_rect(8, 8 - y0, 136, 26, 6, BLACK, True) - fb.text16("pygraphics", 16, 13 - y0, WHITE) - fb.text(sys.implementation.name, 10, H - 24 - y0, WHITE) - fb.text("pygraphics " + pygraphics.implementation(), 10, H - 12 - y0, WHITE) - fb.rect(0, -y0, W, H, WHITE) - - -def draw(): - buf = bytearray(W * BAND * 2) - fb = FrameBuffer(buf, W, BAND, RGB565) - t0 = ticks_ms() - for y0 in range(0, H, BAND): - rows = min(BAND, H - y0) - scene(fb, y0) - display_drv.blit_rect(memoryview(buf)[: W * rows * 2], 0, y0, W, rows) - display_drv.show() - print("landscape %dx%d drawn in %d ms" % (W, H, ticks_diff(ticks_ms(), t0))) - - -draw() -app.run() diff --git a/lib/examples/rotations.py b/lib/examples/rotations.py deleted file mode 100644 index 5be706179..000000000 --- a/lib/examples/rotations.py +++ /dev/null @@ -1,83 +0,0 @@ -# deps: palettes, pygraphics -""" -rotations.py -============ - -Rotates the display 0, 90, 180, and 270 degrees and displays the rotation -number and the color of the display background. -""" - -from board_config import display_drv -import board_config -import appdev - -app = appdev.App(board_config) -from pygraphics import Draw, text16 -from palettes import get_palette - -pal = get_palette() -draw = Draw(display_drv) - -FONT_W = 8 -FONT_H = 16 - - -def center_text(text, y, fg, bg): - x = (display_drv.width - len(text) * FONT_W) // 2 - # Opaque label: fill bg strip then draw glyphs. - draw.fill_rect(x, y, len(text) * FONT_W, FONT_H, bg) - text16(display_drv, text, x, y, fg) - - -def clear_screen(color): - """Expand rectangles from the center toward the edges.""" - width = display_drv.width - height = display_drv.height - x_center = width // 2 - y_center = height // 2 - - for i in range(min(x_center, y_center)): - x = x_center - i - y = y_center - i - draw.rect(x, y, 2 * i + 1, 2 * i + 1, color) - - -def main(): - colors = ( - ("Red", pal.RED, pal.WHITE), - ("Green", pal.GREEN, pal.BLACK), - ("Blue", pal.BLUE, pal.WHITE), - ("Black", pal.BLACK, pal.WHITE), - ("White", pal.WHITE, pal.BLACK), - ("Yellow", pal.YELLOW, pal.BLACK), - ("Cyan", pal.CYAN, pal.BLACK), - ("Magenta", pal.MAGENTA, pal.BLACK), - ) - - st = {"rotation": 0, "color_idx": 0} - - def poll(): - rotation = st["rotation"] - color_idx = st["color_idx"] - display_drv.rotation = rotation * 90 - height = display_drv.height - fg = colors[color_idx][2] - bg = colors[color_idx][1] - - draw.fill(bg) - draw.rect(0, 0, display_drv.width, height, pal.WHITE) - clear_screen(bg) - center_text("Rotation", height // 3 - FONT_H // 2, fg, bg) - center_text(str(rotation * 90), height // 2 - FONT_H // 2, fg, bg) - center_text(colors[color_idx][0], height // 3 * 2 - FONT_H // 2, fg, bg) - st["color_idx"] = (color_idx + 1) % len(colors) - st["rotation"] = (rotation + 1) % 4 - return False - - def _tick(_=None): - poll() - - app.every(_tick, period=2000) - - -main() \ No newline at end of file diff --git a/lib/examples/tower_climb/README.md b/lib/examples/tower_climb/README.md index 71c1ae2ba..2e5b25683 100644 --- a/lib/examples/tower_climb/README.md +++ b/lib/examples/tower_climb/README.md @@ -11,7 +11,7 @@ game. ## Origins and iteration The example started as a vertical-scrolling platformer (software camera, no -hardware rotation), loosely inspired by `bmp565_scroll_sprite.py` and classic +hardware rotation), loosely inspired by pygraphics' `bmp565_scroll_sprite.py` example and classic climbers. Early work focused on: - Scalable layout from a 320×480 reference (`Layout` in [`tower_climb.py`](tower_climb.py)) diff --git a/packages/examples.json b/packages/examples.json index 45280ea07..98d0144e8 100644 --- a/packages/examples.json +++ b/packages/examples.json @@ -16,10 +16,6 @@ "appdev_touch_coords.py", "github:PyDevices/pydevices-examples/lib/examples/appdev_touch_coords.py" ], - [ - "appdev_touch_test.py", - "github:PyDevices/pydevices-examples/lib/examples/appdev_touch_test.py" - ], [ "audio_arpeggio.py", "github:PyDevices/pydevices-examples/lib/examples/audio_arpeggio.py" @@ -36,22 +32,6 @@ "audiolive_rack.py", "github:PyDevices/pydevices-examples/lib/examples/audiolive_rack.py" ], - [ - "bmp565_scroll.py", - "github:PyDevices/pydevices-examples/lib/examples/bmp565_scroll.py" - ], - [ - "bmp565_scroll_sprite.py", - "github:PyDevices/pydevices-examples/lib/examples/bmp565_scroll_sprite.py" - ], - [ - "bmp565_simpletest.py", - "github:PyDevices/pydevices-examples/lib/examples/bmp565_simpletest.py" - ], - [ - "bmp565_sprite.py", - "github:PyDevices/pydevices-examples/lib/examples/bmp565_sprite.py" - ], [ "bmp565_sprite_transparent.py", "github:PyDevices/pydevices-examples/lib/examples/bmp565_sprite_transparent.py" @@ -112,10 +92,6 @@ "feathers.py", "github:PyDevices/pydevices-examples/lib/examples/feathers.py" ], - [ - "font_list.py", - "github:PyDevices/pydevices-examples/lib/examples/font_list.py" - ], [ "font_simpletest.py", "github:PyDevices/pydevices-examples/lib/examples/font_simpletest.py" @@ -124,22 +100,10 @@ "fonts.py", "github:PyDevices/pydevices-examples/lib/examples/fonts.py" ], - [ - "framebuf_simpletest.py", - "github:PyDevices/pydevices-examples/lib/examples/framebuf_simpletest.py" - ], - [ - "graphics_simpletest.py", - "github:PyDevices/pydevices-examples/lib/examples/graphics_simpletest.py" - ], [ "hello.py", "github:PyDevices/pydevices-examples/lib/examples/hello.py" ], - [ - "joystick_list_select.py", - "github:PyDevices/pydevices-examples/lib/examples/joystick_list_select.py" - ], [ "keypins_simpletest.py", "github:PyDevices/pydevices-examples/lib/examples/keypins_simpletest.py" @@ -188,18 +152,6 @@ "paint.py", "github:PyDevices/pydevices-examples/lib/examples/paint.py" ], - [ - "palettes_demo.py", - "github:PyDevices/pydevices-examples/lib/examples/palettes_demo.py" - ], - [ - "pbm_create_new.py", - "github:PyDevices/pydevices-examples/lib/examples/pbm_create_new.py" - ], - [ - "pbm_simpletest.py", - "github:PyDevices/pydevices-examples/lib/examples/pbm_simpletest.py" - ], [ "piano.py", "github:PyDevices/pydevices-examples/lib/examples/piano.py" @@ -212,14 +164,6 @@ "pydevices_demo.py", "github:PyDevices/pydevices-examples/lib/examples/pydevices_demo.py" ], - [ - "pygraphics_landscape.py", - "github:PyDevices/pydevices-examples/lib/examples/pygraphics_landscape.py" - ], - [ - "rotations.py", - "github:PyDevices/pydevices-examples/lib/examples/rotations.py" - ], [ "scroll.py", "github:PyDevices/pydevices-examples/lib/examples/scroll.py" diff --git a/pydevices-examples.toml b/pydevices-examples.toml index 50be1fc6e..62c3a493f 100644 --- a/pydevices-examples.toml +++ b/pydevices-examples.toml @@ -11,7 +11,6 @@ "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/appdev_encoder_test.py" = "/examples/appdev_encoder_test.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/appdev_simpletest.py" = "/examples/appdev_simpletest.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/appdev_touch_coords.py" = "/examples/appdev_touch_coords.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/appdev_touch_test.py" = "/examples/appdev_touch_test.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/audio_arpeggio.py" = "/examples/audio_arpeggio.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/audio_in_playback_test.py" = "/examples/audio_in_playback_test.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/audio_out_test.py" = "/examples/audio_out_test.py" @@ -25,10 +24,6 @@ "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/blackjack/blackjack.py" = "/examples/blackjack/blackjack.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/blackjack/playing_cards.py" = "/examples/blackjack/playing_cards.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/blackjack/playing_cards_simpletest.py" = "/examples/blackjack/playing_cards_simpletest.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/bmp565_scroll.py" = "/examples/bmp565_scroll.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/bmp565_scroll_sprite.py" = "/examples/bmp565_scroll_sprite.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/bmp565_simpletest.py" = "/examples/bmp565_simpletest.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/bmp565_sprite.py" = "/examples/bmp565_sprite.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/bmp565_sprite_transparent.py" = "/examples/bmp565_sprite_transparent.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/bouncing_balls.py" = "/examples/bouncing_balls.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/boxlines.py" = "/examples/boxlines.py" @@ -78,10 +73,8 @@ "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/feathers.py" = "/examples/feathers.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/fleet_page/check_fleet.py" = "/examples/fleet_page/check_fleet.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/fleet_page/fleet.py" = "/examples/fleet_page/fleet.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/font_list.py" = "/examples/font_list.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/font_simpletest.py" = "/examples/font_simpletest.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/fonts.py" = "/examples/fonts.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/framebuf_simpletest.py" = "/examples/framebuf_simpletest.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/google_photos/__init__.py" = "/examples/google_photos/__init__.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/google_photos/__main__.py" = "/examples/google_photos/__main__.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/google_photos/assets/gen_sim_assets.py" = "/examples/google_photos/assets/gen_sim_assets.py" @@ -89,7 +82,6 @@ "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/google_photos/gphotos_engine.py" = "/examples/google_photos/gphotos_engine.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/google_photos/gphotos_lvgl.py" = "/examples/google_photos/gphotos_lvgl.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/google_photos/gphotos_sim.py" = "/examples/google_photos/gphotos_sim.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/graphics_simpletest.py" = "/examples/graphics_simpletest.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/hello.py" = "/examples/hello.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/house/__init__.py" = "/examples/house/__init__.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/house/house_app.py" = "/examples/house/house_app.py" @@ -97,7 +89,6 @@ "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/house/house_server.py" = "/examples/house/house_server.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/house/main.py" = "/examples/house/main.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/house/showtv_proof.py" = "/examples/house/showtv_proof.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/joystick_list_select.py" = "/examples/joystick_list_select.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/keypins_simpletest.py" = "/examples/keypins_simpletest.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/logo.py" = "/examples/logo.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/lv_dynamic_fonts.py" = "/examples/lv_dynamic_fonts.py" @@ -116,9 +107,6 @@ "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/noto_fonts/__init__.py" = "/examples/noto_fonts/__init__.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/noto_fonts/noto_fonts.py" = "/examples/noto_fonts/noto_fonts.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/paint.py" = "/examples/paint.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/palettes_demo.py" = "/examples/palettes_demo.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/pbm_create_new.py" = "/examples/pbm_create_new.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/pbm_simpletest.py" = "/examples/pbm_simpletest.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/piano.py" = "/examples/piano.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/pixel_sim_demos.py" = "/examples/pixel_sim_demos.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/proverbs/__init__.py" = "/examples/proverbs/__init__.py" @@ -126,7 +114,6 @@ "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/proverbs/proverbs_20.py" = "/examples/proverbs/proverbs_20.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/proverbs/proverbs_30.py" = "/examples/proverbs/proverbs_30.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/pydevices_demo.py" = "/examples/pydevices_demo.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/pygraphics_landscape.py" = "/examples/pygraphics_landscape.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/roku/board_config.py" = "/examples/roku/board_config.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/roku/roku_companion_dashboard.py" = "/examples/roku/roku_companion_dashboard.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/roku/roku_companion_displaydev.py" = "/examples/roku/roku_companion_displaydev.py" @@ -143,7 +130,6 @@ "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/roku_remote/roku_remote.py" = "/examples/roku_remote/roku_remote.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/roku_remote/roku_sim.py" = "/examples/roku_remote/roku_sim.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/roku_remote/roku_widgets.py" = "/examples/roku_remote/roku_widgets.py" -"https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/rotations.py" = "/examples/rotations.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/scroll.py" = "/examples/scroll.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/scroll_touch_test.py" = "/examples/scroll_touch_test.py" "https://raw.githubusercontent.com/PyDevices/pydevices-examples/main/lib/examples/sensor_hub/__init__.py" = "/examples/sensor_hub/__init__.py" diff --git a/tools/example_test_kit.py b/tools/example_test_kit.py index 0550ad348..899bc3688 100755 --- a/tools/example_test_kit.py +++ b/tools/example_test_kit.py @@ -1681,8 +1681,6 @@ def main(argv: list[str] | None = None) -> int: "calc_graphics", "paint", "appdev_simpletest", - "graphics_simpletest", - "framebuf_simpletest", "color_test", "chango", } diff --git a/tools/example_test_manifest.toml b/tools/example_test_manifest.toml index 15b8fd31c..243fdf92e 100644 --- a/tools/example_test_manifest.toml +++ b/tools/example_test_manifest.toml @@ -121,22 +121,6 @@ kind = "async" quit = "poll" deps = ["core"] -[examples.graphics_simpletest] -import = "graphics_simpletest" -script = "examples/graphics_simpletest.py" -kind = "oneshot" -quit = "native_exit" -deps = ["core"] -oneshot_timeout_s = 20 - -[examples.framebuf_simpletest] -import = "framebuf_simpletest" -script = "examples/framebuf_simpletest.py" -kind = "oneshot" -quit = "native_exit" -deps = ["core"] -oneshot_timeout_s = 20 - [examples.color_test] import = "color_test" script = "examples/color_test.py" @@ -222,35 +206,6 @@ kind = "async" quit = "poll" deps = ["core"] -[examples.bmp565_scroll] -import = "bmp565_scroll" -script = "examples/bmp565_scroll.py" -kind = "loop" -quit = "poll" -deps = ["core"] - -[examples.bmp565_scroll_sprite] -import = "bmp565_scroll_sprite" -script = "examples/bmp565_scroll_sprite.py" -kind = "loop" -quit = "poll" -timeout_s = 70 -deps = ["core"] - -[examples.bmp565_simpletest] -import = "bmp565_simpletest" -script = "examples/bmp565_simpletest.py" -kind = "oneshot" -quit = "native_exit" -deps = ["core"] - -[examples.bmp565_sprite] -import = "bmp565_sprite" -script = "examples/bmp565_sprite.py" -kind = "loop" -quit = "poll" -deps = ["core"] - [examples.bmp565_sprite_transparent] import = "bmp565_sprite_transparent" script = "examples/bmp565_sprite_transparent.py" @@ -308,13 +263,6 @@ kind = "loop" quit = "poll" deps = ["core"] -[examples.appdev_touch_test] -import = "appdev_touch_test" -script = "examples/appdev_touch_test.py" -kind = "loop" -quit = "inject" -deps = ["core"] - [examples.feathers] import = "feathers" script = "examples/feathers.py" @@ -322,13 +270,6 @@ kind = "loop" quit = "poll" deps = ["core"] -[examples.font_list] -import = "font_list" -script = "examples/font_list.py" -kind = "oneshot" -quit = "native_exit" -deps = ["core"] - [examples.font_simpletest] import = "font_simpletest" script = "examples/font_simpletest.py" @@ -350,13 +291,6 @@ kind = "loop" quit = "poll" deps = ["utils", "tft_config"] -[examples.joystick_list_select] -import = "joystick_list_select" -script = "examples/joystick_list_select.py" -kind = "loop" -quit = "inject" -deps = ["utils"] - [examples.logo] import = "logo" script = "examples/logo.py" @@ -399,35 +333,6 @@ timeout_s = 240 # there either -- the tree only ever appears via another interpreter. skip_interpreters = ["circuitpython"] -[examples.palettes_demo] -import = "palettes_demo" -script = "examples/palettes_demo.py" -kind = "loop" -quit = "poll" -deps = ["core"] - -[examples.pbm_create_new] -import = "pbm_create_new" -script = "examples/pbm_create_new.py" -kind = "oneshot" -quit = "native_exit" -oneshot_timeout_s = 45 -deps = ["core"] - -[examples.pbm_simpletest] -import = "pbm_simpletest" -script = "examples/pbm_simpletest.py" -kind = "oneshot" -quit = "native_exit" -deps = ["core"] - -[examples.rotations] -import = "rotations" -script = "examples/rotations.py" -kind = "loop" -quit = "poll" -deps = ["core"] - [examples.scroll] import = "scroll" script = "examples/scroll.py"