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

Rotate 90 not working as expected with multiple panels #606

Open cmagnuson opened 6 years ago

cmagnuson commented 6 years ago

I'm running a chain of 5x 16x32 panels rotated 90° with this command: sudo rpi-rgb-led-matrix/examples-api-use/text-example --led-gpio-mapping=adafruit-hat --led-chain=5 --led-rows=16 --led-cols=32 --led-row-addr-type=2 --led-multiplexing=8 -f ter-powerline-x32n.bdf --led-pwm-bits=1 --led-pwm-lsb-nanoseconds=1000 --led-slowdown-gpio=2 --led-pixel-mapper="Rotate:90"

But entering a string only results in the first character being printed. I can write one character in each panel by typing:

T\nE\nS\nT\n

for example, but I'd expect to be able to write out that string using just:

TEST\n

I'd guess it is still assuming the same canvas width as before the rotation?

The scrolling-text-example has similar results - it only displays on the first panel when "Rotate:90" is set. When I remove the pixel mapper though it will draw all panels as expected.

Scrolling text example: screen shot 2018-05-01 at 3 26 30 pm

hzeller commented 6 years ago

(you have not given a video of the scrolling example to illustrate).

If you have a chain of 5 and rotate it by 90 degrees, you have a portrait display, so now it is very narrow to display the texts, so it sounds like from what you describe like an expected result.

If you want to have text that writes a vertical text from top to bottom on such a screen, you might want to use VerticalDrawText(...)

cmagnuson commented 6 years ago

Thanks for the explanation, I just misunderstood how the rotate command was working.

In the initial case (no rotate) I have a long horizontal row of panels (case 1). After setting rotate 90° I'd expected to have a horizontal row of panels with each individual panel rotated 90° (case 2) but as you described I see it takes the entire matrix of panels and rotates that by 90° (case 3).

screen shot 2018-05-02 at 10 18 12 am

So I was incorrect in my assumption and the rotate is working. Is there a way to apply a rotation to the individual panels instead of the entire matrix?

angelogoncalve commented 6 years ago

see this issue https://github.com/hzeller/rpi-rgb-led-matrix/issues/368

angelogoncalve commented 6 years ago

See rhis issues also:

https://github.com/hzeller/rpi-rgb-led-matrix/issues/552

https://github.com/hzeller/rpi-rgb-led-matrix/issues/481

cmagnuson commented 6 years ago

Thanks for the pointers.

Would you consider a pull request for a PixelMapper like this:

class RotateSinglePanelPixelMapper : public PixelMapper {
public:
  RotateSinglePanelPixelMapper() : chain_(0) {}

  virtual const char *GetName() const { return "RotatePanel"; }

  virtual bool SetParameters(int chain, int parallel, const char *param) {
    chain_ = chain;
    return true;
  }

  virtual bool GetSizeMapping(int matrix_width, int matrix_height,
                              int *visible_width, int *visible_height)
    const {
      *visible_width = matrix_height * chain_;
      *visible_height = matrix_width / chain_;
    return true;
  }

  virtual void MapVisibleToMatrix(int matrix_width, int matrix_height,
                                  int x, int y,
                                  int *matrix_x, int *matrix_y) const {

  const int panel_width = matrix_width / chain_;
  const int panel_height = matrix_height;

  *matrix_x = matrix_width - (y + panel_width * (x / panel_height)) - 1;
  *matrix_y = x % panel_height;
}

private:
  int chain_;
};

It is working for the use case I described above, but doesn't handle parallel panels at the moment.