psieg / Lightpack

Lightpack and Prismatik open repository
GNU General Public License v3.0
1.57k stars 188 forks source link

Please add corner spacing\shifting\offset\width #233

Open v00d00m4n opened 5 years ago

v00d00m4n commented 5 years ago

So, there is a huge problem with Zone placement - it lacking any option to add some empty corners.

Why would anyone need empty corners?

Well, because some people like it without soldering with corner connectors like this: image

We have stand spacing option which is great things to add empty space where we have stand, but we need similar thing, separately vertical percentage and horizontal percentage (preferably float for extra precision) for each corner spacing, otherwise whole color grid getting shifter and misaligned clother to corners

zomfg commented 5 years ago

I ordered those too, how are they holding?

And if you really need what you ask ASAP you should be able to achieve it through manual editing of LED placements (profile ini)

v00d00m4n commented 5 years ago

I ordered those too, how are they holding?

And if you really need what you ask ASAP you should be able to achieve it through manual editing of LED placements (profile ini)

they hold well, i used them on ip 65 which i had to make thinner with cutter to close clips.

Where does it store profile ini?

zomfg commented 5 years ago

C:\Users\you\Prismatik\Profiles

v00d00m4n commented 5 years ago

Thanks.

I looked at INI, and holy cow, its too big and messy to edit 217 leds individually, also i was too busy to figure out how exactly i could add corner spacing.

zomfg commented 5 years ago

you can also reposition them in the UI by dragging the squares..

and what is your display to have 217 leds?

v00d00m4n commented 5 years ago

you can also reposition them in the UI by dragging the squares..

and what is your display to have 217 leds?

its a 4k LG TV 55 inch, i have about 4 meters of led sticked to it, 71 at top, 39 at sides and 2x34 at bottom with gap for stand.

Unfortunately i cant drag and select whole group opf leds in UI and cant drag them all together or cant resize them, because actually reposition would not work right, as size will remain the same and i just neew to resize whole col and rows to match their aligment behind tv. Also dragging them all 1 by 1 is very time consuming.

Ambibox has its problem solves but it has its own issues and was not updated for too long and seems dead now.

zomfg commented 5 years ago

You could also generate your led config with a script, something simple like this:

function horizontalRow($direction, $start, $end, $ledWidth, $ledHeight, $xoffset, $yoffset, $margin = 0)
{
    while ($start <= $end)
    {
        $led = <<<STR
[LED_{$start}]
IsEnabled=true
Position=@Point({$xoffset} {$yoffset})
Size=@Size({$ledWidth} {$ledHeight})
CoefRed=1
CoefGreen=1
CoefBlue=1

STR;
        echo nl2br($led);
        $start++;
        $xoffset += ($ledWidth + $margin) * $direction;
    }
}

function verticalRow($direction, $start, $end, $ledWidth, $ledHeight, $xoffset, $yoffset, $margin = 0)
{
    while ($start <= $end)
    {
        $led = <<<STR
[LED_{$start}]
IsEnabled=true
Position=@Point({$xoffset} {$yoffset})
Size=@Size({$ledWidth} {$ledHeight})
CoefRed=1
CoefGreen=1
CoefBlue=1

STR;
        echo nl2br($led);
        $start++;
        $yoffset += ($ledHeight + $margin) * $direction;
    }
}

// bottom right
horizontalRow(1, 1, 34, 50, 50, 1920, 2160-50, 0);

// right
verticalRow(-1, 35, 74, 50, 50, 3840-50, 2160-50, 0);

// top
horizontalRow(-1, 75, 146, 50, 50, 3840-50, 0, 0);

// left
verticalRow(1, 147, 186, 50, 50, 0, 50, 0);

// bottom left
horizontalRow(1, 187, 221, 50, 50, 50, 2160-50, 0);

you stick this in code-space here and press run and put the result in the profile

adjust values to your needs

v00d00m4n commented 5 years ago

Something is wrong with script, right now im too busy and lazy to fix it myself - cols and rows are uncentered and spacing between them not equal. Upper block sticked to right side, right block sticked to down side and its go just like swastika!

I forget to mention that default 3% of spacing perfectly match my stand size and i was happy with 15% zone. Maybe you could add identica math for stand and size of block and also make corner spacing dynamically calculated with percentage values and rest of leds to scale according whole bloc size instead of fixed size? Because with scrip like that i still has to do calculation before sending values.

Also i noticed that ini uses fixed pixel size values... what would happen to whole pattern if ill switch from 4k to 1080p? Would Prismatik scale it down or it will just take upper left quorter of screen into account?

v00d00m4n commented 5 years ago

Ok, i did fast and lazy fix of your code to make it fully dynamic and to create properly aligned pattern, it almost works fine, except that i did some miscalculation somewhere at shifting or maybe prizmatic does some weird realigment and stacking that displace zones.

Anyway here my fixed code that allows to make corner spaces and even does better job at normal pattern than built in Prizmatic wizzard. This algoritm (with some optimisations) could be easily backported to prizmatic:

function horizontalRow($direction, $start, $end, $ledWidth, $ledHeight, $xoffset, $yoffset, $margin, $r, $g, $b)
{
    while ($start <= $end)
    {
        $led = <<<STR
[LED_{$start}]
IsEnabled=true
Position=@Point({$xoffset} {$yoffset})
Size=@Size({$ledWidth} {$ledHeight})
CoefRed={$r}
CoefGreen={$g}
CoefBlue={$b}

STR;
        echo nl2br($led);
        $start++;
        $xoffset += round(($ledWidth + $margin) * $direction);
    }
}

function verticalRow($direction, $start, $end, $ledWidth, $ledHeight, $xoffset, $yoffset, $margin, $r, $g, $b)
{
    while ($start <= $end)
    {
        $led = <<<STR
[LED_{$start}]
IsEnabled=true
Position=@Point({$xoffset} {$yoffset})
Size=@Size({$ledWidth} {$ledHeight})
CoefRed={$r}
CoefGreen={$g}
CoefBlue={$b}

STR;
        echo nl2br($led);
        $start++;
        $yoffset += round(($ledHeight + $margin) * $direction);
    }
}

$r = 1.00; // red calibration
$g = 0.74; // green, this is value for my sky blue wall to reduce it bluish tint
$b = 0.49; // blue, this is value for my sky blue wall to reduce it bluish tint
$actual_H = 3840; // actual display pixel size
$actual_V = 2160; // thats 4k
$off__led = 1; // starting led number/offset
$top__led = 71; // number of top leds
$bot__led = 68; // number of bottom leds
$sid__led = 39; // number of side leds
$mid__led = $top__led-$bot__led; // number of leds skipped for stand, its better than percentage, since its autocalculated based on difference and since led are of fixed size
$botR_led = $bot__led/2; // bottom right leds
$botL_led = $bot__led/2; // bottom left leds, i know i could have optimized code and should not use same thing twice but i kept it this way for easy reading and understanding of whats going on
$sidR_led = $sid__led;  // right leds
$sidL_led = $sid__led; // left leds - this is again was done for easy human friendly understanding of what kind of led blocks we dealing with, even despite right and left values are equal
$cap__per = 15; // capture zone percentage
$capH_per = $cap__per; // capture zone horizontal percentage for sides
$capV_per = $cap__per; // $actual_H/$actual_V*$cap__per; // capture zone vertical percentage for tops and bottoms, this formula makes vertical zones equal in pixel size to horizontal zones
//$mid__per = 5;
$corH_per = 2; //horisontal  corner spacing percentage
$corV_per = $actual_H/$actual_V*$corH_per; // vertical corner spacing
//$mid__pix = $actual_H/100*$mid__per;
$corH_pix = $actual_H/100*$corH_per; // H corner spacing in pixels
$corV_pix = $actual_V/100*$corV_per; // V corner spacing in pixels
$scaled_H = $actual_H-($corH_pix*2); // shrinking averall H space according to corner spacing
$scaled_V = $actual_V-($corV_pix*2); // same for V space
$midF_pix = $scaled_H/$top__led*$mid__led; // Stand spacing in pixels calculated by dividing shrinked H space by top leds to get 1 led size in pixel and then multiplying it by diff leds between top and bottom
$midR_pix = $midF_pix/2; // right half of stand pixel size now we need just half of that size, this one for right, it used later to shift right led zone away from middle
$midL_pix = $midF_pix/2; // left half of stand pixel size and this one for left, again using this for better readability and in case some numbers needs to be individual

// function verticalRow($direction, $start, $end, $ledWidth, $ledHeight, $xoffset, $yoffset, $margin, $r, $g, $b)
// bottom right
horizontalRow( 1,                                                                     // direction
              $off__led,                                                              // first # of led in block / offset
              $botR_led,                                                              // last # of led in block  / bottom right
              // rounding here is important, because pixels should be integer
              round($scaled_H/$top__led),                                             // 1 led H size = shrinked display H space / top number of leds
              round($actual_V/100*$capH_per),                                         // 1 led V size = actual display V space / 100% * H capture zone percentage
              round(($actual_H/2)+$midR_pix),                                         // block starting H offset coord = (actual display H size / 2) + left half of stand pixel size
              round($actual_V-($actual_V/100*$capH_per)),           0, $r, $g, $b);   // block starting V offset coord = (actual display V size - (actual V size/100%*))
// right
  verticalRow(-1, 
              $botR_led+$off__led,                                                    // bottom right + offset
              $botR_led+$sidR_led,                                                    // bottom right + right side

              round($actual_H/100*$capV_per),                                         //
              round($scaled_V/$sidR_led),     
              round($actual_H-($actual_H/100*$capV_per)),         
              round($scaled_V-($scaled_V/$sidR_led)+$corV_pix),     0, $r, $g, $b);
// top
horizontalRow(-1, 
              $botR_led+$sidR_led+$off__led,                                           // bottom right + right side + offset
              $botR_led+$sidR_led+$top__led,                                           // bottom right + right side + top

              round($scaled_H/$top__led),       
              round($actual_V/100*$capH_per), 
              round(($scaled_H-($scaled_H/$top__led))+$corH_pix), 
              round($actual_V-$actual_V),                            0, $r, $g, $b);
// left
  verticalRow( 1,                                                                       
              $botR_led+$sidR_led+$top__led+$off__led,                                  // bottom right + right side + top + offset
              $botR_led+$sidR_led+$top__led+$sidL_led,                                  // bottom right + right side + top + left side

              round($actual_H/100*$capV_per),   
              round($scaled_V/$sidL_led),     
              round($actual_H-$actual_H),                         
              round($actual_V-$actual_V+$corV_pix),                  0, $r, $g, $b);
// bottom left
horizontalRow( 1, 
              $botR_led+$sidR_led+$top__led+$sidL_led+$off__led,                        // bottom right + right side + top + left side + offset
              $botR_led+$sidR_led+$top__led+$sidL_led+$botL_led,                        // bottom right + right side + top + left side + bottom left

              round($scaled_H/$top__led),       
              round($actual_V/100*$capH_per),
              round(($actual_H-$actual_H)+$corH_pix),                        
              round($actual_V-($actual_V/100*$capH_per)),             0, $r, $g, $b);
v00d00m4n commented 5 years ago

Did another little update:

<?php

function horizontalRow($direction, $start, $end, $ledWidth, $ledHeight, $xoffset, $yoffset, $margin, $r, $g, $b)
{
    while ($start <= $end)
    {
        $led = <<<STR
[LED_{$start}]
IsEnabled=true
Position=@Point({$xoffset} {$yoffset})
Size=@Size({$ledWidth} {$ledHeight})
CoefRed={$r}
CoefGreen={$g}
CoefBlue={$b}

STR;
        echo nl2br($led);
        $start++;
        $xoffset += round(($ledWidth + $margin) * $direction);
    }
}

function verticalRow($direction, $start, $end, $ledWidth, $ledHeight, $xoffset, $yoffset, $margin, $r, $g, $b)
{
    while ($start <= $end)
    {
        $led = <<<STR
[LED_{$start}]
IsEnabled=true
Position=@Point({$xoffset} {$yoffset})
Size=@Size({$ledWidth} {$ledHeight})
CoefRed={$r}
CoefGreen={$g}
CoefBlue={$b}

STR;
        echo nl2br($led);
        $start++;
        $yoffset += round(($ledHeight + $margin) * $direction);
    }
}

$r = 1.00; // red calibration
$g = 0.74; // green, this is value for my sky blue wall to reduce it bluish tint
$b = 0.49; // blue, this is value for my sky blue wall to reduce it bluish tint
$actual_H = 3840; // actual display pixel size
$actual_V = 2160; // thats 4k
$off__led = 1; // starting led number/offset
$top__led = 71; // number of top leds
$bot__led = 68; // number of bottom leds
$sid__led = 39; // number of side leds
$mid__led = $top__led-$bot__led; // number of leds skipped for stand, its better than percentage, since its autocalculated based on difference and since led are of fixed size
$botR_led = $bot__led/2; // bottom right leds
$botL_led = $bot__led/2; // bottom left leds, i know i could have optimized code and should not use same thing twice but i kept it this way for easy reading and understanding of whats going on
$sidR_led = $sid__led;  // right leds
$sidL_led = $sid__led; // left leds - this is again was done for easy human friendly understanding of what kind of led blocks we dealing with, even despite right and left values are equal
$cap__per = 10; // capture zone percentage
$capH_per = $cap__per/($actual_H/$actual_V); // capture zone horizontal percentage for sides
$capV_per = $cap__per; // $actual_H/$actual_V*$cap__per; // capture zone vertical percentage for tops and bottoms, this formula makes vertical zones equal in pixel size to horizontal zones
//$mid__per = 5;
$corH_per = 2; //horisontal  corner spacing percentage
$corV_per = $actual_H/$actual_V*$corH_per; // vertical corner spacing
//$mid__pix = $actual_H/100*$mid__per;
$corH_pix = $actual_H/100*$corH_per; // H corner spacing in pixels
$corV_pix = $actual_V/100*$corV_per; // V corner spacing in pixels
$scaled_H = $actual_H-($corH_pix*2); // shrinking averall H space according to corner spacing
$scaled_V = $actual_V-($corV_pix*2); // same for V space
$midF_pix = $scaled_H/$top__led*$mid__led; // Stand spacing in pixels calculated by dividing shrinked H space by top leds to get 1 led size in pixel and then multiplying it by diff leds between top and bottom
$midR_pix = $midF_pix/2; // right half of stand pixel size now we need just half of that size, this one for right, it used later to shift right led zone away from middle
$midL_pix = $midF_pix/2; // left half of stand pixel size and this one for left, again using this for better readability and in case some numbers needs to be individual

// function verticalRow($direction, $start, $end, $ledWidth, $ledHeight, $xoffset, $yoffset, $margin, $r, $g, $b)
// bottom right
horizontalRow( 1,                                                                     // direction
              $off__led,                                                              // first # of led in block / offset
              $botR_led,                                                              // last # of led in block  / bottom right
              // rounding here is important, because pixels should be integer
              round($scaled_H/$top__led),                                             // 1 led H size = shrinked display H space / top number of leds
              round($actual_V/100*$capV_per),                                         // 1 led V size = actual display V space / 100% * H capture zone percentage
              round(($actual_H/2)+$midR_pix),                                         // block starting H offset coord = (actual display H size / 2) + left half of stand pixel size
              round($actual_V-($actual_V/100*$capV_per)),           0, $r, $g, $b);   // block starting V offset coord = (actual display V size - (actual V size/100%*))
// right
  verticalRow(-1, 
              $botR_led+$off__led,                                                    // bottom right + offset
              $botR_led+$sidR_led,                                                    // bottom right + right side

              round($actual_H/100*$capH_per),                                         //
              round($scaled_V/$sidR_led),     
              round($actual_H-($actual_H/100*$capH_per)),         
              round($scaled_V-($scaled_V/$sidR_led)+$corV_pix),     0, $r, $g, $b);
// top
horizontalRow(-1, 
              $botR_led+$sidR_led+$off__led,                                           // bottom right + right side + offset
              $botR_led+$sidR_led+$top__led,                                           // bottom right + right side + top

              round($scaled_H/$top__led),       
              round($actual_V/100*$capV_per), 
              round(($scaled_H-($scaled_H/$top__led))+$corH_pix), 
              round($actual_V-$actual_V),                            0, $r, $g, $b);
// left
  verticalRow( 1,                                                                       
              $botR_led+$sidR_led+$top__led+$off__led,                                  // bottom right + right side + top + offset
              $botR_led+$sidR_led+$top__led+$sidL_led,                                  // bottom right + right side + top + left side

              round($actual_H/100*$capH_per),   
              round($scaled_V/$sidL_led),     
              round($actual_H-$actual_H),                         
              round($actual_V-$actual_V+$corV_pix),                  0, $r, $g, $b);
// bottom left
horizontalRow( 1, 
              $botR_led+$sidR_led+$top__led+$sidL_led+$off__led,                        // bottom right + right side + top + left side + offset
              $botR_led+$sidR_led+$top__led+$sidL_led+$botL_led,                        // bottom right + right side + top + left side + bottom left

              round($scaled_H/$top__led),       
              round($actual_V/100*$capV_per),
              round(($actual_H-$actual_H)+$corH_pix),                        
              round($actual_V-($actual_V/100*$capV_per)),             0, $r, $g, $b);

?>