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.71k stars 1.17k forks source link

panel P6 32x32 outdoor 1/8 scan rate - mapping pixels wrigth transform #445

Closed angelogoncalve closed 6 years ago

angelogoncalve commented 6 years ago

Hello people. I nedd to have the wrigth transform for mapping pixels a panel P6 32x32 outdoor 1/8 scan rate.

I think I need to change trasnsformer.cc file in the UArrangementTransformer but I do not get the wright transformation for the pixels.

In below is the transformation for a panel 16x32 with a scan rate 1:4:

void UArrangementTransformer::TransformCanvas::SetPixel( int x, int y, uint8_t red, uint8_t green, uint8_t blue) { int new_x = 0; int new_y = 0; if (y < 4 || (y > 7 && y < 12)) { new_x = (x -1) + (24 ((x / 8) + 1)) - 17; new_y = y; } else { new_x = x + (8 * ((x / 8) + 1)); newy = y - 4; } delegatee->SetPixel(new_x, new_y, red, green, blue);

/ if (x < 0 || x >= width || y < 0 || y >= height) return; const int slab_height = 2panelheight; // one folded u-shape const int base_y = (y / slab_height) panelheight; y %= slab_height; if (y < panelheight) { x += delegatee->width() / 2; } else { x = width - x - 1; y = slabheight - y - 1; } delegatee->SetPixel(x, base_y + y, red, green, blue); / }

Can anybody help me please to finish the project for the shchool.

Thank you for your atention.

darknessii commented 6 years ago

hello guys, here I have an ugly code created for my p6 32x32 1/8 panel. it works for me. however, it only works for one --led-parallel=1 and at least 4 panels.

void UArrangementTransformer::TransformCanvas::SetPixel( int x, int y, uint8_t red, uint8_t green, uint8_t blue) {

// Panel SMD3535 RGB OS-P6-32x32-8S

int new_x = 0; int new_y = 0;

if (y <= 7) { new_x = ((x / 16) 32) + (x % 16); if ((y & 8) == 1) { new_x += 16; } new_y = ((y / 16) 8) + (y % 8); }else { if ((y >= 16) && (y <= 23)) { new_x = ((x / 16) 32) + (x % 16); if ((y & 8) == 1) { new_x += 16; } new_y = ((y / 16) 8) + (y % 8); }else { new_x = ((x / 16) 32) + (x % 16); y -= 8; if ((y & 8) == 0) { new_x += 16; } new_y = ((y / 16) 8) + (y % 8); } } delegatee_->SetPixel(new_x, new_y, red, green, blue); }

Example with 2 Panel: (while :; do date +%T ; sleep 0.2 ; done) | sudo ./text-example -f ../fonts/8x13B.bdf -y8 -C140,0,0 --led-rows=16 --led-chain=4 --led-parallel=1 --led-slowdown-gpio=2 --led-pwm-lsb-nanoseconds=200 --led-no-hardware-pulse

darknessii commented 6 years ago

Example with 4x 32x32 Panel U-arrangement (64x64) ./demo -D 0 --led-rows=16 --led-chain=8 --led-parallel=1 --led-slowdown-gpio=2 --led-pwm-lsb-nanoseconds=80 --led-no-hardware-pulse -L

angelogoncalve commented 6 years ago

Hi the transformer for 32x32 panel with scan rate 1:8 can be these ones:

// / P10outdoor Transformer Canvas / // class P10outdoorTransformer::TransformCanvas : public Canvas { public: TransformCanvas() : delegatee_(NULL) {}

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, uint8t blue) { delegatee->Fill(red, green, blue); }

int P10outdoorTransformer::TransformCanvas::width() const { return delegatee_->width() / 2; }

int P10outdoorTransformer::TransformCanvas::height() const { return delegatee_->height() * 2; }

void P10outdoorTransformer::TransformCanvas::SetPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue) { if (x < 0 || x >= width() || y < 0 || y >= height()) return; /int new_x, new_y; new_x = ((x / 32) 64) + (x % 32); if ((y & 8) == 0) { new_x += 32; }
new_y = ((y / 16) 8) + (y % 8);/ //fprintf(stdout, "value of new_x new_y :: %d %d\n ", new_x, new_y);

/int odd8_block =(((y % 16) / 8) +1) % 2; //to know if the pixel is in an odd 8pixel row int num_mod_x = (x / 32); //num of daisy chainned modules int new_x = (x + 32num_mod_x + 32odd8_block); int new_y = (y % 8) + 8 ( y / 16);*/

//The following code converts a 32x32 matrix into a 64x16 matrix for proper display. /int new_x = x; int new_y = y; if (y < 8) new_x = x + 32; else if (y < 16) new_y = y - 8; else if (y < 24) { new_x = x + 32; new_y = y - 8; } else new_y = y - 16;/

//Panel SMD3535 RGB OS-P6-32x32-8S int new_x = 0; int new_y = 0; if (y <= 7) { new_x = ((x / 32) 64) + (x % 32); if ((y & 8) == 0) { new_x += 32; } new_y = ((y / 16) 8) + (y % 8); }else { new_x = ((x / 32) 64) + (x % 32); //y -= 8; if ((y & 8) == 0) { new_x += 32; } new_y = ((y / 16) 8) + (y % 8); } delegatee_->SetPixel(new_x, new_y, red, green, blue); }

// / P10outdoor Transformer / // P10outdoorTransformer::P10outdoorTransformer() : canvas_(new TransformCanvas()) { }

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

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

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

./demo -D 0 --led-rows=16 --led-chain=2 * number of panels --led-parallel=1

angelogoncalve commented 6 years ago

The correct transformer that you send my friend for 32x32 panel with scan rate 1:8 is this:

//Panel SMD3535 RGB OS-P6-32x32-8S int new_x = 0; int new_y = 0; if (y <= 7) { new_x = ((x / 32) 64) + (x % 32); if ((y & 8) == 0) { new_x += 32; } new_y = ((y / 16) 8) + (y % 8); } else { if ((y >= 16) && (y <= 23)) { new_x = ((x / 32) 64) + (x % 32); new_y = y - 8; if ((y & 8) == 0) { new_x += 32; } new_y = ((y / 16) 8) + (y % 8); } else { new_x = ((x / 32) 64) + (x % 32); if ((y & 8) == 0) { new_x += 32; } new_y = ((y / 16) 8) + (y % 8); } } delegatee_->SetPixel(new_x, new_y, red, green, blue);

hzeller commented 6 years ago

Please check out the new option --led-multiplexing https://github.com/hzeller/rpi-rgb-led-matrix#multiplexing It does the mapping built into the library (and can also be used from Python.) (You need to do a fresh checkout and compile, this just went in).

lukasmalkmus commented 6 years ago

Can confirm. The new multiplexing options fixed my issue with the same display. I'm not talking in behalf of the issue author but I think this can be closed. @hzeller @angelogoncalve

darknessii commented 6 years ago

The --led-multiplexing option does not work for me.

Only my Transfomset works fine. i did some optimisation.

void UArrangementTransformer::TransformCanvas::SetPixel( int x, int y, uint8_t red, uint8_t green, uint8_t blue) {

int new_x = 0; int new_y = 0;

//Panel SMD3535 RGB OS-P6-32x32-8S if ((y <= 7) || ((y >= 16) && (y <= 23)) || ((y >= 32) && (y <= 39)) || ((y >= 48) && (y <= 55))) { new_x = ((x / 16) 32) + (x % 16); if ((y & 8) == 1) { new_x += 16; } new_y = ((y / 16) 8) + (y % 8); }else { new_x = ((x / 16) 32) + (x % 16); y -= 8; if ((y & 8) == 0) { new_x += 16; } new_y = ((y / 16) 8) + (y % 8); } delegatee_->SetPixel(new_x, new_y, red, green, blue); }

sudo ./examples-api-use/demo -D 3 --led-rows=16 --led-chain=4 --led-parallel=2 --led-slowdown-gpio=2 --led-pwm-lsb-nanoseconds=80 --led-no-hardware-pulse

img_20180214_222244

Not working..... --led-multiplexing=

sudo ./examples-api-use/demo -D 3 --led-rows=16 --led-chain=4 --led-parallel=2 --led-slowdown-gpio=2 --led-pwm-lsb-nanoseconds=80 --led-no-hardware-pulse --led-multiplexing=0

img_20180214_222218

sudo ./examples-api-use/demo -D 3 --led-rows=16 --led-chain=4 --led-parallel=2 --led-slowdown-gpio=2 --led-pwm-lsb-nanoseconds=80 --led-no-hardware-pulse --led-multiplexing=1

img_20180214_222146

sudo ./examples-api-use/demo -D 3 --led-rows=16 --led-chain=4 --led-parallel=2 --led-slowdown-gpio=2 --led-pwm-lsb-nanoseconds=80 --led-no-hardware-pulse --led-multiplexing=2

img_20180214_222054

sudo ./examples-api-use/demo -D 3 --led-rows=16 --led-chain=4 --led-parallel=2 --led-slowdown-gpio=2 --led-pwm-lsb-nanoseconds=80 --led-no-hardware-pulse --led-multiplexing=3

img_20180214_222030

sudo ./examples-api-use/demo -D 3 --led-rows=16 --led-chain=4 --led-parallel=2 --led-slowdown-gpio=2 --led-pwm-lsb-nanoseconds=80 --led-no-hardware-pulse --led-multiplexing=4

img_20180214_221904

Also the option --led-row-addr-type dose not work.

But thanks for the transform Set Option. this works fine.

hzeller commented 6 years ago

So if the existing --led-multiplexing= values 0 .. 4 don't work, but you have figured out a transformer mapping for you, it would be great if you could send a pull request that adds these to lib/multiplex-transformers.cc - there might be other people that have the same panel so would be greatful for your contribution.

hzeller commented 6 years ago

@darknessii I guess this can be closed now as this was the transformer you were working on ?

angelogoncalve commented 6 years ago

Hello Dear Henner.

The --led-multiplexing=6 works fine. Thank you my friend for your help.

hzeller commented 6 years ago

Thank @darknessii who implemented this mapper, not me :)