Merge pull request #457 from pimoroni/patch-picow-memory-issues

Pico Scroll/Unicorn: Fix static memory alloc for Pico W.
This commit is contained in:
Philip Howard 2022-07-22 14:55:28 +01:00 committed by GitHub
commit 5f19bbdeb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 54 additions and 54 deletions

View File

@ -63,7 +63,7 @@ jobs:
env:
# MicroPython version will be contained in github.event.release.tag_name for releases
RELEASE_FILE: pimoroni-${{matrix.name}}-${{github.event.release.tag_name || github.sha}}-micropython.uf2
RELEASE_FILE: pimoroni-${{matrix.name}}-${{github.event.release.tag_name || github.sha}}-micropython
steps:
- name: Compiler Cache
@ -86,16 +86,7 @@ jobs:
- name: Install Compiler & CCache
if: runner.os == 'Linux'
run: |
sudo apt update && sudo apt install ccache
- name: Install ARM Toolchain
if: runner.os == 'Linux'
working-directory: ${{runner.workspace}}
run: |
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
tar xf gcc-*.tar.bz2
cd gcc*/bin
pwd >> $GITHUB_PATH
sudo apt update && sudo apt install ccache gcc-arm-none-eabi
- uses: actions/checkout@v2
with:
@ -125,13 +116,21 @@ jobs:
- name: Rename .uf2 for artifact
shell: bash
working-directory: micropython/ports/rp2/build-${{matrix.board}}
run: cp firmware.uf2 $RELEASE_FILE
run: |
cp firmware.uf2 $RELEASE_FILE.uf2
cp firmware.elf $RELEASE_FILE.elf
- name: Store .uf2 as artifact
uses: actions/upload-artifact@v2
with:
name: ${{env.RELEASE_FILE}}
path: micropython/ports/rp2/build-${{matrix.board}}/${{env.RELEASE_FILE}}
name: ${{env.RELEASE_FILE}}.uf2
path: micropython/ports/rp2/build-${{matrix.board}}/${{env.RELEASE_FILE}}.uf2
- name: Store .elf as artifact
uses: actions/upload-artifact@v2
with:
name: ${{env.RELEASE_FILE}}.elf
path: micropython/ports/rp2/build-${{matrix.board}}/${{env.RELEASE_FILE}}.elf
- name: Upload .uf2
if: github.event_name == 'release'
@ -141,5 +140,5 @@ jobs:
with:
asset_path: micropython/ports/rp2/build-${{matrix.board}}/firmware.uf2
upload_url: ${{github.event.release.upload_url}}
asset_name: ${{env.RELEASE_FILE}}
asset_name: ${{env.RELEASE_FILE}}.uf2
asset_content_type: application/octet-stream

View File

@ -76,7 +76,7 @@ namespace pimoroni {
return to_ms_since_boot(get_absolute_time());
}
constexpr uint8_t GAMMA[256] = {
constexpr uint8_t GAMMA_8BIT[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5,
@ -94,6 +94,26 @@ namespace pimoroni {
191, 193, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220,
222, 224, 227, 229, 231, 233, 235, 237, 239, 241, 244, 246, 248, 250, 252, 255};
/* Moved from pico_unicorn.cpp
v = (uint16_t)(powf((float)(n) / 255.0f, 2.2) * 16383.0f + 0.5f) */
constexpr uint16_t GAMMA_14BIT[256] = {
0, 0, 0, 1, 2, 3, 4, 6, 8, 10, 13, 16, 20, 23, 28, 32,
37, 42, 48, 54, 61, 67, 75, 82, 90, 99, 108, 117, 127, 137, 148, 159,
170, 182, 195, 207, 221, 234, 249, 263, 278, 294, 310, 326, 343, 361, 379, 397,
416, 435, 455, 475, 496, 517, 539, 561, 583, 607, 630, 654, 679, 704, 730, 756,
783, 810, 838, 866, 894, 924, 953, 983, 1014, 1045, 1077, 1110, 1142, 1176, 1210, 1244,
1279, 1314, 1350, 1387, 1424, 1461, 1499, 1538, 1577, 1617, 1657, 1698, 1739, 1781, 1823, 1866,
1910, 1954, 1998, 2044, 2089, 2136, 2182, 2230, 2278, 2326, 2375, 2425, 2475, 2525, 2577, 2629,
2681, 2734, 2787, 2841, 2896, 2951, 3007, 3063, 3120, 3178, 3236, 3295, 3354, 3414, 3474, 3535,
3596, 3658, 3721, 3784, 3848, 3913, 3978, 4043, 4110, 4176, 4244, 4312, 4380, 4449, 4519, 4589,
4660, 4732, 4804, 4876, 4950, 5024, 5098, 5173, 5249, 5325, 5402, 5479, 5557, 5636, 5715, 5795,
5876, 5957, 6039, 6121, 6204, 6287, 6372, 6456, 6542, 6628, 6714, 6801, 6889, 6978, 7067, 7156,
7247, 7337, 7429, 7521, 7614, 7707, 7801, 7896, 7991, 8087, 8183, 8281, 8378, 8477, 8576, 8675,
8775, 8876, 8978, 9080, 9183, 9286, 9390, 9495, 9600, 9706, 9812, 9920, 10027, 10136, 10245, 10355,
10465, 10576, 10688, 10800, 10913, 11027, 11141, 11256, 11371, 11487, 11604, 11721, 11840, 11958, 12078, 12198,
12318, 12440, 12562, 12684, 12807, 12931, 13056, 13181, 13307, 13433, 13561, 13688, 13817, 13946, 14076, 14206,
14337, 14469, 14602, 14735, 14868, 15003, 15138, 15273, 15410, 15547, 15685, 15823, 15962, 16102, 16242, 16383};
struct pin_pair {
union {
uint8_t first;

View File

@ -81,7 +81,7 @@ namespace pimoroni {
}
void IS31FL3731::set(uint8_t index, uint8_t brightness) {
buf[index + 1] = pimoroni::GAMMA[brightness];
buf[index + 1] = pimoroni::GAMMA_8BIT[brightness];
}
void IS31FL3731::update(uint8_t frame) {

View File

@ -99,9 +99,9 @@ void APA102::set_hsv(uint32_t index, float h, float s, float v) {
void APA102::set_rgb(uint32_t index, uint8_t r, uint8_t g, uint8_t b, bool gamma) {
if(gamma) {
r = pimoroni::GAMMA[r];
g = pimoroni::GAMMA[g];
b = pimoroni::GAMMA[b];
r = pimoroni::GAMMA_8BIT[r];
g = pimoroni::GAMMA_8BIT[g];
b = pimoroni::GAMMA_8BIT[b];
}
buffer[index].rgb(r, g, b);
}

View File

@ -87,10 +87,10 @@ void WS2812::set_hsv(uint32_t index, float h, float s, float v, uint8_t w) {
void WS2812::set_rgb(uint32_t index, uint8_t r, uint8_t g, uint8_t b, uint8_t w, bool gamma) {
if(gamma) {
r = pimoroni::GAMMA[r];
g = pimoroni::GAMMA[g];
b = pimoroni::GAMMA[b];
w = pimoroni::GAMMA[w];
r = pimoroni::GAMMA_8BIT[r];
g = pimoroni::GAMMA_8BIT[g];
b = pimoroni::GAMMA_8BIT[b];
w = pimoroni::GAMMA_8BIT[w];
}
switch(color_order) {
case COLOR_ORDER::RGB:

View File

@ -34,9 +34,9 @@ namespace pimoroni {
}
void RGBLED::update_pwm() {
uint16_t r16 = GAMMA[led_r];
uint16_t g16 = GAMMA[led_g];
uint16_t b16 = GAMMA[led_b];
uint16_t r16 = GAMMA_8BIT[led_r];
uint16_t g16 = GAMMA_8BIT[led_g];
uint16_t b16 = GAMMA_8BIT[led_b];
r16 *= led_brightness;
g16 *= led_brightness;
b16 *= led_brightness;

View File

@ -1,7 +1,7 @@
#include "pico_scroll_font.hpp"
/* static font data */
static unsigned char __bitmap[256][5] = {
static const unsigned char __bitmap[256][5] = {
{0x0, 0x0, 0x8, 0x0, 0x0}, {0x0, 0x10, 0x0, 0x4, 0x0},
{0x0, 0x10, 0x8, 0x4, 0x0}, {0x0, 0x14, 0x0, 0x14, 0x0},
{0x0, 0x14, 0x8, 0x14, 0x0}, {0x0, 0x1c, 0x0, 0x1c, 0x0},
@ -137,7 +137,7 @@ int render_text(const char *text, unsigned int nchr, unsigned char *buffer, unsi
// TODO check nbfr >= 6 * nchr
for (unsigned int i = 0; i < nchr; i++) {
unsigned char *symbol = __bitmap[(unsigned int)text[i]];
const unsigned char *symbol = __bitmap[(unsigned int)text[i]];
for (unsigned int j = 0; j < 5; j++) {
buffer[i * 6 + j] = symbol[j];
}

View File

@ -1,7 +1,6 @@
#include <math.h>
#include "hardware/dma.h"
#include "hardware/irq.h"
#include "common/pimoroni_common.hpp"
#include "pico_unicorn.pio.h"
#include "pico_unicorn.hpp"
@ -53,10 +52,6 @@ constexpr uint32_t BITSTREAM_LENGTH = (ROW_COUNT * ROW_BYTES * BCD_FRAMES);
// must be aligned for 32bit dma transfer
alignas(4) static uint8_t bitstream[BITSTREAM_LENGTH] = {0};
static uint16_t r_gamma_lut[256] = {0};
static uint16_t g_gamma_lut[256] = {0};
static uint16_t b_gamma_lut[256] = {0};
static uint32_t dma_channel;
static inline void unicorn_jetpack_program_init(PIO pio, uint sm, uint offset) {
@ -139,20 +134,6 @@ namespace pimoroni {
gpio_init(pin::ROW_5); gpio_set_dir(pin::ROW_5, GPIO_OUT);
gpio_init(pin::ROW_6); gpio_set_dir(pin::ROW_6, GPIO_OUT);
// create 14-bit gamma luts
for(uint16_t v = 0; v < 256; v++) {
// gamma correct the provided 0-255 brightness value onto a
// 0-65535 range for the pwm counter
float r_gamma = 2.8f;
r_gamma_lut[v] = (uint16_t)(powf((float)(v) / 255.0f, r_gamma) * 16383.0f + 0.5f);
float g_gamma = 2.8f;
g_gamma_lut[v] = (uint16_t)(powf((float)(v) / 255.0f, g_gamma) * 16383.0f + 0.5f);
float b_gamma = 2.8f;
b_gamma_lut[v] = (uint16_t)(powf((float)(v) / 255.0f, b_gamma) * 16383.0f + 0.5f);
}
// initialise the bcd timing values and row selects in the bitstream
for(uint8_t row = 0; row < HEIGHT; row++) {
for(uint8_t frame = 0; frame < BCD_FRAMES; frame++) {
@ -254,9 +235,9 @@ namespace pimoroni {
uint8_t shift = x % 2 == 0 ? 0 : 4;
uint8_t nibble_mask = 0b00001111 << shift;
uint16_t gr = r_gamma_lut[r];
uint16_t gg = g_gamma_lut[g];
uint16_t gb = b_gamma_lut[b];
uint16_t gr = pimoroni::GAMMA_14BIT[r];
uint16_t gg = pimoroni::GAMMA_14BIT[g];
uint16_t gb = pimoroni::GAMMA_14BIT[b];
// set the appropriate bits in the separate bcd frames
for(uint8_t frame = 0; frame < BCD_FRAMES; frame++) {

View File

@ -49,8 +49,8 @@ include(plasma/micropython)
include(hub75/micropython)
# Packs
# include(pico_unicorn/micropython) # 2408 bytes RAM
# include(pico_scroll/micropython) # 1284 bytes RAM
include(pico_unicorn/micropython)
include(pico_scroll/micropython)
include(pico_rgb_keypad/micropython)
# Servos & Motors