Global per pixel brghtness adjustment

I stepped into unexpected problem. My wife asked to increase a size for the Virtual Fireplace project. The original display was three 16x16 panels combined into single 48x16 panel. Now I added (successfully) there more matrix on top (one 8x32 followed by two 8x8 and added on the top of the existing panel). The problem is - this 8x32 panel has less brightness than all other panels. Unfortunately the difference is very well visible even with relatively high global brightness setting.
On a taken picture the difference is less pronounced as in reality (top left corner):

As a test I was able to correct difference by introducing a brightness multiplier which depend on index:

export function beforeRender(delta) {
  t1 = time(.1)
}

export function render(index)
{
  if ((index < 768) | (index > 1023))
  {
    r = 0.3
    g = 0
    b = 0
  }
  else
  {
    r = 1
    g = 0
    b = 0
  }
  rgb(r, g, b)
}

My question is:
Is it possible to create (or call the existing) function for correcting this problem globally (the ideal place will be Mapper)?

Sadly such global magic is not yet available in pattern code.

I would change the mapper to add a z coordinate with this multiplier (0.3 or 1.0) … then you need to change all your 2D patterns to use render3D() and simply multiply r,g,b (or v) by the z value.

(actually straight multiplication might not do it, because gamma, but I can’t advise you on the correct math)

Thank you very much for the advice.
I am sure, this trick will/should work. But since there is no one single place to apply the required changes I will change the failed matrix (this one is few years old, was sitting in my spare parts drawer, all others are brand new) with new one from the same manufacture as all other panels (all they are looks about the same (but still not a 100%) for the brightness).

BTW, I am/was about to try to implement your idea but I am confused how do I introduce a Z layer without having a physical LEDs. Should I simply double a pixelCount value (making 3D array with only two Z layers (one is real physical (Z = 0) and a virtual (Z = 1) for Brightness adjustment)?
Just in case here is my current Mapper function:

// Mapping for the 48x24 Matrix
// with vertical zigzagging for each sub-matrix
// The Combined Matrix is
//  8x32 +  8x8  +  8x8  (Top Portion,    Index Range 768 : 1151)
// 16x16 + 16x16 + 16x16 (Bottom Portion, Index Range   0 :  767)

function (pixelCount)
{
  // Index Range 768 : 1151
  // 8x256 + 8x8 + 8x8
  // Zigzag Top-to-Bottom + Bottom-to-Top
  var widthTop  =  48
  var heightTop =  8
  var pixelCountTop = 384 //(widthTop * heightTop)

  // Index Range 0 : 767
  // 16x16 + 16x16 + 16x16
  // Zigzag Top-to-Bottom + Bottom-to-Top
  var widthBottom  =  48
  var heightBottom =  16
  var pixelCountBottom = (widthBottom * heightBottom)

  var height
  
  var map = []

  for (i = 0; i < pixelCount; i++)
  {
    if (i < pixelCountBottom)
    {
      x = Math.floor(i / heightBottom) 
      y = (i % heightBottom)

      // y adjustment for vertical zigzag wiring
      y = (x % 2) == 1 ? (heightBottom - 1 - y) : y
      
      y = y + heightTop
    }
    else
    {
      x = Math.floor(i / heightTop) 
      y = (i % heightTop)

      // y adjustment for vertical zigzag wiring
      y = (x % 2) == 1 ? (heightTop - 1 - y) : y
      
      x = x - (2 * widthBottom)
    }

    map.push([x, y])
  }

  return map
}

The dimmed panel is 8x32 one with the Index range (768 : 1023). This range requires full brightness.
The rest of the array (Index ranges 0 : 767 and 1024 : 1151)) requires a reduced brightness.
If you have a spare minutes it will be very helpful if you can adjust the current mapper with the required changes.

Replace this with something like:

map.push([x, y, ((i < 768)||(i > 1023)) ? 0.3 : 1.0 ])

This is a short way of writing:


  if ((i < 768)||(i > 1023)) {
    z = 0.3
  } else {
    z = 1.0
  }

  map.push([x, y, z])

Well, I tried the suggested code modification. It works but unfortunately not as expected unless I am doing something wrong. Here is my simple test pattern (it should light up the entire matrix regardless of index and coordinates and yes, the entire matrix is lighted):

export function beforeRender(delta) {
  t1 = time(.1)
}

export function render3D(index, x, y, z)
{
    r = 1
    g = 1
    b = 1

   rgb(r * z, g * z, b * z)
}

And here is a modified Mapper function:

// Mapping for the 48x24 Matrix
// with vertical zigzagging for each sub-matrix
// The 2D Combined Matrix is
//  8x32 +  8x8  +  8x8  (Top Portion,    Index Range 768 : 1151)
// 16x16 + 16x16 + 16x16 (Bottom Portion, Index Range   0 :  767)

function (pixelCount)
{
  // Index Range 768 : 1151
  // 8x256 + 8x8 + 8x8
  // Zigzag Top-to-Bottom + Bottom-to-Top
  var widthTop  =  48
  var heightTop =  8
  var pixelCountTop = 384 //(widthTop * heightTop)

  // Index Range 0 : 767
  // 16x16 + 16x16 + 16x16
  // Zigzag Top-to-Bottom + Bottom-to-Top
  var widthBottom  =  48
  var heightBottom =  16
  var pixelCountBottom = (widthBottom * heightBottom)

  var height
  
  var map = []

  for (i = 0; i < pixelCount; i++)
  {
    if (i < pixelCountBottom)
    {
      x = Math.floor(i / heightBottom) 
      y = (i % heightBottom)

      // y adjustment for vertical zigzag wiring
      y = (x % 2) == 1 ? (heightBottom - 1 - y) : y
      
      y = y + heightTop
    }
    else
    {
      x = Math.floor(i / heightTop) 
      y = (i % heightTop)

      // y adjustment for vertical zigzag wiring
      y = (x % 2) == 1 ? (heightTop - 1 - y) : y
      
      x = x - (2 * widthBottom)
    }

    //map.push([x, y])
    if ((i < 768) || (i > 1023))
    {
      z = 0.0
    }
    else
    {
      z = 0.0
    }

    map.push([x, y, z])
  }

  return map
}

I set z to be 0 regardless of index. So, the entire matrix should be Off but it is On like z=1.
Now if I change z to 1 in whatever region this region turns On but the value for the second region does not have any affect and that second region is Off. However if z value is the same for both regions then both regions are On with somewhat reduced brightness but not even proportional to the z value.
What is wrong with this test?

Your Z is probably getting normalized and centered.

Use a min/max z relative to your other dimensions or turn the map mode back to full and use two different z values.

1 Like

Thank you for the tips advice.
Just in case (and for better understanding what is going on) I will try to fix this Brightness Adjustment algorithm but for now I am all set. Amazon was quick enough to ship a replacement 32x8 Panel. It has about the same as all other panels Brightness (actually for the Brightness there is no two or more exactly the same panels, there is always some minor (near invisible) difference). Dimmed panel already replaced and now the entire combined 48x24 panel looks very good.

Oh right! Normalization!

So you could just set z to 0 or 1, then multiply by (z ? 0.3 : 1.0)

This would only work if you have two different values to correct for.

Ok then, set z to any value 0…1, then mulitply by (0.3 + z * 0.7) :stuck_out_tongue:

Has a power issue been ruled out? Did you check the voltage going into the panel?

Yes, power distribution is/was next to ideal. The panel in question definitely was a problem. And the problem was instantly fixed by replacing the dimmed panel. Now I am waiting for the tap black plastic to be delivered (the expected delivery is some time tomorrow).

1 Like