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 b6e1c92
Show file tree
Hide file tree
Showing 28 changed files with 311 additions and 313 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
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.

24 changes: 24 additions & 0 deletions modules/c/presto/micropython.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set(MOD_NAME portal)
string(TOUPPER ${MOD_NAME} MOD_NAME_UPPER)
add_library(usermod_${MOD_NAME} INTERFACE)

target_sources(usermod_${MOD_NAME} INTERFACE
${CMAKE_CURRENT_LIST_DIR}/${MOD_NAME}.c
${CMAKE_CURRENT_LIST_DIR}/${MOD_NAME}.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_${MOD_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../../drivers/st7701_portal/st7701_parallel.pio)
pico_generate_pio_header(usermod_${MOD_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../../drivers/st7701_portal/st7701_timing.pio)

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

target_compile_definitions(usermod_${MOD_NAME} INTERFACE
MODULE_PORTAL_ENABLED=1
)

target_link_libraries(usermod INTERFACE usermod_${MOD_NAME})
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(Portal___del___obj, Portal___del__);
MP_DEFINE_CONST_FUN_OBJ_2(Portal_update_obj, Portal_update);

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

static const mp_rom_map_elem_t Portal_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&Portal___del___obj) },
{ MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&Portal_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(Portal_locals_dict, Portal_locals_dict_table);


MP_DEFINE_CONST_OBJ_TYPE(
Portal_type,
MP_QSTR_Portal,
MP_TYPE_FLAG_NONE,
make_new, Portal_make_new,
locals_dict, (mp_obj_dict_t*)&Portal_locals_dict
);

/***** Globals Table *****/
static const mp_map_elem_t portal_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_portal) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_Portal), (mp_obj_t)&Portal_type },
};

static MP_DEFINE_CONST_DICT(mp_module_portal_globals, portal_globals_table);

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

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

MP_REGISTER_MODULE(MP_QSTR_portal, portal_user_cmodule);
Loading

0 comments on commit b6e1c92

Please sign in to comment.