Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8015

SDK • Header defined value in PIO

$
0
0
Is it possible to use a value defined in a header in a PIO program?

I've been playing around with the TM1637 7-segment display and wrote a PIO program that can drive 1-4 displays.
To make it happen, I use the OUT, SET, and IN instructions (out pindirs #). If I understood correctly, the number of bits to shift depends on the number of pins. So, for example, if I have just one display, then I should write

Code:

out pindirs 1
but if I have 4, then it's

Code:

out pindirs 4
I can add a define to the pio program and then use the defined value elsewhere

Code:

.define (PUBLIC) SEGMENTS 4
But can I do the inverse and define the value somewhere else?
Or should it be done in some other way? Such as having 4 identical programs for 4 different numbers of displays?

Statistics: Posted by SREG_SFR — Thu Aug 07, 2025 11:07 am



Viewing all articles
Browse latest Browse all 8015

Trending Articles