Skip to content

Commit 0c1aa87

Browse files
authored
Merge branch 'pimoroni:main' into main
2 parents 0f0d12f + 3b03a30 commit 0c1aa87

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1126
-147
lines changed

.github/workflows/cmake.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ on:
77
env:
88
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
99
BUILD_TYPE: Release
10+
PICO_SDK_VERSION: 2.0.0
1011

1112
jobs:
1213
build:
1314
name: ${{matrix.name}} (C++)
14-
runs-on: ubuntu-20.04
15+
runs-on: ubuntu-latest
1516
strategy:
1617
matrix:
1718
include:
@@ -43,6 +44,7 @@ jobs:
4344
uses: actions/checkout@v4
4445
with:
4546
repository: raspberrypi/pico-sdk
47+
ref: ${{ env.PICO_SDK_VERSION }}
4648
path: pico-sdk
4749
submodules: true
4850

@@ -54,11 +56,15 @@ jobs:
5456
path: pico-extras
5557
submodules: false # lwip breaks audio submodule fetching
5658

59+
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
60+
uses: carlosperate/arm-none-eabi-gcc-action@v1
61+
with:
62+
release: '13.3.Rel1'
63+
5764
# Linux deps
5865
- name: Install deps
59-
if: runner.os == 'Linux'
6066
run: |
61-
sudo apt update && sudo apt install ccache gcc-arm-none-eabi
67+
sudo apt update && sudo apt install ccache
6268
6369
- name: Create Build Environment
6470
run: cmake -E make_directory ${{runner.workspace}}/build

.github/workflows/micropython.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
jobs:
1313
build:
1414
name: ${{ matrix.name }} (${{ matrix.board }})
15-
runs-on: ubuntu-20.04
15+
runs-on: ubuntu-latest
1616
continue-on-error: true
1717
strategy:
1818
matrix:
@@ -71,7 +71,7 @@ jobs:
7171
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
7272
uses: carlosperate/arm-none-eabi-gcc-action@v1
7373
with:
74-
release: '9-2020-q2'
74+
release: '13.3.Rel1'
7575

7676
- name: Install CCache
7777
run: |
@@ -95,12 +95,6 @@ jobs:
9595
source $BUILD_TOOLS
9696
micropython_build_mpy_cross
9797
98-
- name: "HACK: CMakeLists.txt Disable C++ Exceptions Patch"
99-
shell: bash
100-
run: |
101-
source $BUILD_TOOLS
102-
hack_patch_micropython_disable_exceptions
103-
10498
- name: "HACK: Pico SDK Patch"
10599
shell: bash
106100
run: |

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ We also maintain a C++/CMake boilerplate with GitHub workflows configured for te
8080
* Pico Unicorn Pack - https://shop.pimoroni.com/products/pico-unicorn-pack
8181
* Pico Audio Pack (C++ only) - https://shop.pimoroni.com/products/pico-audio-pack
8282
* Pico Wireless Pack - https://shop.pimoroni.com/products/pico-wireless-pack
83-
* Pico Display 2.0 - https://shop.pimoroni.com/products/pico-display-pack-2-0
83+
* Pico Display 2.0" - https://shop.pimoroni.com/products/pico-display-pack-2-0
8484
* Pico Enviro+ Pack - https://shop.pimoroni.com/products/pico-enviro-pack
8585
* Pico Inky Pack - https://shop.pimoroni.com/products/pico-inky-pack
8686
* Pico GFX Pack - https://shop.pimoroni.com/products/pico-gfx-pack
87+
* Pico Display 2.8" - https://shop.pimoroni.com/products/pico-display-pack-2-8
8788

8889
## SHIMs
8990

@@ -145,6 +146,7 @@ We also maintain a C++/CMake boilerplate with GitHub workflows configured for te
145146
* SCD41 CO2 Sensor (Carbon Dioxide / Temperature / Humidity) - https://shop.pimoroni.com/products/scd41-co2-sensor-breakout
146147
* VL53L5CX 8x8 Time of Flight Array Sensor - https://shop.pimoroni.com/products/vl53l5cx-time-of-flight-tof-sensor-breakout
147148
* RGB Encoder Wheel - https://shop.pimoroni.com/products/rgb-encoder-wheel-breakout
149+
* AS7343 14-Channel Multi-Spectral Sensor Breakout - https://shop.pimoroni.com/products/as7343-breakout
148150

149151
## Kits
150152

ci/micropython.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ function micropython_version {
4545
echo "MICROPY_GIT_HASH=$MICROPYTHON_VERSION-$TAG_OR_SHA" >> $GITHUB_ENV
4646
}
4747

48-
function hack_patch_micropython_disable_exceptions {
49-
cd micropython
50-
git apply $PIMORONI_PICO_DIR/micropython/micropython_nano_specs.patch
51-
cd ../
52-
}
53-
5448
function hack_patch_pico_sdk {
5549
# pico-sdk-patch.sh will apply the patch if it exists
5650
cd micropython

drivers/as7343/as7343.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace pimoroni {
3030
i2c->set_bits(address, reg::FIFO_MAP, 0, FIFO_MAP_CH5 | FIFO_MAP_CH4 | FIFO_MAP_CH3 | FIFO_MAP_CH2 | FIFO_MAP_CH1 | FIFO_MAP_CH0 | FIFO_MAP_ASTATUS);
3131

3232
// Set the PON bit
33-
i2c->reg_write_uint8(address, reg::ENABLE, ENABLE_WEN | ENABLE_SMUXEN | ENABLE_SP_EN | ENABLE_PON);
33+
i2c->reg_write_uint8(address, reg::ENABLE, ENABLE_WEN | ENABLE_SP_EN | ENABLE_PON);
3434

3535
return true;
3636
}
@@ -135,10 +135,23 @@ namespace pimoroni {
135135
}
136136
}
137137

138+
void AS7343::start_measurement() {
139+
if(running) return;
140+
i2c->set_bits(address, reg::ENABLE, 0, ENABLE_SMUXEN);
141+
running = true;
142+
}
143+
144+
void AS7343::stop_measurement() {
145+
i2c->set_bits(address, reg::ENABLE, 0, ENABLE_SMUXEN);
146+
running = false;
147+
}
148+
138149
void AS7343::read_fifo(uint16_t *buf) {
139150
uint16_t expected_results = read_cycles * 7;
140151
uint16_t result_slot = 0;
141152

153+
start_measurement();
154+
142155
while (i2c->reg_read_uint8(address, reg::FIFO_LVL) < expected_results) {
143156
sleep_ms(1);
144157
}

drivers/as7343/as7343.hpp

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,36 +49,68 @@ namespace pimoroni {
4949
public:
5050
struct reading {
5151
// Cycle 1
52+
uint16_t c1_astatus = 0; // (c1_astatus >> 8) & 0b10001111
53+
// 0b10000000 = saturated
54+
// 0b00001111 = gain lowest nibble
5255
uint16_t FZ = 0; // 428-480 nm
5356
uint16_t FY = 0; // 534-593 nm
5457
uint16_t FXL = 0; // 593-628 nm
5558
uint16_t NIR = 0; // 849-903 nm
5659

5760
uint16_t c1_vis_tl = 0; // Visible top-left
5861
uint16_t c1_vis_br = 0; // Visible bottom-right
59-
uint16_t c1_astatus = 0; // (c1_astatus >> 8) & 0b10001111
60-
// 0b10000000 = saturated
61-
// 0b00001111 = gain lowest nibble
62+
//uint16_t c1_fd = 0; // This is where flicker detect *would* be
6263

6364
// Cycle 2
65+
uint16_t c2_astatus = 0;
6466
uint16_t F2 = 0; // 408-448 nm
6567
uint16_t F3 = 0; // 448-500 mn
6668
uint16_t F4 = 0; // 500-534 nm
6769
uint16_t F6 = 0; // 618-665 nm
6870

6971
uint16_t c2_vis_tl = 0;
7072
uint16_t c2_vis_br = 0;
71-
uint16_t c2_astatus = 0;
73+
//uint16_t c2_fd = 0;
7274

7375
// Cycle 3
76+
uint16_t c3_astatus = 0;
7477
uint16_t F1 = 0; // 396-408 nm
75-
uint16_t F5 = 0; // 531-594 nm
7678
uint16_t F7 = 0; // 685-715 nm
7779
uint16_t F8 = 0; // 715-766 nm
80+
uint16_t F5 = 0; // 531-594 nm
7881

7982
uint16_t c3_vis_tl = 0;
8083
uint16_t c3_vis_br = 0;
81-
uint16_t c3_astatus = 0;
84+
//uint16_t c3_fd = 0;
85+
86+
float gain(uint8_t cycle) {
87+
uint8_t status = 0;
88+
switch(cycle) {
89+
case 1:
90+
status = c1_astatus & 0xf;
91+
break;
92+
case 2:
93+
status = c2_astatus & 0xf;
94+
break;
95+
case 3:
96+
status = c3_astatus & 0xf;
97+
break;
98+
}
99+
return status ? 1 << (status - 1) : 0.5f;
100+
}
101+
102+
bool saturated(uint8_t cycle) {
103+
switch(cycle) {
104+
case 1:
105+
return c1_astatus & 0x80;
106+
case 2:
107+
return c2_astatus & 0x80;
108+
case 3:
109+
return c3_astatus & 0x80;
110+
default:
111+
return false;
112+
}
113+
}
82114
};
83115

84116

@@ -95,6 +127,8 @@ namespace pimoroni {
95127
uint8_t read_cycles = 1;
96128
uint8_t ch_count = (uint8_t)channel_count::SIX_CHANNEL;
97129

130+
bool running = false;
131+
98132

99133
//--------------------------------------------------
100134
// Constructors/Destructor
@@ -120,6 +154,9 @@ namespace pimoroni {
120154

121155
void get_version(uint8_t &auxid, uint8_t &revid, uint8_t &hwid);
122156

157+
void start_measurement();
158+
void stop_measurement();
159+
123160
reading read();
124161

125162
void read_fifo(uint16_t *buf);

drivers/pcf85063a/pcf85063a.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#include "hardware/i2c.h"
4-
#include "hardware/rtc.h"
4+
#include "pico/types.h"
55

66
#include "common/pimoroni_common.hpp"
77
#include "common/pimoroni_i2c.hpp"

drivers/psram_display/psram_display.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ namespace pimoroni {
9292

9393
int __not_in_flash_func(SpiSetBlocking)(const uint16_t uSrc, size_t uLen)
9494
{
95-
invalid_params_if(SPI, 0 > (int)uLen);
9695
// Deliberately overflow FIFO, then clean up afterward, to minimise amount
9796
// of APB polling required per halfword
9897
for (size_t i = 0; i < uLen; ++i) {

drivers/pwm/pwm_cluster.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ uint8_t PWMCluster::claimed_sms[] = { 0x0, 0x0 };
2525
uint PWMCluster::pio_program_offset = 0;
2626

2727

28-
PWMCluster::PWMCluster(PIO pio, uint sm, uint pin_mask, bool loading_zone)
28+
PWMCluster::PWMCluster(PIO pio, uint sm, uint64_t pin_mask, bool loading_zone)
2929
: pio(pio)
3030
, sm(sm)
31-
, pin_mask(pin_mask & ((1u << NUM_BANK0_GPIOS) - 1))
31+
, pin_mask(pin_mask & ((1llu << NUM_BANK0_GPIOS) - 1))
3232
, channel_count(0)
3333
, wrap_level(0)
3434
, loading_zone(loading_zone) {

drivers/pwm/pwm_cluster.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ namespace pimoroni {
103103
PIO pio;
104104
uint sm;
105105
int dma_channel;
106-
uint pin_mask;
106+
uint64_t pin_mask;
107107
uint8_t channel_count;
108108
ChannelState channels[NUM_BANK0_GPIOS];
109109
uint8_t channel_to_pin_map[NUM_BANK0_GPIOS];
@@ -135,7 +135,7 @@ namespace pimoroni {
135135
// Constructors/Destructor
136136
//--------------------------------------------------
137137
public:
138-
PWMCluster(PIO pio, uint sm, uint pin_mask, bool loading_zone = DEFAULT_USE_LOADING_ZONE);
138+
PWMCluster(PIO pio, uint sm, uint64_t pin_mask, bool loading_zone = DEFAULT_USE_LOADING_ZONE);
139139
PWMCluster(PIO pio, uint sm, uint pin_base, uint pin_count, bool loading_zone = DEFAULT_USE_LOADING_ZONE);
140140
PWMCluster(PIO pio, uint sm, const uint8_t *pins, uint32_t length, bool loading_zone = DEFAULT_USE_LOADING_ZONE);
141141
PWMCluster(PIO pio, uint sm, std::initializer_list<uint8_t> pins, bool loading_zone = DEFAULT_USE_LOADING_ZONE);

0 commit comments

Comments
 (0)