1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- from rgbmatrix import RGBMatrix, RGBMatrixOptions
- from PIL import Image
-
- class PiMatrix:
- def __init__(self, w = 32 * 4, h = 32, panelW = 32, panelH = 32):
- self.width = w
- self.height = h
-
- self.panelW = panelW
- self.panelH = panelH
-
-
- self.multiplier = 1.0
-
- options = RGBMatrixOptions()
-
- options.cols = self.panelW
- options.rows = self.panelH
-
- options.chain_length = int(self.width / options.cols)
- options.parallel = int(self.height / options.rows)
-
- options.row_address_type = 0
- options.multiplexing = 0
- options.pwm_bits = 11
- options.brightness = 100
- options.pwm_lsb_nanoseconds = 130
- options.led_rgb_sequence = 'RGB'
-
-
-
-
-
-
-
- options.panel_type = "FM6126A"
-
- self.matrix = RGBMatrix(options = options)
-
- self.loop_start()
-
- def exit(self):
- pass
-
- def loop_start(self):
- self.image = Image.new('RGB', (self.width, self.height))
- return False
-
- def loop_end(self):
- self.matrix.SetImage(self.image.convert('RGB'))
-
- def set_pixel(self, x, y, color):
- if (x < 0) or (y < 0) or (x >= self.width) or (y >= self.height):
- return
-
- self.image.putpixel((int(x), int(y)), color)
-
- if __name__ == "__main__":
- import util
-
- t = PiMatrix()
- util.loop(t, lambda: t.set_pixel(15, 15, (255, 255, 255)))
|