hzeller / rpi-rgb-led-matrix

Controlling up to three chains of 64x64, 32x32, 16x32 or similar RGB LED displays using Raspberry Pi GPIO
GNU General Public License v2.0
3.7k stars 1.17k forks source link

P10 Outdoor Panel 1/4 Scan Problem. #529

Closed dl2ocb closed 6 years ago

dl2ocb commented 6 years ago

Hello,

i got some of this nice P10 Outdoor Panels too.

They are 1/4 Scan Panels and i inserted the Code for the P10 Transformation provided by VolkerGoeschl (many many Thanks).

My HW-Config is a Raspberry Pi 3 with the active Adapter for 3 Chains and 1 Panel connected for testing.

I tested the demo Application after inserting the following Line into it:

... Upper Code .... if (rotation > 0) { matrix->ApplyStaticTransformer(RotateTransformer(rotation)); }

// INSERTED by DL2OCB -------------------------------------------------- matrix->ApplyStaticTransformer(P10outdoorTransformer()); //------------------------------------------------------------------------------------

printf("Size: %dx%d. Hardware gpio mapping: %s\n", matrix->width(), matrix->height(), matrix_options.hardware_mapping); ... more Code ....

If i got it right, this should transform the Matrix to be displayed the rigth way on an 1/4 Scan P10 Panel.

I used this commandline:

sudo ./demo -D3 --led-rows=8 --led-chain=4

The Output of the Panel looked like this:

img_20180223_190230_resized_20180223_070540360

I dont know what went wrong ... @hzeller can you give me a hint please ?

I also tried the --led-multiplex=4 Option without success.

I can provide you a Panel for testing if you need.

Many thanks for the nice Lib !!

dl2ocb commented 6 years ago

With this Code i got this: https://www.youtube.com/watch?v=Tz9S7Wzy13w

I changed this: options.multiplexing =2 options.row_address_type =2


import time

number_of_rows = 16 
number_of_panels = 1
parallel =1 
number_of_columns = 32

def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing =2 
    options.row_address_type =2 
    options.brightness = 50 
    options.rows = number_of_rows
    options.cols = number_of_columns
    options.chain_length = number_of_panels
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode = 1
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options

options = rgbmatrix_options()
display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue):
    scan_rate = number_of_rows / 4
    new_x = ((x / (number_of_columns/4)) * (number_of_columns/2)) + (x % (number_of_columns/4))
    if y & scan_rate == 0:
        new_x += number_of_columns/4
        new_y = ((y / (number_of_rows/2)) * scan_rate) + (y % scan_rate)
        display.SetPixel(new_x, new_y, red, green, blue)

for x in range(0, number_of_columns * number_of_panels):
    for y in range(0, number_of_rows * parallel):
        transformer(x, y, 0, 255, 0)
        time.sleep(0.1)
OhmResistance commented 6 years ago

used your code and got a slightly different output: https://youtu.be/hUMNfH5TPKk

angelogoncalve commented 6 years ago

I forgot to tell to try this options my friends in rows an chain_length to work.

from rgbmatrix import RGBMatrix, RGBMatrixOptions import time

number_of_rows = 16 number_of_panels = 1 parallel = 1 number_of_columns = 32

def rgbmatrix_options(): options = RGBMatrixOptions() options.multiplexing = 0 options.row_address_type = 0 options.brightness = 100 options.rows = number_of_rows/2 options.cols = number_of_columns options.chain_length = 2*number_of_panels options.parallel = parallel options.hardware_mapping = 'adafruit-hat' options.inverse_colors = False options.led_rgb_sequence = "RGB" options.gpio_slowdown = 4 options.pwm_lsb_nanoseconds = 130 options.show_refresh_rate = 0 options.disable_hardware_pulsing = True options.scan_mode = 1 options.pwm_bits = 1 options.daemon = 0 options.drop_privileges = 0 return options

options = rgbmatrix_options() display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue): scan_rate = number_of_rows / 4

new_x = ((x / (number_of_columns/4)) (number_of_columns/2)) + (x % (number_of_columns/4)) if y & scan_rate == 0: (4 spaces)new_x += number_of_columns/4 new_y = ((y / (number_of_rows/2)) scan_rate) + (y % scan_rate) display.SetPixel(new_x, new_y, red, green, blue)

for x in range(0, number_of_columns number_of_panels): for y in range(0, number_of_rows parallel): transformer(x, y, 0, 255, 0) time.sleep(1)

angelogoncalve commented 6 years ago

I forgot to tell to try this options my friends with another transformer in rows an chain_length to work also.

from rgbmatrix import RGBMatrix, RGBMatrixOptions import time

number_of_rows = 16 number_of_panels = 1 parallel = 1 number_of_columns = 32

def rgbmatrix_options(): options = RGBMatrixOptions() options.multiplexing = 0 options.row_address_type = 0 options.brightness = 100 options.rows = number_of_rows/2 options.cols = number_of_columns options.chain_length = 2*number_of_panels options.parallel = parallel options.hardware_mapping = 'adafruit-hat' options.inverse_colors = False options.led_rgb_sequence = "RGB" options.gpio_slowdown = 4 options.pwm_lsb_nanoseconds = 130 options.show_refresh_rate = 0 options.disable_hardware_pulsing = True options.scan_mode = 1 options.pwm_bits = 1 options.daemon = 0 options.drop_privileges = 0 return options

options = rgbmatrix_options() display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue): scan_rate = number_of_rows / 4

xoffset = (number_of_columns / 4) (x / (number_of_columns / 4)) yoffset = ((y + scan_rate) % (number_of_rows / 2)) / scan_rate new_x = x + (number_of_columns / 4) yoffset + xoffset new_y = (y % scan_rate) + scan_rate * (y / (number_of_rows / 2)) display.SetPixel(new_x, new_y, red, green, blue)

for x in range(0, number_of_columns number_of_panels): for y in range(0, number_of_rows parallel): transformer(x, y, 0, 255, 0) time.sleep(1)

angelogoncalve commented 6 years ago

Use only one panel 16x32 Dear friend Schuetzirol connected to raspberry to test the last two codes options I send. Thank you my friend and send the two videos to see if it works changing the rows and chain_length options.

OhmResistance commented 6 years ago

The last two codes leave the Panel Black.

angelogoncalve commented 6 years ago

Dear friend Schuetzirol are you using only one panel 16x32?

OhmResistance commented 6 years ago

yes. I think i got 16x16 Pannels. I just connected 2 panels for 16x32. img_20180225_221439

angelogoncalve commented 6 years ago

The one panel 16x16 have another transformer Dear friend Schuetzirol.

from rgbmatrix import RGBMatrix, RGBMatrixOptions import time

number_of_rows = 16 number_of_panels = 1 parallel = 1 number_of_columns = 16

def rgbmatrix_options(): options = RGBMatrixOptions() options.multiplexing = 0 options.row_address_type = 0 options.brightness = 100 options.rows = number_of_rows/2 options.cols = number_of_columns options.chain_length = 2*number_of_panels options.parallel = parallel options.hardware_mapping = 'adafruit-hat' options.inverse_colors = False options.led_rgb_sequence = "RGB" options.gpio_slowdown = 4 options.pwm_lsb_nanoseconds = 130 options.show_refresh_rate = 0 options.disable_hardware_pulsing = True options.scan_mode = 1 options.pwm_bits = 1 options.daemon = 0 options.drop_privileges = 0 return options

options = rgbmatrix_options() display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue): scan_rate = number_of_rows / 2

new_x = ((x / number_of_columns) number_of_columns 2) + (7 - (x % (number_of_columns / 2))) if (x / (number_of_columns / 2)) & 1: new_x += number_of_columns if (y & scan_rate) == 0: new_x += number_of_columns / 2 new_y = ((y / (number_of_rows / 2)) * scan_rate) + (y % scan_rate) display.SetPixel(new_x, new_y, red, green, blue)

for x in range(0, number_of_columns number_of_panels): for y in range(0, number_of_rows parallel): transformer(x, y, 0, 255, 0) time.sleep(1)

OhmResistance commented 6 years ago

this code with 16x16:

from rgbmatrix import RGBMatrix, RGBMatrixOptions
import time

number_of_rows = 16
number_of_panels = 1
parallel = 1
number_of_columns = 16

def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing = 0
    options.row_address_type = 0
    options.brightness = 100
    options.rows = number_of_rows
    options.cols = number_of_columns
    options.chain_length = number_of_panels
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode = 1
    options.pwm_bits = 1
    options.daemon = 0
    options.drop_privileges = 0
    return options

options = rgbmatrix_options()
display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue):
    scan_rate = number_of_rows / 4
    new_x = ((x / (number_of_columns/4)) * (number_of_columns/2)) + (x % (number_of_columns/4))
    if y & scan_rate == 0:
        new_x += number_of_columns/4
        new_y = ((y / (number_of_rows/2)) * scan_rate) + (y % scan_rate)
        display.SetPixel(new_x, new_y, red, green, blue)

for x in range(0, number_of_columns * number_of_panels):
    for y in range(0, number_of_rows * parallel):
        transformer(x, y, 0, 255, 0)
        time.sleep(1)

i get this output: https://youtu.be/DtoryrJB19M

angelogoncalve commented 6 years ago

Use this transformer Dear friend Schuetzirol and the before code I send for one panel 16x16:

def transformer(x, y, red, green, blue): scan_rate = number_of_rows / 2

new_x = ((x / number_of_columns) number_of_columns 2) + (7 - (x % (number_of_columns / 2))) if (x / (number_of_columns / 2)) & 1: new_x += number_of_columns if (y & scan_rate) == 0: new_x += number_of_columns / 2 new_y = ((y / (number_of_rows / 2)) * scan_rate) + (y % scan_rate) display.SetPixel(new_x, new_y, red, green, blue)

dl2ocb commented 6 years ago

@schuetzirol Hi, you used the wrong hardware option ... options.hardware_mapping = 'regular' ... think you need to have the adafruit hat here. I have different HW (The active Hat from @hzeller )

dl2ocb commented 6 years ago

@angelogoncalve This Code:

import time

number_of_rows = 16 
number_of_panels = 1
parallel =1 
number_of_columns = 32

def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing =0 
    options.row_address_type =2 
    options.brightness = 50 
    options.rows = number_of_rows/2
    options.cols = number_of_columns
    options.chain_length = 2*number_of_panels
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode = 1
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options

options = rgbmatrix_options()
display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue):
    scan_rate = number_of_rows / 4
    new_x = ((x / (number_of_columns/4)) * (number_of_columns/2)) + (x % (number_of_columns/4))
    if y & scan_rate == 0:
        new_x += number_of_columns/4
        new_y = ((y / (number_of_rows/2)) * scan_rate) + (y % scan_rate)
        display.SetPixel(new_x, new_y, red, green, blue)

for x in range(0, number_of_columns * number_of_panels):
    for y in range(0, number_of_rows * parallel):
        transformer(x, y, 0, 255, 0)
        time.sleep(0.1)

Output is here:

https://youtu.be/2qHtxi6bwMc

angelogoncalve commented 6 years ago

Try this:

from rgbmatrix import RGBMatrix, RGBMatrixOptions import time

number_of_rows = 16 number_of_panels = 1 parallel = 1 number_of_columns = 32

def rgbmatrix_options(): options = RGBMatrixOptions() options.multiplexing = 0 options.row_address_type = 0 options.brightness = 100 options.rows = number_of_rows/2 options.cols = number_of_columns options.chain_length = 2*number_of_panels options.parallel = parallel options.hardware_mapping = 'adafruit-hat' options.inverse_colors = False options.led_rgb_sequence = "RGB" options.gpio_slowdown = 4 options.pwm_lsb_nanoseconds = 130 options.show_refresh_rate = 0 options.disable_hardware_pulsing = True options.scan_mode = 1 options.pwm_bits = 1 options.daemon = 0 options.drop_privileges = 0 return RGBMatrix(options=options)

display = rgbmatrix_options() height = display.height width = display.width

def transformer(x, y, red, green, blue): scan_rate = number_of_rows / 4

xoffset = (number_of_columns / 4) (x / (number_of_columns / 4)) yoffset = ((y + scan_rate) % (number_of_rows / 2)) / scan_rate new_x = x + (number_of_columns / 4) yoffset + xoffset new_y = (y % scan_rate) + scan_rate * (y / (number_of_rows / 2)) display.SetPixel(new_x, new_y, red, green, blue)

for x in range(0, width): for y in range(0, height): transformer(x, y, 0, 255, 0) time.sleep(1)

dl2ocb commented 6 years ago

Hello @angelogoncalve and @hzeller ... i think that was a step into the right direction.

The Panel fills in Blocks from left to right. But there are two Block (4x4) ahead of the others and the Pixels start to fill from row 5 to 8 then 1-4, 13-16 and last 9-12.

When the first four columns are filled the Pattern looks like this:

   12345678
1  oooo
2  oooo
3  oooo
4  oooo
5      oooo
6      oooo
7      oooo
8      oooo
9  oooo
10 oooo
11 oooo
12 oooo
13      oooo
14      oooo
15      oooo
16      oooo

If all of the tranforming has been setup right the Panel should fill from Top down and column for column to the right direction ... is this right ?? It should look this way:

   1234
1  oooo
2  oooo
3  oooo
4  oooo
5  oooo
6  oooo
7  oooo
8  oooo
9  oooo
10 oooo
11 oooo
12 oooo
13 oooo
14 oooo
15 oooo
16 oooo

This was the Code i used for the Test, i changed the "options.row_address_type = 0" line to "options.row_address_type = 2" because only with this Option i get usefull results.

from rgbmatrix import RGBMatrix, RGBMatrixOptions
import time

number_of_rows = 16 
number_of_panels = 1
parallel =1 
number_of_columns = 32

def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing =0
    options.row_address_type = 2
    options.brightness = 50 
    options.rows = number_of_rows / 2
    options.cols = number_of_columns
    options.chain_length = 2*number_of_panels
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode =0 
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options

options = rgbmatrix_options()
display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue):
    scan_rate = number_of_rows / 4
    xoffset = (number_of_columns / 4) * (x / (number_of_columns / 4))
    yoffset = ((y + scan_rate) % (number_of_rows / 2)) / scan_rate
    new_x = x + (number_of_columns / 4) * yoffset + xoffset
    new_y = (y % scan_rate) + scan_rate * (y / (number_of_rows / 2))
    display.SetPixel(new_x, new_y, red, green, blue)

for x in range(0, number_of_columns * number_of_panels):
    for y in range(0, number_of_rows * parallel):
        transformer(x, y, 0, 255, 0)
        time.sleep(0.05)

Look at the Video of the Result here: https://youtu.be/qOF7UOmbtms

dl2ocb commented 6 years ago

@hzeller I have some problems to implement this Transformer into the multiplexing-transformers. Maybe you can help to implement this into your Framework.

dl2ocb commented 6 years ago

@schuetzirol Is your Panel running the right way now ?

OhmResistance commented 6 years ago

I modified your code a little bit and gets this result:

https://youtu.be/pcL4xM7l5Zg

from rgbmatrix import RGBMatrix, RGBMatrixOptions
import time

number_of_rows = 16 
number_of_panels = 1
parallel = 1
number_of_columns = 16

def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing =0
    options.row_address_type = 0
    options.brightness = 50 
    options.rows = number_of_rows / 2
    options.cols = number_of_columns
    options.chain_length = 2*number_of_panels
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode =0 
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options

options = rgbmatrix_options()
display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue):
    scan_rate = number_of_rows / 4
    xoffset = (number_of_columns / 4) * (x / (number_of_columns / 4))
    yoffset = ((y + scan_rate) % (number_of_rows / 2)) / scan_rate
    new_x = x + (number_of_columns / 4) * yoffset + xoffset
    new_y = (y % scan_rate) + scan_rate * (y / (number_of_rows / 2))
    display.SetPixel(new_x, new_y, red, green, blue)

for x in range(0, number_of_columns * number_of_panels):
    for y in range(0, number_of_rows * parallel):
        transformer(x, y, 0, 255, 0)
        time.sleep(0.05)
hzeller commented 6 years ago

@dl2ocb For ease of implementation, can you have a look at the https://github.com/hzeller/rpi-rgb-led-matrix/tree/pixel-mapper branch ? I am currently working on that branch to make it simpler to define such Transformers, in the future named "PixelMapper".

The new multiplex mappers are defined in lib/multiplex-mappers.cc in that branch, and they are much simpler as you essentially only have to extend a class, implement a single method and then register it with one line in CreateMultiplexMapperList()

dl2ocb commented 6 years ago

@hzeller @angelogoncalve Can you help to get the Transformation for my Panel fixed ? I think there is only a small step to go. I tested around but i didn't get closer to the Goal.

Am i right that the Pixels must light up from top left to bottom right Column by Column ??

@hzeller The PixelMapper thing look really good ... i will try to implement that. MANY Thanks for your Work and please tell me how i can help / donate you.

angelogoncalve commented 6 years ago

Am i right that the Pixels must light up from top left to bottom right Column by Column ?? - Yes you are right this is the correct positions mapping pixels in your panel 16x32.

Try this transformer but with my options:

def transformer(x, y, red, green, blue): scan_rate = number_of_rows / 4 new_x = ((x / (number_of_columns/4)) (number_of_columns/2)) + (x % (number_of_columns/4)) if y & scan_rate == 0: (4 spaces)new_x += number_of_columns/4 new_y = ((y / (number_of_rows/2)) scan_rate) + (y % scan_rate) display.SetPixel(new_x, new_y, red, green, blue)

or this transformer but with my options:

def transformer(x, y, red, green, blue): scan_rate = number_of_rows / 4 xoffset = (number_of_columns / 4) (x / (number_of_columns / 4)) yoffset = (y % (number_of_rows / 2)) / scan_rate new_x = x + (number_of_columns / 4) yoffset + xoffset new_y = (y % scan_rate) + scan_rate * (y / (number_of_rows / 2)) display.SetPixel(new_x, new_y, red, green, blue)

dl2ocb commented 6 years ago

@angelogoncalve Thanks for your help !

Here are the Results of the two Transformers.

First one:

from rgbmatrix import RGBMatrix, RGBMatrixOptions
import time

number_of_rows = 16 
number_of_panels = 1
parallel =1 
number_of_columns = 32

def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing =0
    options.row_address_type = 2
    options.brightness = 50 
    options.rows = number_of_rows / 2
    options.cols = number_of_columns
    options.chain_length = 2*number_of_panels
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode =0 
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options

options = rgbmatrix_options()
display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue):
    scan_rate = number_of_rows / 4
    new_x = ((x / (number_of_columns/4)) * (number_of_columns/2)) + (x % (number_of_columns/4))
    if y & scan_rate == 0:
        new_x += number_of_columns / 4
    new_y = ((y / (number_of_rows/2)) * scan_rate) + (y % scan_rate)
    display.SetPixel(new_x, new_y, red, green, blue)

for x in range(0, number_of_columns * number_of_panels):
    for y in range(0, number_of_rows * parallel):
        transformer(x, y, 0, 255, 0)
        time.sleep(0.1)

Video of the Result: https://youtu.be/Ax_7Wh-3j04

Second one:

import time

number_of_rows = 16 
number_of_panels = 1
parallel =1 
number_of_columns = 32

def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing =0
    options.row_address_type = 2
    options.brightness = 50 
    options.rows = number_of_rows / 2
    options.cols = number_of_columns
    options.chain_length = 2*number_of_panels
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode =0 
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options

options = rgbmatrix_options()
display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue):
    scan_rate = number_of_rows / 4 
    xoffset = (number_of_columns / 4) * (x / (number_of_columns / 4))
    yoffset = (y % (number_of_rows / 2)) / scan_rate
    new_x = x + (number_of_columns / 4) * yoffset + xoffset
    new_y = (y % scan_rate) + scan_rate * (y / (number_of_rows / 2))
    display.SetPixel(new_x, new_y, red, green, blue)

for x in range(0, number_of_columns * number_of_panels):
    for y in range(0, number_of_rows * parallel):
        transformer(x, y, 0, 255, 0)
        time.sleep(0.09)

Video of the Result: https://youtu.be/hqX-1K6IpbI

angelogoncalve commented 6 years ago

Use for both transformers options.row_address_type = 0 to see what happens in the panel 16x32.

dl2ocb commented 6 years ago

@angelogoncalve OK, here we go ...

First Test with this Code:

from rgbmatrix import RGBMatrix, RGBMatrixOptions
import time

number_of_rows = 16 
number_of_panels = 1
parallel =1 
number_of_columns = 32

def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing =0
    options.row_address_type =0
    options.brightness = 50 
    options.rows = number_of_rows / 2
    options.cols = number_of_columns
    options.chain_length = 2*number_of_panels
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode =0 
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options

options = rgbmatrix_options()
display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue):
    scan_rate = number_of_rows / 4
    new_x = ((x / (number_of_columns/4)) * (number_of_columns/2)) + (x % (number_of_columns/4))
    if y & scan_rate == 0:
        new_x += number_of_columns / 4
    new_y = ((y / (number_of_rows/2)) * scan_rate) + (y % scan_rate)
    display.SetPixel(new_x, new_y, red, green, blue)

for x in range(0, number_of_columns * number_of_panels):
    for y in range(0, number_of_rows * parallel):
        transformer(x, y, 0, 255, 0)
        time.sleep(0.1)

Video is here: https://youtu.be/3cXjAh9jOv8

Second Test with this Code:

from rgbmatrix import RGBMatrix, RGBMatrixOptions
import time

number_of_rows = 16 
number_of_panels = 1
parallel =1 
number_of_columns = 32

def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing =0
    options.row_address_type = 0
    options.brightness = 50 
    options.rows = number_of_rows / 2
    options.cols = number_of_columns
    options.chain_length = 2*number_of_panels
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode =0 
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options

options = rgbmatrix_options()
display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue):
    scan_rate = number_of_rows / 4 
    xoffset = (number_of_columns / 4) * (x / (number_of_columns / 4))
    yoffset = (y % (number_of_rows / 2)) / scan_rate
    new_x = x + (number_of_columns / 4) * yoffset + xoffset
    new_y = (y % scan_rate) + scan_rate * (y / (number_of_rows / 2))
    display.SetPixel(new_x, new_y, red, green, blue)

for x in range(0, number_of_columns * number_of_panels):
    for y in range(0, number_of_rows * parallel):
        transformer(x, y, 0, 255, 0)
        time.sleep(0.1)

Video is here: https://youtu.be/7x4bKsI9XEU

vapiper commented 6 years ago

@dl2ocb you have matrix with direct adressing. You'd use options.row_address_type = 2. See #509 Can you make two additional videos without any transform?

for y in range(0, display.height):
    for x in range(0, display.width):
        display.SetPixel(x, y,  128, 128, 128)
        time.sleep(0.5)

First with following parameters:

    options.multiplexing =0
    options.row_address_type = 2
    options.rows = number_of_rows
    options.cols = number_of_columns
    options.chain_length = 1

Second with following parameters:

    options.multiplexing =0
    options.row_address_type = 2
    options.rows = number_of_rows/2
    options.cols = number_of_columns*2
    options.chain_length = 1
dl2ocb commented 6 years ago

@vapiper OK, here are the Tests:

First test:

from rgbmatrix import RGBMatrix, RGBMatrixOptions
import time

number_of_rows = 16 
number_of_panels = 1
parallel =1 
number_of_columns = 32

def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing = 0
    options.row_address_type = 2
    options.brightness = 50 
    options.rows = number_of_rows
    options.cols = number_of_columns
    options.chain_length = 1
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode =0 
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options

options = rgbmatrix_options()
display = RGBMatrix(options=options)

for y in range(0, display.height):
    for x in range(0, display.width):
        display.SetPixel(x, y,  128, 128, 128)
        time.sleep(0.1)

Video: https://youtu.be/HLxnOVvc0vs

Second Test:

from rgbmatrix import RGBMatrix, RGBMatrixOptions
import time

number_of_rows = 16 
number_of_panels = 1
parallel =1 
number_of_columns = 32

def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing = 0
    options.row_address_type = 2
    options.brightness = 50 
    options.rows = number_of_rows / 2
    options.cols = number_of_columns * 2
    options.chain_length = 1
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode =0 
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options

options = rgbmatrix_options()
display = RGBMatrix(options=options)

for y in range(0, display.height):
    for x in range(0, display.width):
        display.SetPixel(x, y,  128, 128, 128)
        time.sleep(0.1)

Video:https://youtu.be/LDXMpCCIrM4

vapiper commented 6 years ago

@dl2ocb The last video is corrupted, but I think the second test is closer to the truth. You can try this:

def transformer(x, y, red, green, blue):
    shift_even_quarter = 0
    shift_odd_quarter = 0
    if ((y / 4) % 2) == 0:
        shift_even_quarter = 4
    else:
        shift_odd_quarter = 4

    mx = x + ((x + shift_even_quarter) / 8) * 8 + shift_odd_quarter
    my = y % 4 + 4 * (y / 8)

    display.SetPixel(mx, my, red, green, blue)

for y in range(0, number_of_rows):
    for x in range(0, number_of_columns):
        transformer(x, y,  128, 128, 128)
        time.sleep(0.1)
dl2ocb commented 6 years ago

@vapiper OK, here is the Result of this Code:

from rgbmatrix import RGBMatrix, RGBMatrixOptions
import time

number_of_rows = 16 
number_of_panels = 1
parallel =1 
number_of_columns = 32

def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing = 0
    options.row_address_type = 2
    options.brightness = 50 
    options.rows = number_of_rows / 2
    options.cols = number_of_columns * 2
    options.chain_length = 1
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode =0 
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options

options = rgbmatrix_options()
display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue):
    shift_even_quarter = 0
    shift_odd_quarter = 0
    if ((y / 4) % 2) == 0:
        shift_even_quarter = 4
    else:
        shift_odd_quarter = 4

    mx = x + ((x + shift_even_quarter) / 8) * 8 + shift_odd_quarter
    my = y % 4 + 4 * (y / 8)

    display.SetPixel(mx, my, red, green, blue)

for y in range(0, number_of_rows):
    for x in range(0, number_of_columns):
        transformer(x, y,  128, 128, 128)
        time.sleep(0.1)

Video:https://youtu.be/434IO9t2NMQ

Is this filling Pattern how it should be ? Or should it fill from upper left Corner to lower right Corner, Column by Column ?

vapiper commented 6 years ago

@dl2ocb At the last video is the correct filling pattern. It is according to the programm.

Let's try to simplify the code:

def transformer(x, y, red, green, blue):
    odd_quarter = ((y / 4) % 2)
    shift_even_quarter = (1 - odd_quarter) * 4
    shift_odd_quarter = ((y / 4) % 2) * 4

    mx = x + ((x + shift_even_quarter) / 8) * 8 + shift_odd_quarter
    my = y % 4 + 4 * (y / 8)

    display.SetPixel(mx, my, red, green, blue)
dl2ocb commented 6 years ago

@vapiper OK this transformer does the same as the one before, so its OK.

vapiper commented 6 years ago

Nice, Now you have the transformer for your matrix. Can you take a photo of the back of the matrix?

dl2ocb commented 6 years ago

OK, i started to implement it into the Code like this (old style, not Pixelmapper):

In multiplex-transformers.cc:

 /********************************/
/* My New Transformer Canvas */
/********************************/

class P10outdoorTransformer::TransformCanvas : public BasicMultiplexCanvas {
public:
  TransformCanvas(int panel_rows, int panel_cols) : BasicMultiplexCanvas(panel_rows, panel_cols) {}

  void SetDelegatee(Canvas* delegatee);

  virtual void Clear();
  virtual void Fill(uint8_t red, uint8_t green, uint8_t blue);
  virtual int width() const;
  virtual int height() const;
  virtual void SetPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue);

private:
  Canvas *delegatee_;
};

void P10outdoorTransformer::TransformCanvas::SetDelegatee(Canvas* delegatee) {
  delegatee_ = delegatee;
}

void P10outdoorTransformer::TransformCanvas::Clear() {
  delegatee_->Clear();
}

void P10outdoorTransformer::TransformCanvas::Fill(uint8_t red, uint8_t green, uint8_t blue) {
  delegatee_->Fill(red, green, blue) /* add any necessary transform of color here */;
}

int P10outdoorTransformer::TransformCanvas::width() const {
  return delegatee_->width()  /* add any necessary transform of width here */;
}

int P10outdoorTransformer::TransformCanvas::height() const {
  return delegatee_->height() /* add any necessary transform of height here */;
}

void P10outdoorTransformer::TransformCanvas::SetPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue) {
  int display_new_x;
  int display_new_y;

  int odd_quarter = ((y / 4) % 2);
  int shift_even_quarter = (1 - odd_quarter) * 4;
  int shift_odd_quarter = ((y / 4) % 2) * 4;

  display_new_x = x + ((x + shift_even_quarter) / 8) * 8 + shift_odd_quarter;
  display_new_y = y % 4 + 4 * (y / 8);

return delegatee_->SetPixel(display_new_x, display_new_y, red, green, blue);

}

P10outdoorTransformer::P10outdoorTransformer(int panel_rows, int panel_cols)
  : canvas_(new TransformCanvas(panel_rows, panel_cols)) {
}

P10outdoorTransformer::~P10outdoorTransformer() {
  delete canvas_;
}

Canvas *P10outdoorTransformer::Transform(Canvas *output) {
  assert(output != NULL);

  canvas_->SetDelegatee(output);
  return canvas_;
}

In multiplex-transformers-internal.h:

// P10Outdoor Transformer for 1/4 scan Panels.
//

class P10outdoorTransformer : public CanvasTransformer {
public:
  P10outdoorTransformer(int panel_rows, int panel_cols);
  virtual ~P10outdoorTransformer();

  virtual Canvas *Transform(Canvas *output);

private:
  class TransformCanvas;

  TransformCanvas *const canvas_;
};

And in the options-initialize.cc added an Option --led-multiplexing=5

In led-matrix.cc:

  switch (params_.multiplexing) {
  case 1:
    ApplyStaticTransformer(internal::StripeTransformer(params_.rows * 2,
                                                       params_.cols / 2));
    break;
  case 2:
    ApplyStaticTransformer(internal::CheckeredTransformer(params_.rows * 2,
                                                          params_.cols / 2));
    break;
  case 3:
    ApplyStaticTransformer(internal::SpiralTransformer(params_.rows * 2,
                                                       params_.cols / 2));
    break;
  case 4:
    ApplyStaticTransformer(internal::ZStripeTransformer(params_.rows * 2,
                                                        params_.cols / 2));
    break;
  case 5:
    ApplyStaticTransformer(internal::P10outdoorTransformer(params_.rows * 2,params_.cols / 2));
   break;
  }

Anything else todo ??

vapiper commented 6 years ago

Using the MultiplexMapper class is easier then CanvasTransformer . You'd add code in only one place.

dl2ocb commented 6 years ago

@hzeller @angelogoncalve @vapiper @schuetzirol Final Video ... MANY Thanks for your Help !!!

@hzeller Maybe you can add this Transformer to your Codebase.

vapiper commented 6 years ago

Can you take a photo of the back of the matrix?

dl2ocb commented 6 years ago

@vapiper Here are the Pictures of the Backside of the Panel:

img_20180302_125007_resized_20180302_125500674 img_20180302_125026_resized_20180302_125459998 img_20180302_125003_resized_20180302_125459266 img_20180302_125019_resized_20180302_125458448

OhmResistance commented 6 years ago

hey @dl2ocb i tryed your code with little changes.

from rgbmatrix import RGBMatrix, RGBMatrixOptions
import time

number_of_rows = 16 
number_of_panels = 1
parallel =1 
number_of_columns = 16

def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing = 0
    options.row_address_type = 0
    options.brightness = 50 
    options.rows = number_of_rows / 2
    options.cols = number_of_columns * 2
    options.chain_length = 1
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode =0 
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options

options = rgbmatrix_options()
display = RGBMatrix(options=options)

def transformer(x, y, red, green, blue):
    shift_even_quarter = 0
    shift_odd_quarter = 0
    if ((y / 4) % 2) == 0:
        shift_even_quarter = 4
    else:
        shift_odd_quarter = 4

    mx = x + ((x + shift_even_quarter) / 8) * 8 + shift_odd_quarter
    my = y % 4 + 4 * (y / 8)

    display.SetPixel(mx, my, red, green, blue)

for y in range(0, number_of_rows):
    for x in range(0, number_of_columns):
        transformer(x, y,  128, 128, 128)
        time.sleep(0.1)

but I got this result, would be very nice if you can have a look at it. https://youtu.be/RpXMVdCVrZw

vapiper commented 6 years ago

@dl2ocb Can you test the new MultiplexMapper at the branch pixel-mapper?

dl2ocb commented 6 years ago

@vapiper Yes i'll try it as soon as i can. Ttyl.

angelogoncalve commented 6 years ago

Dear Dl2ocB in the multiplex-transformers.cc you need to put this wright? Thank you for your help my friend.

int P10outdoorTransformer::TransformCanvas::width() const { return delegatee_->width() / 2 / add any necessary transform of width here /; }

int P10outdoorTransformer::TransformCanvas::height() const { return delegatee_->height() 2 / add any necessary transform of height here */; }

dl2ocb commented 6 years ago

@angelogoncalve Yes thats right.

angelogoncalve commented 6 years ago

With the factor number multiplication for the with() function and the divide number factor for the height() function wright Dear Dl2ocb? Thank you for your attention.

OhmResistance commented 6 years ago

How do i use the new MultiplexMapper, pixelmapper ?

hzeller commented 6 years ago

It is not documented yet, hence it is in the separate branch @schuetzirol - but if you look at the code, it is pretty self-explanatory; the relevant part is in multiplex-mappers.cc. From the user point-of-view, nothing changed, the multiplexing can be still be selected with --led-multiplexing=xx

hzeller commented 6 years ago

FYI, the pixel-mapper branch is now merged into master. So just a plain checkout witll get you there.

hzeller commented 6 years ago

Looks like this is fixed ?

Thuba18 commented 3 years ago

I can't run it, is this the library? even though the circuit is the same. please help me set the position for NTP clock and date in one panel p10 rgb 16x32 1/4 scan

davemaster commented 3 years ago

Greetings

share your options and your circuit/pinout

Thuba18 commented 3 years ago

Greetings

share your options and your circuit/pinout

include

include

include

include

define DHTPIN D3 //GPIO-0 D3 pin of nodemcu

define DHTTYPE DHT11 // DHT 11

include "Arduino.h"

WiFiClient client; DHT dht(DHTPIN, DHTTYPE);

include "Adafruit_GFX.h"

include

include

include "PxMatrix.h"

include

Ticker display_ticker;

define P_LAT D0

define P_A D1

define P_B D2

define P_C D8

define P_CLK D5

define P_OE D4

define P_R1 D7

// Pins for LED MATRIX

define matrix_width 32

define matrix_height 16

//JAM const char ssid = "thubatatto"; const char password = "12345678"; const long utcOffsetInSeconds = 76060; char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

//TANGGAL String months[12]={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

// Define NTP Client to get time WiFiUDP ntpUDP; NTPClient timeClient(ntpUDP, "asia.pool.ntp.org", utcOffsetInSeconds);

// This defines the 'on' time of the display is us. The larger this number, // the brighter the display. If too large the ESP will crash // uint8_t display_draw_time=10; //10-50 is usually fine

//PxMATRIX display(matrix_width,matrix_height,P_LAT, P_OE,P_A,P_B,P_C); PxMATRIX display(32, 16,P_LAT, P_OE,P_A,P_B,P_C,P_CLK,P_R1); //PxMATRIX display(64,64,P_LAT, P_OE,P_A,P_B,P_C,P_D,P_E);

// Some standard colors uint16_t myRED = display.color565(255, 0, 0); uint16_t myGREEN = display.color565(0, 255, 0); uint16_t myBLUE = display.color565(0, 0, 255); uint16_t myWHITE = display.color565(255, 255, 255); uint16_t myYELLOW = display.color565(255, 255, 0); uint16_t myCYAN = display.color565(0, 255, 255); uint16_t myMAGENTA = display.color565(255, 0, 255); uint16_t myBLACK = display.color565(255, 255, 255);

uint16_t myCOLORS[8]={myRED,myGREEN,myBLUE,myWHITE,myYELLOW,myCYAN,myMAGENTA,myBLACK};

uint8_t display_draw_time=10; //10-50 is usually fine

ifdef ESP8266

// ISR for display refresh void display_updater() { display.display(display_draw_time); }

endif

void display_update_enable(bool is_enable) {

ifdef ESP8266

if (is_enable) display_ticker.attach(0.002, display_updater); else display_ticker.detach();

endif

}

void setup() { Serial.begin(115200); // Define your display layout here, e.g. 1/8 step display.begin(4);

display.setCursor(1,1); display.println("connecting"); WiFi.begin(ssid, password); while ( WiFi.status() != WL_CONNECTED ) { delay ( 500 ); Serial.print ( "." ); }

timeClient.begin(); // Set offset time in seconds to adjust for your timezone, for example: // GMT +1 = 3600 // GMT +8 = 28800 // GMT -1 = -3600 // GMT 0 = 0 timeClient.setTimeOffset(25200);

dht.begin(); dht.readTemperature(); dht.readHumidity();

}

void loop() { display.clearDisplay(); timeClient.update(); display.setCursor(0,0); display.fillRect(1, 1, 4, 4, display.color565(0, 0, 0)); display.setFont(&kongtext4pt7b); Serial.print(daysOfTheWeek[timeClient.getDay()]); Serial.print(", "); Serial.print(timeClient.getHours()); Serial.print(":"); Serial.print(timeClient.getMinutes()); Serial.print(":"); Serial.println(timeClient.getSeconds()); //Serial.println(timeClient.getFormattedTime());

delay(1000);

//TANGGAL unsigned long epochTime = timeClient.getEpochTime(); //Get a time structure struct tm ptm = gmtime ((time_t )&epochTime);

int monthDay = ptm->tm_mday; // Serial.print("Month day: "); // Serial.println(monthDay);

int currentMonth = ptm->tm_mon+1; // Serial.print("Month: "); // Serial.println(currentMonth);

String currentMonthName = months[currentMonth-1]; // Serial.print("Month name: "); // Serial.println(currentMonthName);

int currentYear = ptm->tm_year+1900; // Serial.print("Year: "); // Serial.println(currentYear);

//Print complete date: String currentDate = String(monthDay) + "/" + String(currentMonth) + "/" + String(currentYear); Serial.print("Current date: "); Serial.println(currentDate);

Serial.println("");

delay(2000);

//SUHU float h = dht.readHumidity(); float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); return; } Serial.print("Kelembaban udara = "); Serial.print(dht.readHumidity()); Serial.print("% "); Serial.print("Suhu = "); Serial.print(dht.readTemperature()); Serial.println(" C "); delay(2000);

}

Thuba18 commented 3 years ago

I want to be like @greatproject's project but I'm using p10 rgb 16x32 1/4scan