Skip to content

Commit d870d2d

Browse files
committed
avoid conflicts in global variable names
1 parent 34c0608 commit d870d2d

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/dmd_interface.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
#include "hardware/pio.h"
2525

2626
// Derive divider from current clock so PIO runs at ~125 MHz reference
27-
uint32_t sys_hz = clock_get_hz(clk_sys); // e.g. 125/200/266 MHz
28-
float target_hz = 125000000.0f; // PIO code designed for 125 MHz
29-
float divider = (float)sys_hz / target_hz; // scales automatically
27+
float dmd_interface_clk_divider =
28+
(float)(clock_get_hz(clk_sys)) / 125000000.0f; // scales automatically
3029

3130
// Init the DMD reader (dots) PIO program, common for all DMD types.
3231
void dmd_reader_program_init(PIO pio, uint sm, uint offset, pio_sm_config c,
@@ -65,7 +64,7 @@ void dmd_reader_program_init(PIO pio, uint sm, uint offset, pio_sm_config c,
6564
);
6665

6766
// Make sure we run this sm with a 125MHz clk
68-
sm_config_set_clkdiv(&c, divider);
67+
sm_config_set_clkdiv(&c, dmd_interface_clk_divider);
6968

7069
// Load our configuration, do not yet start the program
7170
pio_sm_init(pio, sm, offset, &c);
@@ -93,7 +92,7 @@ void dmd_framedetect_program_init(PIO pio, uint sm, uint offset,
9392
0);
9493

9594
// Make sure we run this sm with a 125MHz clk
96-
sm_config_set_clkdiv(&c, divider);
95+
sm_config_set_clkdiv(&c, dmd_interface_clk_divider);
9796

9897
// Load our configuration, do not yet start the program
9998
pio_sm_init(pio, sm, offset, &c);

src/dmdreader.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ uint16_t source_planehistoryperframe;
8282
uint16_t source_dwordsperframe;
8383
uint16_t source_bytesperframe;
8484
uint16_t source_lineoversampling;
85-
uint16_t source_mergeplanes;
8685
uint16_t source_dwordsperline;
86+
uint16_t source_mergeplanes;
8787
uint16_t offset[MAX_PLANESPERFRAME];
8888

8989
static uint8_t *alloc_aligned_buffer(size_t size, size_t alignment,
@@ -647,6 +647,9 @@ void dmd_dma_handler() {
647647
// and 1/0/0/0 are present. If an illegal pattern occures for a pixel, the
648648
// planes are out of sync and need to be shifted and no further check is
649649
// required for this frame.
650+
// It seems to be sufficient to check every 8th pixel for these patterns to
651+
// detect sync. So we could avoid bitschifiting of the uint32_t value to
652+
// check every single pixel.
650653
if (dmd_type >= DMD_CAPCOM && !locked_in && !plane0_shifted) {
651654
digitalWrite(LED_BUILTIN, HIGH);
652655
uint8_t value = pixval & 0x0F;
@@ -674,7 +677,7 @@ void dmd_dma_handler() {
674677
(value == 2 && ((planebuf[px] & 0x0F) == 1 ||
675678
planebuf[offset[2] + px] & 0x0F) == 1)) {
676679
// An unsynchronized has been found.
677-
// Disable the SM, clean the DMA channel and restart.
680+
// Disable the state machine, clean the DMA channel and restart.
678681
// As a result, we will skip exactly one plane.
679682
pio_sm_set_enabled(dmd_pio, dmd_sm, false);
680683
dmd_dma_reset();

0 commit comments

Comments
 (0)