Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
default_envs = rp2040

[env:rp2040]
platform = https://github.com/maxgerhardt/platform-raspberrypi#79ce473e1a8010ed8096388690222fd2c94858a6
platform = https://github.com/maxgerhardt/platform-raspberrypi/archive/5d4561a05e3b212660ac6fdd3fbfb328d1988aa1.tar.gz
framework = arduino
board = pico
board_build.core = earlephilhower
board_build.filesystem_size = 0.5m

[env:rp2350]
platform = https://github.com/maxgerhardt/platform-raspberrypi#79ce473e1a8010ed8096388690222fd2c94858a6
platform = https://github.com/maxgerhardt/platform-raspberrypi/archive/5d4561a05e3b212660ac6fdd3fbfb328d1988aa1.tar.gz
framework = arduino
board = rpipico2
board_build.core = earlephilhower
Expand Down
19 changes: 10 additions & 9 deletions src/dmdreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ typedef struct __attribute__((__packed__)) block_pix_header_t {
uint16_t padding; // padding bits
} block_pix_header_t __attribute__((aligned(4)));

block_header_t h = {};
block_pix_header_t ph = {};

DmdType dmd_type;

// Line oversampling
Expand Down Expand Up @@ -257,15 +260,6 @@ void spi_clean_exit() {
* @param pixbuf a frame to send
*/
bool spi_send_pix(uint8_t *pixbuf, bool skip_when_busy) {
block_header_t h = {.block_type = SPI_BLOCK_PIX};
block_pix_header_t ph = {};

// round length to 4-byte blocks
h.len = (((target_bytes + 3) / 4) * 4) + sizeof(h) + sizeof(ph);
ph.columns = source_width;
ph.rows = source_height;
ph.bitsperpixel = target_bitsperpixel;

if (skip_when_busy) {
if (spi_busy()) return false;
}
Expand Down Expand Up @@ -1564,6 +1558,13 @@ void dmdreader_spi_init() {
pinMode(SPI0_CS, OUTPUT);
digitalWrite(SPI0_CS, LOW);

// Set up SPI header
h.len = (((target_bytes + 3) / 4) * 4) + sizeof(h) + sizeof(ph);
h.block_type = SPI_BLOCK_PIX;
ph.columns = source_width;
ph.rows = source_height;
ph.bitsperpixel = target_bitsperpixel;

// initialize SPI slave PIO
dmdreader_error_blink(pio_claim_free_sm_and_add_program_for_gpio_range(
&clocked_output_program, &spi_pio, &spi_sm, &spi_offset, SPI_BASE, 4,
Expand Down
Loading