Oops...first had to google for the meaning 'bitbanging'...
So...Yes, my code is bitbanging!
Wasn't aware of this term, just started coding with ( in this case ) the single NRZ protocol AND my scope next to me.
BUT...to get the 'electrical One or Zero I'm using:
( in this case I have ledbars, each 8xRGB, so 192 bit )
procedure writeLogicOne(pinNr:byte);
var
byCntr: byte;
begin
sio.gpio_set := 1 shl pinNr; // 800
for byCntr:= 0 to 4 do; // = 720
sio.gpio_clr := 1 shl pinNr; // 400
for byCntr:= 0 to 1 do; // = 420
end; // p\writeLogicOne
procedure writeLogicZero(pinNr: byte);
var
byCntr: byte;
begin
sio.gpio_set := 1 shl pinNr; // 400
for byCntr:= 0 to 1 do; // = 320
sio.gpio_clr := 1 shl pinNr; // 800
for byCntr:= 0 to 4 do; // = 820
end; // p\writeLogicZero
procedure doLEDwrite(pinNR: byte);
var
byCntrBIT: byte;
begin
for byCntrBIT:= 0 to 191 do
begin
if (lightBL[byCntrBIT] = true ) then writeLogicOne(pinLightBR)
else writeLogicZero(pinLightBR);
end;
for byCntrBIT:= 0 to 191 do
begin
if (lightBL[byCntrBIT] = true ) then writeLogicOne(pinlightBL)
else writeLogicZero(pinLightBL);
end;
end; // p\
BE AWARE of the fOLLOWING:The timing is NOT ONLY determed by the
for byCntr:= 0 to 1 and
for byCntr:= 0 to 4 do; but by the whole 'process' above'.
This 'proces' is time-sollid at itself!
Sure, there are multiple ways leading to Rome...
As written before, just jumped into 'pascal for pico' and this
way of setting/resetting an output pin is new for me.
I'm used to this: portA.4:= 1 (or 0 ) instead of sio.gpio_set/clr 'thing'
I'm using this array method, cause between ( refreshrate ) writing a bunch of ws2812b, there's is plenty of time
to calcutale/determen and placing the 24bits for each led in the array.
Multiple led arrays can be used, if eachr strip/bar has difference colourvariations/patterns.
To get an idea:
f_bit = 800kHz
T_bit = 1.25us
T_led = 24 x 1.25 = 30us
f_led = 1/30us = 33k33Hz
When suggestions ( assembly? ) about setting resetting output bit, please commecnt!
Kind regards.