Reducing the brightness of an LED Strip (Adafruit Dotstar RGB Strip) using Python
<p>I have this code below piping data to a strip of RGB LEDs.  The code works fine.  The Adafruit Dotstar libray (<a href="https://github.com/adafruit/Adafruit_DotStar" rel="nofollow">https://github.com/adafruit/Adafruit_DotStar</a>) also has a strandtest.py example in addition to the code below.  In the test example it is possible to reduce the brightness of the LEDs using <em>strip.setBrightnes(2)</em>.  I have duplicated that code in the same general location in the code below but it does not change the LED brightness.  I suspect a bug with in the library but I would still like to find a solution to reduce the LED brightness.  I am at wits end (read NOOB).
Any help reducing the LED brightness is appreciated.</p>

<pre><code>#!/usr/bin/python

import PIL
from PIL import Image
from dotstar import Adafruit_DotStar
filename  = "/home/pi/Adafruit_DotStar_Pi/marilynlowerres.jpg"

datapin   = 10
clockpin  = 11
strip     = Adafruit_DotStar(0, datapin, clockpin)

rOffset = 3
gOffset = 2
bOffset = 1
strip.begin()
strip.setBrightness(2)
print "Loading..."
img = Image.open(filename).convert("RGB")
pixels = img.load()
width = img.size[0]
height = img.size[1]
print "%dx%d pixels" % img.size
gamma = bytearray(256)
for i in range(256):
    gamma[i] = int(pow(float(i) / 255.0, 2.7) * 255.0 + 0.5)
print "Allocating..."
column = [0 for x in range(width)]
for x in range(width):
    column[x] = bytearray(height * 4)
print "Converting..."
for x in range(width):
    for y in range(height):
    value= pixels[x, y]
    y4= y * 4 
    column[x][y4]= 0xFF
    column[x][y4 + rOffset] = gamma[value[0]]
    column[x][y4 + gOffset] = gamma[value[1]] 
    column[x][y4 + bOffset] = gamma[value[2]]
print "Displaying..."
while True:
    for x in range(width):
        strip.show(column[x])
</code></pre>

<p>Here is a solution to reducing pixel brightness provided by Adafruit Industries.  Thanks Adafruit!</p>

<pre><code>  column[x][y4 + rOffset] = gamma[value[0]/2] # Gamma-corrected R
  column[x][y4 + gOffset] = gamma[value[1]/2] # Gamma-corrected G
  column[x][y4 + bOffset] = gamma[value[2]/2] # Gamma-corrected B
</code></pre>

python debugging raspberry-pi led