Ejemplo n.º 1
0
 def __init__(self, level):
     global enabled
     self._log = Logger("rgbmatrix", level)
     self._rgbmatrix5x5_PORT = RGBMatrix5x5(address=0x77)
     self._log.info('port rgbmatrix at 0x77.')
     self._rgbmatrix5x5_PORT.set_brightness(0.8)
     self._rgbmatrix5x5_PORT.set_clear_on_exit()
     self._rgbmatrix5x5_STBD = RGBMatrix5x5(address=0x74)
     self._log.info('starboard rgbmatrix at 0x74.')
     self._rgbmatrix5x5_STBD.set_brightness(0.8)
     self._rgbmatrix5x5_STBD.set_clear_on_exit()
     self._height = self._rgbmatrix5x5_PORT.height
     self._width = self._rgbmatrix5x5_PORT.width
     self._log.info('rgbmatrix width,height: {},{}'.format(
         self._width, self._height))
     self._thread_PORT = None
     self._thread_STBD = None
     self._color = Color.RED  # used by _solid
     enabled = False
     self._closing = False
     self._closed = False
     self._display_type = DisplayType.DARK  # default
     # used by _cpu:
     self._max_value = 0.0  # TEMP
     self._buf = numpy.zeros(
         (self._rgbmatrix5x5_STBD._width, self._rgbmatrix5x5_STBD._height))
     self._colors = [
         Color.GREEN, Color.YELLOW_GREEN, Color.YELLOW, Color.ORANGE,
         Color.RED
     ]
     self._log.info('ready.')
def test_set_all():
    sys.modules['smbus'] = mock.Mock()
    from rgbmatrix5x5 import RGBMatrix5x5
    rgbmatrix5x5 = RGBMatrix5x5()
    rgbmatrix5x5.set_all(255, 0, 0)
    rgbmatrix5x5.show()
    assert rgbmatrix5x5.buf == [(255, 0, 0, 1.0)] * 5 * 5
Ejemplo n.º 3
0
 def __init__(self, level):
     self._log = Logger("indicator", level)
     self._rgbmatrix5x5 = RGBMatrix5x5(address=0x74)
     self._log.debug('rgbmatrix at 0x74.')
     self._rgbmatrix5x5.set_brightness(0.8)
     self._rgbmatrix5x5.set_clear_on_exit()
     self._height = self._rgbmatrix5x5.height
     self._width  = self._rgbmatrix5x5.width
     self._log.info('ready.')
def test_set_multiple():
    sys.modules['smbus'] = mock.Mock()
    from rgbmatrix5x5 import RGBMatrix5x5
    rgbmatrix5x5 = RGBMatrix5x5()
    rgbmatrix5x5.set_multiple_pixels(list(range(1, 25, 2)), (255, 0, 0))
    rgbmatrix5x5.show()
    result = [(0, 0, 0, 1.0), (255, 0, 0, 1.0)] * 13
    result = result[:-1]
    print(rgbmatrix5x5.buf)
    assert rgbmatrix5x5.buf == result
Ejemplo n.º 5
0
 def __init__(self, level):
     global enabled
     self._log = Logger("rgbmatrix", level)
     self._rgbmatrix5x5_PORT = RGBMatrix5x5(address=0x77)
     self._log.info('port rgbmatrix at 0x77.')
     self._rgbmatrix5x5_PORT.set_brightness(0.8)
     self._rgbmatrix5x5_PORT.set_clear_on_exit()
     self._rgbmatrix5x5_STBD = RGBMatrix5x5(address=0x74)
     self._log.info('starboard rgbmatrix at 0x74.')
     self._rgbmatrix5x5_STBD.set_brightness(0.8)
     self._rgbmatrix5x5_STBD.set_clear_on_exit()
     self._height = self._rgbmatrix5x5_PORT.height
     self._width = self._rgbmatrix5x5_PORT.width
     self._thread_PORT = None
     self._thread_STBD = None
     enabled = False
     self._closing = False
     self._closed = False
     self._display_type = DisplayType.DARK  # default
     self._log.info('ready.')
Ejemplo n.º 6
0
    def __init__(self, level):
        global enabled
        self._log = Logger("rgbmatrix", level)
        _i2c_scanner = I2CScanner(Level.WARN)
        _addresses = _i2c_scanner.get_int_addresses()
        self._rgbmatrix5x5_PORT = RGBMatrix5x5(
            address=0x77) if (0x77 in _addresses) else None
        #       self._rgbmatrix5x5_PORT = RGBMatrix5x5(address=0x77)
        if self._rgbmatrix5x5_PORT:
            self._log.info('port rgbmatrix at 0x77.')
            self._rgbmatrix5x5_PORT.set_brightness(0.8)
            self._rgbmatrix5x5_PORT.set_clear_on_exit()
        else:
            self._log.info('no port rgbmatrix found.')
        self._rgbmatrix5x5_STBD = RGBMatrix5x5(address=0x74)
        self._log.info('starboard rgbmatrix at 0x74.')
        self._rgbmatrix5x5_STBD.set_brightness(0.8)
        self._rgbmatrix5x5_STBD.set_clear_on_exit()

        self._height = self._rgbmatrix5x5_STBD.height
        self._width = self._rgbmatrix5x5_STBD.width
        self._log.info('rgbmatrix width,height: {},{}'.format(
            self._width, self._height))
        self._thread_PORT = None
        self._thread_STBD = None
        self._color = Color.RED  # used by _solid
        enabled = False
        self._closing = False
        self._closed = False
        self._display_type = DisplayType.DARK  # default
        # color used by wipe display
        self._wipe_color = Color.WHITE  # default
        # used by _cpu:
        self._max_value = 0.0  # TEMP
        self._buf = numpy.zeros(
            (self._rgbmatrix5x5_STBD._width, self._rgbmatrix5x5_STBD._height))
        self._colors = [
            Color.GREEN, Color.YELLOW_GREEN, Color.YELLOW, Color.ORANGE,
            Color.RED
        ]
        self._log.info('ready.')
Ejemplo n.º 7
0
try:
    import numpy
except ImportError:
    exit('This script requires the numpy module\nInstall with: sudo pip install numpy')

from rgbmatrix5x5 import RGBMatrix5x5

print("""
RGBMatrix5x5 - Random Blinky!

Displays random warm colours across the matrix.

Press Ctrl+C to exit!
""")

rgbmatrix5x5 = RGBMatrix5x5()

rgbmatrix5x5.set_clear_on_exit()
rgbmatrix5x5.set_brightness(0.8)

height = rgbmatrix5x5.height
width = rgbmatrix5x5.width

while True:
    rand_mat = numpy.random.rand(width, height)
    for y in range(height):
        for x in range(width):
            h = 0.1 * rand_mat[x, y]
            s = 0.8
            v = rand_mat[x, y]
            r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(h, s, v)]
Ejemplo n.º 8
0
 def __init__(self):
     self._rgbmatrix = RGBMatrix5x5()
     self._rgbmatrix.set_clear_on_exit()
     self._rgbmatrix.set_brightness(0.8)
Ejemplo n.º 9
0
#!/usr/bin/env python

import colorsys
import time

from rgbmatrix5x5 import RGBMatrix5x5

rainbow1 = RGBMatrix5x5(0x74)
rainbow2 = RGBMatrix5x5(0x77)

spacing = 360.0 / 5.0
hue = 0

for rainbow in [rainbow1, rainbow2]:
    rainbow.set_clear_on_exit()
    rainbow.set_brightness(0.8)

while True:
    for x in range(rainbow1.width):
        for y in range(rainbow1.height):
            hue = int(time.time() * 100) % 360
            offset = (x * y) / 25.0 * spacing
            h = ((hue + offset) % 360) / 360.0
            r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]
            rainbow1.set_pixel(x, y, r, g, b)
            r, g, b = [
                int(c * 255) for c in colorsys.hsv_to_rgb(h + 0.5, 1.0, 1.0)
            ]
            rainbow2.set_pixel(x, y, r, g, b)

    rainbow1.show()
Ejemplo n.º 10
0
 def __init__(self):
     self.d1 = RGBMatrix5x5(0x74)
     self.d2 = RGBMatrix5x5(0x77)
     self.clear()
Ejemplo n.º 11
0
def test_setup():
    sys.modules['smbus'] = mock.Mock()
    from rgbmatrix5x5 import RGBMatrix5x5
    rgbmatrix5x5 = RGBMatrix5x5()
    rgbmatrix5x5.show()