Skip to content

Commit

Permalink
Merge pull request #1664 from marcmerlin/VmapperZ_fixed
Browse files Browse the repository at this point in the history
Fix for orientation being swapped as described in #1663
  • Loading branch information
hzeller authored Jul 29, 2024
2 parents b84b3f5 + 6a262d0 commit a98c563
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/pixel-mapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,17 @@ class VerticalMapper : public PixelMapper {
int *matrix_x, int *matrix_y) const {
const int panel_width = matrix_width / chain_;
const int panel_height = matrix_height / parallel_;
// because the panel you plug into ends up being the "bottom" panel and coordinates
// start from the top panel, and you typically don't wire the bottom panel (first in
// the chain) upside down, whether each panel gets swapped depends on this.
// Without this, if you wire for 4 panels high and add a 5h panel, without this
// code everything would get reversed and you'd have to re-layout all the panels
bool is_height_even_panels = ( matrix_width / panel_width) % 2;
const int x_panel_start = y / panel_height * panel_width;
const int y_panel_start = x / panel_width * panel_height;
const int x_within_panel = x % panel_width;
const int y_within_panel = y % panel_height;
const bool needs_flipping = z_ && (y / panel_height) % 2 == 1;
const bool needs_flipping = z_ && (is_height_even_panels - ((y / panel_height) % 2)) == 0;
*matrix_x = x_panel_start + (needs_flipping
? panel_width - 1 - x_within_panel
: x_within_panel);
Expand Down

0 comments on commit a98c563

Please sign in to comment.