Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
7bdd85d
Fix web server only serving file once and wifi country configuration
mutatrum Apr 8, 2023
f620687
Update pico_rtc.py
Quitsoon Apr 11, 2023
a19f594
CI: Use name instead of board for build dir.
Gadgetoid Apr 24, 2023
1d003a8
CI: Revert lib/pico-sdk before build.
Gadgetoid Apr 24, 2023
5bfc0eb
Merge pull request #756 from pimoroni/ci/fix-caching
Gadgetoid Apr 24, 2023
af99d6d
MicroPython: Set board manifest for Inky, Enviro.
Gadgetoid Apr 24, 2023
334283a
Merge pull request #757 from pimoroni/ci/board-manifests
Gadgetoid Apr 24, 2023
c25de67
CI: Set MICROPY_GIT_TAG and MICROPY_GIT_HASH for #752.
Gadgetoid Apr 26, 2023
49e0b25
Fix relative link to PicoGraphics documentation
andrewmk Apr 26, 2023
b512bdc
Merge pull request #760 from andrewmk/main
helgibbons Apr 26, 2023
8e0fe15
CI: Fix patch revert hack.
Gadgetoid Apr 27, 2023
c885789
CI: Bump to MicroPython v1.20.0.
Gadgetoid Apr 27, 2023
f097577
Merge pull request #759 from pimoroni/ci/version-info
Gadgetoid Apr 27, 2023
70f133d
CI: Single-job builds to avoid #761.
Gadgetoid Apr 27, 2023
22a659a
CI: Set C heap size.
Gadgetoid Apr 28, 2023
56dba37
Merge pull request #762 from pimoroni/ci/single-job
Gadgetoid Apr 28, 2023
59d57a1
Initial support for Encoder wheel breakout
ZodiusInfuser Sep 12, 2022
15978e5
Temporary fix for compiler issues
ZodiusInfuser Sep 27, 2022
e3c3692
Test python for encoder
ZodiusInfuser Sep 27, 2022
7c11593
Fix for IOExpander address not getting changed
ZodiusInfuser Sep 27, 2022
f353525
First porting of python examples
ZodiusInfuser Apr 27, 2023
cd83a51
Fix micropython config
ZodiusInfuser Apr 27, 2023
6464f44
Fix micropython config
ZodiusInfuser Apr 27, 2023
178afd1
remove description prints
ZodiusInfuser Apr 27, 2023
2d45ed6
Updated mp function list
ZodiusInfuser May 2, 2023
928c28b
Switch to rom_map
ZodiusInfuser May 2, 2023
dd4347d
CI: Grab only necessary modules.
Gadgetoid Apr 28, 2023
d4d6cd1
Progress on encoder wheel C++ and MP
ZodiusInfuser May 2, 2023
e90ae33
CI: All MicroPython builds use local board dirs.
Gadgetoid May 2, 2023
45a2e0f
MicroPython: Set hostname for Enviro and Inky.
Gadgetoid May 2, 2023
387df3b
Progress on encoder wheel C++ and MP
ZodiusInfuser May 2, 2023
1cfae8b
More work on encoder wheel C++, adding reset to ioe
ZodiusInfuser May 2, 2023
226e750
Fix
ZodiusInfuser May 2, 2023
e3f9f14
Fix ioe reset timing out too early, and encoder reversed
ZodiusInfuser May 3, 2023
8648597
CI: Clean ports/rp2/modules before each build.
Gadgetoid May 3, 2023
9f925b5
Ported most encoder wheel examples to C++
ZodiusInfuser May 3, 2023
e0a4057
Fix namespace issue
ZodiusInfuser May 3, 2023
b30d9ca
CI: Switch py modules from cmake hacks to manifest.py.
Gadgetoid May 3, 2023
4dadeb0
Add c++ examples readme
ZodiusInfuser May 4, 2023
7951ef9
CI: Hack: Patch MicroPython to remove exception handling.
Gadgetoid May 4, 2023
862806f
Simplified example I2C setup
ZodiusInfuser May 4, 2023
5619274
Added MP readme
ZodiusInfuser May 4, 2023
b6499e7
Merge pull request #764 from pimoroni/ci/smolmodules
Gadgetoid May 4, 2023
a59aa35
Improved inky's sleep_for, now handles up to 28 days (#754)
ahnlak May 4, 2023
8966cbf
Added C++ readme
ZodiusInfuser May 4, 2023
1dcad21
Pico Display Pack: Display init fixes.
May 4, 2023
7491ced
Merge pull request #767 from pimoroni/1.14_lcd_improved
Gadgetoid May 4, 2023
1be888f
Cosmic: add links
helgibbons May 5, 2023
302d6ae
Merge pull request #768 from pimoroni/helgibbons-patch-1
helgibbons May 5, 2023
67df015
fonts need cstdint
raybellis May 8, 2023
32dfdc6
use __builtin_bswap32
raybellis May 8, 2023
bfb6490
fix dangling pointer error
raybellis May 8, 2023
ecbd1e6
Merge pull request #771 from raybellis/macos_fixes
Gadgetoid May 9, 2023
092fbe4
Merge pull request #748 from Quitsoon/patch-1
Gadgetoid May 9, 2023
1c39da4
Merge pull request #746 from mutatrum/main
Gadgetoid May 9, 2023
653090c
Exposed support for GPIO pins on encoder wheel
ZodiusInfuser May 10, 2023
05cad0c
Ulab: Bump to 6.0.12.
Gadgetoid May 10, 2023
89699fd
Merge pull request #773 from pimoroni/ulab/bump-6.0.12
Gadgetoid May 10, 2023
12e38c1
Implemented GPIO MP support for Encoder wheel
ZodiusInfuser May 10, 2023
0120975
Readme improvements
ZodiusInfuser May 10, 2023
d00185d
Added C & MP interrupt example
ZodiusInfuser May 10, 2023
5b31e01
Possible ghosting fix for Cosmic
MichaelBell Apr 26, 2023
ec205fb
Merge pull request #775 from MichaelBell/cosmic-ghost-fix
Gadgetoid May 12, 2023
8648196
Merge pull request #774 from pimoroni/breakout_encoder_wheel
Gadgetoid May 12, 2023
652de85
Tufty 2040: RGB565 DMA display update.
Gadgetoid May 12, 2023
00d1617
Merge pull request #777 from pimoroni/patch-st7789-parallel-dma
Gadgetoid May 12, 2023
5061ccf
Interstate75: add build with ulab
ned-pcs Apr 21, 2023
721ee45
Update micropython.yml
ned-pcs Apr 21, 2023
b554b16
Renamed cmake file
ned-pcs Apr 21, 2023
b401e01
WIP: trying to get build to work
ned-pcs May 8, 2023
77ee834
WIP: adding hub75, etc.
ned-pcs May 9, 2023
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
98 changes: 47 additions & 51 deletions .github/workflows/micropython.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
types: [created]

env:
MICROPYTHON_VERSION: 38e7b842c6bc8122753cbf0845eb141f28fbcb72
MICROPYTHON_VERSION: v1.20.0

jobs:
deps:
Expand All @@ -19,9 +19,9 @@ jobs:
uses: actions/cache@v3
with:
path: ${{runner.workspace}}
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}-with-libs
key: workspace-micropython-${{env.MICROPYTHON_VERSION}}-nano-specs
restore-keys: |
workspace-micropython-${{env.MICROPYTHON_VERSION}}-with-libs
workspace-micropython-${{env.MICROPYTHON_VERSION}}-nano-specs

# Check out MicroPython
- name: Checkout MicroPython
Expand All @@ -41,17 +41,17 @@ jobs:
repository: micropython/micropython-lib
path: micropython-lib

- name: Fetch base MicroPython submodules
- name: Fetch Pico submodules
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
working-directory: micropython
run: git submodule update --init

- name: Fetch Pico SDK submodules
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
working-directory: micropython/lib/pico-sdk
run: git submodule update --init
working-directory: micropython/ports/rp2
run: |
git submodule update --init ../../lib/pico-sdk
git submodule update --init ../../lib/cyw43-driver
git submodule update --init ../../lib/lwip
git submodule update --init ../../lib/mbedtls
git submodule update --init ../../lib/micropython-lib
git submodule update --init ../../lib/tinyusb

- name: Build mpy-cross
if: steps.cache.outputs.cache-hit != 'true'
Expand All @@ -68,29 +68,8 @@ jobs:
include:
- name: pico
board: PICO
- name: picow
board: PICO_W
- name: tiny2040
board: PIMORONI_TINY2040
- name: picolipo_4mb
board: PIMORONI_PICOLIPO_4MB
- name: picolipo_16mb
board: PIMORONI_PICOLIPO_16MB
- name: tufty2040
board: PIMORONI_TUFTY2040
local_board_dir: true
- name: enviro
board: PICO_W_ENVIRO
local_board_dir: true
patch: true
- name: galactic_unicorn
board: PICO_W
- name: cosmic_unicorn
board: PICO_W
- name: inky_frame
board: PICO_W_INKY
local_board_dir: true
patch: true
- name: interstate75_ulab
board: PICO

env:
# MicroPython version will be contained in github.event.release.tag_name for releases
Expand Down Expand Up @@ -125,55 +104,72 @@ jobs:
with:
submodules: true
path: pimoroni-pico-${{ github.sha }}

- name: Set MicroPython Version Env Vars
shell: bash
run: |
echo "MICROPY_GIT_TAG=$MICROPYTHON_VERSION, ${{matrix.name}} ${{github.event.release.tag_name || github.sha}}" >> $GITHUB_ENV
echo "MICROPY_GIT_HASH=$MICROPYTHON_VERSION-${{github.event.release.tag_name || github.sha}}" >> $GITHUB_ENV

- name: "HACK: Clean ports/rp2/modules and ports/rp2/CMakeLists.txt"
shell: bash
working-directory: micropython/ports/rp2
run: |
rm -rf modules
git checkout modules

- name: "HACK: Revert Patches" # Avoid an already-patched MicroPython tree breaking our build
shell: bash
working-directory: micropython
run: |
git checkout lib/pico-sdk
git checkout ports/rp2/CMakeLists.txt

- name: "HACK: CMakeLists.txt Disable C++ Exceptions Patch"
shell: bash
working-directory: micropython
run: git apply $GITHUB_WORKSPACE/pimoroni-pico-${{ github.sha }}/micropython/micropython_nano_specs.patch

- name: "HACK: Pico SDK Patch"
if: matrix.patch == true
shell: bash
working-directory: micropython
run: |
$GITHUB_WORKSPACE/pimoroni-pico-${{ github.sha }}/micropython/board/pico-sdk-patch.sh ${{matrix.board}}

- name: Configure MicroPython (Local Board Dir)
if: matrix.local_board_dir == true
shell: bash
working-directory: micropython/ports/rp2
run: |
cmake -S . -B build-${{matrix.board}} -DPICO_BUILD_DOCS=0 -DUSER_C_MODULES=${{env.USER_C_MODULES}} -DMICROPY_BOARD_DIR=${{env.MICROPY_BOARD_DIR}} -DMICROPY_BOARD=${{matrix.board}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache

- name: Configure MicroPython (Upstream Board Dir)
if: matrix.local_board_dir != true
- name: Configure MicroPython
shell: bash
working-directory: micropython/ports/rp2
run: |
cmake -S . -B build-${{matrix.board}} -DPICO_BUILD_DOCS=0 -DUSER_C_MODULES=${{env.USER_C_MODULES}} -DMICROPY_BOARD=${{matrix.board}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Build MicroPython
cmake -S . -B build-${{matrix.name}} -DPICO_BUILD_DOCS=0 -DUSER_C_MODULES=${{env.USER_C_MODULES}} -DMICROPY_BOARD_DIR=${{env.MICROPY_BOARD_DIR}} -DMICROPY_BOARD=${{matrix.board}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache

- name: Build MicroPython # Multiple simultaneous jobs trigger https://github.com/pimoroni/pimoroni-pico/issues/761
shell: bash
working-directory: micropython/ports/rp2
run: |
ccache --zero-stats || true
cmake --build build-${{matrix.board}} -j 2
cmake --build build-${{matrix.name}} -j 1
ccache --show-stats || true

- name: Rename .uf2 for artifact
shell: bash
working-directory: micropython/ports/rp2/build-${{matrix.board}}
working-directory: micropython/ports/rp2/build-${{matrix.name}}
run: |
cp firmware.uf2 $RELEASE_FILE.uf2

- name: Store .uf2 as artifact
uses: actions/upload-artifact@v3
with:
name: ${{env.RELEASE_FILE}}.uf2
path: micropython/ports/rp2/build-${{matrix.board}}/${{env.RELEASE_FILE}}.uf2
path: micropython/ports/rp2/build-${{matrix.name}}/${{env.RELEASE_FILE}}.uf2

- name: Upload .uf2
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
asset_path: micropython/ports/rp2/build-${{matrix.board}}/firmware.uf2
asset_path: micropython/ports/rp2/build-${{matrix.name}}/firmware.uf2
upload_url: ${{github.event.release.upload_url}}
asset_name: ${{env.RELEASE_FILE}}.uf2
asset_content_type: application/octet-stream
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ add_subdirectory(drivers)
add_subdirectory(libraries)

# Example Pico Pack projects
add_subdirectory(examples)
# add_subdirectory(examples)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ We also maintain a C++/CMake boilerplate with GitHub workflows configured for te
* MICS6814 - Gas Sensor - https://shop.pimoroni.com/products/mics6814-gas-sensor-breakout
* RGB Potentiometer - https://shop.pimoroni.com/products/rgb-potentiometer-breakout
* RGB Encoder - https://shop.pimoroni.com/products/rgb-encoder-breakout
* RGB Encoder Wheel - https://shop.pimoroni.com/products/rgb-encoder-wheel-breakout
* IO Expander - https://shop.pimoroni.com/products/io-expander
* RV3028 - Real-Time Clock (RTC) - https://shop.pimoroni.com/products/rv3028-real-time-clock-rtc-breakout
* ST7735 - 0.96" LCD - https://shop.pimoroni.com/products/0-96-spi-colour-lcd-160x80-breakout
Expand Down
84 changes: 69 additions & 15 deletions drivers/ioexpander/ioexpander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,21 @@ namespace pimoroni {
Pin::adc(1, 7, 0)}
{}

bool IOExpander::init(bool skipChipIdCheck) {
bool succeeded = true;
bool IOExpander::init(bool skipChipIdCheck, bool perform_reset) {
if(!skipChipIdCheck) {
uint16_t chip_id = get_chip_id();
if(chip_id != CHIP_ID) {
if(debug) {
printf("Chip ID invalid: %04x expected: %04x\n", chip_id, CHIP_ID);
}
return false;
}
}

// Reset the chip if requested, to put it into a known state
if(perform_reset && !reset()) {
return false;
}

if(interrupt != PIN_UNUSED) {
gpio_set_function(interrupt, GPIO_FUNC_SIO);
Expand All @@ -331,17 +344,36 @@ namespace pimoroni {
enable_interrupt_out(true);
}

if(!skipChipIdCheck) {
uint16_t chip_id = get_chip_id();
if(chip_id != CHIP_ID) {
if(debug) {
printf("Chip ID invalid: %04x expected: %04x\n", chip_id, CHIP_ID);
}
succeeded = false;
return true;
}

uint8_t IOExpander::check_reset() {
uint8_t user_flash_reg = reg::USER_FLASH;
uint8_t value;
if(i2c_write_blocking(i2c->get_i2c(), address, &user_flash_reg, 1, false) == PICO_ERROR_GENERIC) {
return 0x00;
}
if(i2c_read_blocking(i2c->get_i2c(), address, (uint8_t *)&value, sizeof(uint8_t), false) == PICO_ERROR_GENERIC) {
return 0x00;
}

return value;
}

bool IOExpander::reset() {
uint32_t start_time = millis();
set_bits(reg::CTRL, ctrl_mask::RESET);
// Wait for a register to read its initialised value
while(check_reset() != 0x78) {
sleep_ms(1);
if(millis() - start_time >= RESET_TIMEOUT_MS) {
if(debug)
printf("Timed out waiting for Reset!");
return false;
}
}

return succeeded;
return true;
}

i2c_inst_t* IOExpander::get_i2c() const {
Expand Down Expand Up @@ -370,7 +402,7 @@ namespace pimoroni {

void IOExpander::set_address(uint8_t address) {
set_bit(reg::CTRL, 4);
i2c->reg_write_uint8(address, reg::ADDR, address);
i2c->reg_write_uint8(this->address, reg::ADDR, address);
this->address = address;
sleep_ms(250); //TODO Handle addr change IOError better
//wait_for_flash()
Expand Down Expand Up @@ -491,13 +523,35 @@ namespace pimoroni {
return divider_good;
}

void IOExpander::set_pwm_period(uint16_t value, bool load) {
void IOExpander::set_pwm_period(uint16_t value, bool load, bool wait_for_load) {
value &= 0xffff;
i2c->reg_write_uint8(address, reg::PWMPL, (uint8_t)(value & 0xff));
i2c->reg_write_uint8(address, reg::PWMPH, (uint8_t)(value >> 8));

if(load)
pwm_load();
pwm_load(wait_for_load);
}

uint16_t IOExpander::set_pwm_frequency(float frequency, bool load, bool wait_for_load) {
uint32_t period = (uint32_t)(CLOCK_FREQ / frequency);
if (period / 128 > MAX_PERIOD) {
return MAX_PERIOD;
}
if (period < 2) {
return 2;
}

uint8_t divider = 1;
while ((period > MAX_PERIOD) && (divider < MAX_DIVIDER)) {
period >>= 1;
divider <<= 1;
}

period = MIN(period, MAX_PERIOD); // Should be unnecessary because of earlier raised errors, but kept in case
set_pwm_control(divider);
set_pwm_period((uint16_t)(period - 1), load, wait_for_load);

return (uint16_t)period;
}

uint8_t IOExpander::get_mode(uint8_t pin) {
Expand Down Expand Up @@ -669,7 +723,7 @@ namespace pimoroni {
}
}

void IOExpander::output(uint8_t pin, uint16_t value, bool load) {
void IOExpander::output(uint8_t pin, uint16_t value, bool load, bool wait_for_load) {
if(pin < 1 || pin > NUM_PINS) {
printf("Pin should be in range 1-14.");
return;
Expand All @@ -685,7 +739,7 @@ namespace pimoroni {
i2c->reg_write_uint8(address, io_pin.reg_pwml, (uint8_t)(value & 0xff));
i2c->reg_write_uint8(address, io_pin.reg_pwmh, (uint8_t)(value >> 8));
if(load)
pwm_load();
pwm_load(wait_for_load);
}
else {
if(value == LOW) {
Expand Down
18 changes: 15 additions & 3 deletions drivers/ioexpander/ioexpander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace pimoroni {
static const uint8_t PIN_MODE_PWM = 0b00101; // PWM, Output, Push-Pull mode
static const uint8_t PIN_MODE_ADC = 0b01010; // ADC, Input-only (high-impedance)

static const uint32_t RESET_TIMEOUT_MS = 1000;

public:
static const uint8_t DEFAULT_I2C_ADDRESS = 0x18;

Expand All @@ -45,6 +47,10 @@ namespace pimoroni {
static const uint16_t LOW = 0;
static const uint16_t HIGH = 1;

static const uint32_t CLOCK_FREQ = 24000000;
static const uint32_t MAX_PERIOD = (1 << 16) - 1;
static const uint32_t MAX_DIVIDER = (1 << 7);


//--------------------------------------------------
// Subclasses
Expand Down Expand Up @@ -171,7 +177,12 @@ namespace pimoroni {
// Methods
//--------------------------------------------------
public:
bool init(bool skip_chip_id_check = false);
bool init(bool skip_chip_id_check = false, bool perform_reset = false);

private:
uint8_t check_reset();
public:
bool reset();

// For print access in micropython
i2c_inst_t* get_i2c() const;
Expand All @@ -198,15 +209,16 @@ namespace pimoroni {
void pwm_clear(bool wait_for_clear = true);
bool pwm_clearing();
bool set_pwm_control(uint8_t divider);
void set_pwm_period(uint16_t value, bool load = true);
void set_pwm_period(uint16_t value, bool load = true, bool wait_for_load = true);
uint16_t set_pwm_frequency(float frequency, bool load = true, bool wait_for_load = true);

uint8_t get_mode(uint8_t pin);
void set_mode(uint8_t pin, uint8_t mode, bool schmitt_trigger = false, bool invert = false);

int16_t input(uint8_t pin, uint32_t adc_timeout = 1);
float input_as_voltage(uint8_t pin, uint32_t adc_timeout = 1);

void output(uint8_t pin, uint16_t value, bool load = true);
void output(uint8_t pin, uint16_t value, bool load = true, bool wait_for_load = true);

void setup_rotary_encoder(uint8_t channel, uint8_t pin_a, uint8_t pin_b, uint8_t pin_c = 0, bool count_microsteps = false);
int16_t read_rotary_encoder(uint8_t channel);
Expand Down
6 changes: 3 additions & 3 deletions drivers/ltp305/ltp305.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ namespace pimoroni {
}

void LTP305::set_character(uint8_t x, uint16_t ch) {
uint8_t *data = nullptr;
for(auto c : dotfont) {
const uint8_t *data = nullptr;
for(const auto& c : dotfont) {
if(c.code == ch) {
data = &c.data[0];
break;
Expand Down Expand Up @@ -128,4 +128,4 @@ namespace pimoroni {
i2c->reg_write_uint8(address, CMD_BRIGHTNESS, brightness);
i2c->reg_write_uint8(address, CMD_UPDATE, 0x01);
}
}
}
Loading