One for the PIO gurus


Author Message
AlbertR
Senior Member

Joined: 29/05/2025
Location: Germany
Posts: 111
Posted: 12:12pm 04 Nov 2025      

Hallo Peter,

very nice. Your program inspired me to change a few things about my PIOs. Thank you for that.

I don't know anything about VGA, but since the color signals are analog, some kind of “PWM” should work to reduce the number of RGB-pins.

I changed the output part of PIO 1


...
Pull side 1 'get the next data - don't block
Out pins,6 side 1 [9]
Out pins,6 side 1 [9]
Out pins,6 side 1 [9]
Out pins,6 side 1 [9]
Out pins,6 side 1 [7]
Out null,2
...


to


...
Pull side 1 'get the next data - don't block
Out pins,3 side 1 [2]
Out pins,3 side 1 [6]
Out pins,3 side 1 [2]
Out pins,3 side 1 [6]
Out pins,3 side 1 [2]
Out pins,3 side 1 [6]
Out pins,3 side 1 [2]
Out pins,3 side 1 [6]
Out pins,3 side 1 [2]
Out pins,3 side 1 [4]
Out null,2
..


and add a function to arrange the colors

Function RGB222(R%,B%,G%) As integer
Local res%                                 '-1 because bit1 already shifted
  res% =        ((R% And 1)<<0)+((R% And 2)<<2)
  res% = res% Or((G% And 1)<<1)+((G% And 2)<<3)
  res% = res% Or((B% And 1)<<2)+((B% And 2)<<4)
  RGB222 = res%
End Function


The output is shown here. If both bits of an color are set it is ok, but it not I got a kind of of floating in the printposition. It looks like a diff of 5 pixel, that means one "pull". Could there be a lack of synchronization here?



output of:

mycls rgb222(0,0,0) '&H03
rectangle   1, 10,100,100,rgb222(3,0,0)
rectangle 101, 10,200,100,rgb222(2,0,0)
rectangle 201, 10,300,100,rgb222(1,0,0)

rectangle   1,110,100,200,rgb222(0,3,0)
rectangle 101,110,200,200,rgb222(0,2,0)
rectangle 201,110,300,200,rgb222(0,1,0)

rectangle   1,210,100,300,rgb222(0,0,3)
rectangle 101,210,200,300,rgb222(0,0,2)
rectangle 201,210,300,300,rgb222(0,0,1)

rectangle   1,310,100,400,rgb222(3,3,3)
rectangle 101,310,200,400,rgb222(2,2,2)
rectangle 201,310,300,400,rgb222(1,1,1)

rectangle 315, 10,414,100,rgb222(3,3,0)
rectangle 415, 10,514,100,rgb222(2,2,0)
rectangle 515, 10,614,100,rgb222(1,1,0)

rectangle 315,110,414,200,rgb222(0,3,3)
rectangle 415,110,514,200,rgb222(0,2,2)
rectangle 515,110,614,200,rgb222(0,1,1)

rectangle 315,210,414,300,rgb222(3,0,3)
rectangle 415,210,514,300,rgb222(2,0,2)
rectangle 515,210,614,300,rgb222(1,0,1)

rectangle 315,310,414,400,rgb222(3,2,1)
rectangle 415,310,514,400,rgb222(2,3,2)
rectangle 515,310,614,400,rgb222(1,1,3)

rectangle 5,614,7,634,rgb222(3,0,0)

printstring "red---+_|>@",  1,405,3,RGB222(3,0,0),-1
printstring "green-+_|>@",300,410,2,RGB222(0,3,0),-1
printstring "blue--+_|>@",500,420,1,RGB222(0,0,3),-1
printstring "blue--+_|>@",500,430,1,RGB222(0,0,2),-1
printstring "blue--+_|>@",500,440,1,RGB222(0,0,1),-1  


Albert
Edited 2025-11-04 22:48 by AlbertR