Skip to content

Commit

Permalink
Hey, Presto!
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Aug 13, 2024
1 parent 3ecdbf4 commit abb4617
Show file tree
Hide file tree
Showing 29 changed files with 310 additions and 329 deletions.
57 changes: 42 additions & 15 deletions .github/workflows/micropython.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,23 @@ jobs:
strategy:
matrix:
include:
- name: pga2040
board: pga2040
- name: presto
board: presto
variant:
modules: default
- name: pga2350
board: pga2350
modules: default
- name: pga2350-psram # Friendly-name for output files
board: pga2350 # /<board>
variant: PSRAM # /<board>/mpconfigvariant_<variant>.cmake
modules: default # /modules/<modules>.cmake

env:
# MicroPython version will be contained in github.event.release.tag_name for releases
RELEASE_FILE: ${{ matrix.name }}-${{ github.event.release.tag_name || github.sha }}-micropython
PIMORONI_PICO_DIR: "${{ github.workspace }}/pimoroni-pico"
MICROPY_BOARD_DIR: "${{ github.workspace }}/src-${{ github.sha }}/${{ matrix.BOARD }}"
USER_C_MODULES: "${{ github.workspace }}/src-${{ github.sha }}/modules/${{ matrix.modules }}.cmake"
USER_FS_MANIFEST: "${{ github.workspace }}/src-${{ github.sha }}/modules/${{ matrix.modules }}.txt"
USER_FS_SOURCE: "${{ github.workspace }}/src-${{ github.sha }}/modules/littlefs"
TAG_OR_SHA: ${{ github.event.release.tag_name || github.sha }}
MICROPY_BOARD: ${{ matrix.board }}
MICROPY_BOARD_VARIANT: ${{ matrix.variant }}
MICROPY_BOARD_DIR: "${{ github.workspace }}/src-${{ github.sha }}/${{ matrix.BOARD }}"
MICROPY_FROZEN_MANIFEST: "${{ github.workspace }}/src-${{ github.sha }}/modules/${{ matrix.modules }}.py"
BOARD_NAME: ${{ matrix.name }}
BUILD_TOOLS: src-${{ github.sha }}/ci/micropython.sh

Expand Down Expand Up @@ -81,12 +78,19 @@ jobs:
source $BUILD_TOOLS
micropython_clone
- name: "Py_Decl: Checkout py_decl"
- name: "Py_Decl: Checkout"
uses: actions/checkout@v4
with:
repository: gadgetoid/py_decl
ref: v0.0.2
path: py_decl

- name: "dir2uf2: Checkout"
uses: actions/checkout@v4
with:
repository: gadgetoid/dir2uf2
ref: v0.0.7
path: dir2uf2

- name: "MicroPython: Build MPY Cross"
run: |
Expand All @@ -106,24 +110,47 @@ jobs:
source $BUILD_TOOLS
cmake_build
- name: "Py_Decl: Verify UF2"
- name: "Py_Decl: Verify .uf2"
shell: bash
run: |
python3 py_decl/py_decl.py --to-json --verify build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2
- name: Store .uf2 as artifact
- name: "dir2uf2: Append filesystem to .uf2"
shell: bash
run: |
python3 -m pip install littlefs-python==0.12.0
./dir2uf2/dir2uf2 --fs-compact --append-to build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2 --manifest ${{env.USER_FS_MANIFEST}} --filename with-filesystem.uf2 ${{env.USER_FS_SOURCE}}/
- name: "Artifacts: Upload .uf2"
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_FILE }}.uf2
path: build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2

- name: Upload .uf2
- name: "Artifacts: Upload .uf2 with filesystem"
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_FILE }}-with-filesystem.uf2
path: ${{ env.RELEASE_FILE }}-with-filesystem.uf2

- name: "Release: Upload .uf2"
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_path: build-${{ matrix.name }}/firmware.uf2
asset_path: build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2
upload_url: ${{ github.event.release.upload_url }}
asset_name: ${{ env.RELEASE_FILE }}.uf2
asset_content_type: application/octet-stream

- name: "Release: Upload .uf2 with filesystem"
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_path: ${{ env.RELEASE_FILE }}-with-filesystem.uf2
upload_url: ${{ github.event.release.upload_url }}
asset_name: ${{ env.RELEASE_FILE }}-with-filesystem.uf2
asset_content_type: application/octet-stream
17 changes: 1 addition & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
# Pimoroni PGA Boilerplate

This repository is intended to provide a baseline MicroPython build for PGA2040
and PGA2350, in addition to being a minimal example of how you might set up your
own custom MicroPython flavour to support your PGA-based project.

Use this repository as a boilerplate to set up your own project, and GitHub actions
should automatically handle building MicroPython for you.

## Contents

* pga2040 - MicroPython and Pico SDK board definitions for PGA2040
* pga2350 - MicroPython and Pico SDK board definitions for PGA2350, with PSRAM variant
* modules/c/example - An example MicroPython C++ module, demonstrating C class bindings
* modules/py_frozen - Python files intended to be frozen into the firmware
* modules/py_littlefs - Python files intended to be visible/editable in the LittleFS user filesystem
# Pimoroni Presto
1 change: 1 addition & 0 deletions ci/micropython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function cmake_configure {
-DMICROPY_BOARD_DIR=$MICROPY_BOARD_DIR \
-DMICROPY_BOARD=$MICROPY_BOARD \
-DMICROPY_BOARD_VARIANT=$MICROPY_BOARD_VARIANT \
-DMICROPY_FROZEN_MANIFEST=$MICROPY_FROZEN_MANIFEST \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
}
Expand Down
37 changes: 0 additions & 37 deletions modules/c/example/example.c

This file was deleted.

67 changes: 0 additions & 67 deletions modules/c/example/example.cpp

This file was deleted.

8 changes: 0 additions & 8 deletions modules/c/example/example.h

This file was deleted.

16 changes: 0 additions & 16 deletions modules/c/example/micropython.cmake

This file was deleted.

22 changes: 22 additions & 0 deletions modules/c/presto/micropython.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
add_library(usermod_presto INTERFACE)

target_sources(usermod_presto INTERFACE
${CMAKE_CURRENT_LIST_DIR}/presto.c
${CMAKE_CURRENT_LIST_DIR}/presto.cpp
${CMAKE_CURRENT_LIST_DIR}/../../../drivers/st7701_portal/st7701.cpp
${CMAKE_CURRENT_LIST_DIR}/../../../libraries/pico_graphics/pico_graphics_pen_rgb565.cpp
)
pico_generate_pio_header(usermod_presto ${CMAKE_CURRENT_LIST_DIR}/../../../drivers/st7701_portal/st7701_parallel.pio)
pico_generate_pio_header(usermod_presto ${CMAKE_CURRENT_LIST_DIR}/../../../drivers/st7701_portal/st7701_timing.pio)

target_include_directories(usermod_presto INTERFACE
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/../../../libraries/pico_graphics/
${CMAKE_CURRENT_LIST_DIR}/../../../drivers/st7701_portal/
)

target_compile_definitions(usermod_presto INTERFACE
MODULE_PRESTO_ENABLED=1
)

target_link_libraries(usermod INTERFACE usermod_presto)
45 changes: 45 additions & 0 deletions modules/c/presto/presto.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "presto.h"


/***** Methods *****/

MP_DEFINE_CONST_FUN_OBJ_1(Presto___del___obj, Presto___del__);
MP_DEFINE_CONST_FUN_OBJ_2(Presto_update_obj, Presto_update);

/***** Binding of Methods *****/

static const mp_rom_map_elem_t Presto_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&Presto___del___obj) },
{ MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&Presto_update_obj) },

{ MP_ROM_QSTR(MP_QSTR_WIDTH), MP_ROM_INT(WIDTH) },
{ MP_ROM_QSTR(MP_QSTR_HEIGHT), MP_ROM_INT(HEIGHT) },
};

static MP_DEFINE_CONST_DICT(Presto_locals_dict, Presto_locals_dict_table);


MP_DEFINE_CONST_OBJ_TYPE(
Presto_type,
MP_QSTR_Presto,
MP_TYPE_FLAG_NONE,
make_new, Presto_make_new,
locals_dict, (mp_obj_dict_t*)&Presto_locals_dict
);

/***** Globals Table *****/
static const mp_map_elem_t presto_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_presto) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_Presto), (mp_obj_t)&Presto_type },
};

static MP_DEFINE_CONST_DICT(mp_module_presto_globals, presto_globals_table);

/***** Module Definition *****/

const mp_obj_module_t presto_user_cmodule = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&mp_module_presto_globals,
};

MP_REGISTER_MODULE(MP_QSTR_presto, presto_user_cmodule);
Loading

0 comments on commit abb4617

Please sign in to comment.