Esempio n. 1
0
def led_matrix_options(args):
  options = RGBMatrixOptions()

  if args.led_gpio_mapping != None:
    options.hardware_mapping = args.led_gpio_mapping

  options.rows = args.led_rows
  options.cols = args.led_cols
  options.chain_length = args.led_chain
  options.parallel = args.led_parallel
  options.row_address_type = args.led_row_addr_type
  options.multiplexing = args.led_multiplexing
  options.pwm_bits = args.led_pwm_bits
  options.brightness = args.led_brightness
  options.pwm_lsb_nanoseconds = args.led_pwm_lsb_nanoseconds
  options.led_rgb_sequence = args.led_rgb_sequence
  try:
    options.pixel_mapper_config = args.led_pixel_mapper
  except AttributeError:
    debug.warning("Your compiled RGB Matrix Library is out of date.")
    debug.warning("The --led-pixel-mapper argument will not work until it is updated.")

  if args.led_show_refresh:
    options.show_refresh_rate = 1

  if args.led_slowdown_gpio != None:
    options.gpio_slowdown = args.led_slowdown_gpio

  if args.led_no_hardware_pulse:
    options.disable_hardware_pulsing = True

  return options
Esempio n. 2
0
def led_matrix_options(args):
  options = RGBMatrixOptions()

  if args.led_gpio_mapping != None:
    options.hardware_mapping = args.led_gpio_mapping

  options.rows = args.led_rows
  options.cols = args.led_cols
  options.chain_length = args.led_chain
  options.parallel = args.led_parallel
  options.row_address_type = args.led_row_addr_type
  options.multiplexing = args.led_multiplexing
  options.pwm_bits = args.led_pwm_bits
  options.brightness = args.led_brightness
  options.pwm_lsb_nanoseconds = args.led_pwm_lsb_nanoseconds
  options.led_rgb_sequence = args.led_rgb_sequence

  if args.led_show_refresh:
    options.show_refresh_rate = 1

  if args.led_slowdown_gpio != None:
    options.gpio_slowdown = args.led_slowdown_gpio

  if args.led_no_hardware_pulse:
    options.disable_hardware_pulsing = True

  return options
Esempio n. 3
0
def led_matrix_options(args):
    options = RGBMatrixOptions()

    if args.led_gpio_mapping != None:
        options.hardware_mapping = args.led_gpio_mapping

    options.rows = args.led_rows
    options.cols = args.led_cols
    options.chain_length = args.led_chain
    options.parallel = args.led_parallel
    options.row_address_type = args.led_row_addr_type
    options.multiplexing = args.led_multiplexing
    options.pwm_bits = args.led_pwm_bits
    options.brightness = args.led_brightness
    options.pwm_lsb_nanoseconds = args.led_pwm_lsb_nanoseconds
    options.led_rgb_sequence = args.led_rgb_sequence
    try:
        options.pixel_mapper_config = args.led_pixel_mapper
    except AttributeError:
        debug.warning("Your compiled RGB Matrix Library is out of date.")
        debug.warning("The --led-pixel-mapper argument will not work until it is updated.")

    if args.led_show_refresh:
        options.show_refresh_rate = 1

    if args.led_slowdown_gpio != None:
        options.gpio_slowdown = args.led_slowdown_gpio

    if args.led_no_hardware_pulse:
        options.disable_hardware_pulsing = True

    return options
Esempio n. 4
0
    def __init__(self, config):
        from rgbmatrix import RGBMatrix, RGBMatrixOptions
        options = RGBMatrixOptions()

        options.rows = config.getint('rows')
        options.cols = config.getint('cols')
        options.hardware_mapping = config['led_hardware_mapping']

        options.chain_length = config.getint('led_chain')
        options.parallel = config.getint('led_parallel')
        options.pwm_bits = config.getint('led_pwm_bits')
        options.brightness = config.getint('led_brightness')
        options.pwm_lsb_nanoseconds = config.getint('led_pwm_lsb_nanoseconds')
        options.inverse_colors = config.getboolean('led_inverse')
        options.led_rgb_sequence = config['led_rgb_sequence']
        options.pixel_mapper_config = config['led_pixel_mapper']
        options.row_address_type = config.getint('led_row_addr_type')
        options.multiplexing = config.getint('led_multiplexing')
        options.scan_mode = config.getint('led_scan_mode')
        options.gpio_slowdown = config.getint('led_slowdown_gpio')
        options.disable_hardware_pulsing = config.getboolean(
            'led_no_hardware_pulse')
        options.show_refresh_rate = config.getboolean('led_show_refresh')
        options.pwm_dither_bits = config.getint('led_pwm_dither_bits')
        #options.panel_type = config['led_panel_type']

        self.matrix = RGBMatrix(options=options)
        self.offscreen_canvas = self.matrix.CreateFrameCanvas()
Esempio n. 5
0
def init_matrix():
    global _state

    options = RGBMatrixOptions()
    options.hardware_mapping = const.scr_led_gpio_mapping
    options.rows = const.scr_led_rows
    options.cols = const.scr_led_cols
    options.chain_length = const.scr_led_chain
    options.parallel = const.scr_led_parallel
    options.row_address_type = const.scr_row_address_type
    options.multiplexing = const.scr_led_multiplexing
    options.pwm_bits = const.scr_led_pwm_bits
    options.brightness = _state.currentBrightness
    options.pwm_lsb_nanoseconds = const.scr_led_pwm_lsb_nanoseconds
    options.led_rgb_sequence = const.scr_led_rgb_sequence
    if const.scr_led_show_refresh:
        options.show_refresh_rate = 1
    if const.scr_led_slowdown_gpio is not None:
        options.gpio_slowdown = const.scr_led_slowdown_gpio
    if const.scr_led_no_hardware_pulse:
        options.disable_hardware_pulsing = True
    options.pixel_mapper_config = const.scr_pixel_mapper_config

    # https://github.com/hzeller/rpi-rgb-led-matrix/issues/679#issuecomment-423268899
    _state.matrix = RGBMatrix(options=options)

    for fontFilename in ["10x20", "6x9", "5x8"]:
        font = graphics.Font()
        font.LoadFont("{}/{}.bdf".format(const.scr_fonts_dir, fontFilename))
        _state.fonts.append(font)

    logger.debug("matrix canvas initialized")
Esempio n. 6
0
    def process(self):
        self.args = self.parser.parse_args()

        options = RGBMatrixOptions()

        options.hardware_mapping = "adafruit-hat"
        options.rows = self.args.led_rows
        options.cols = self.args.led_cols
        options.chain_length = self.args.led_chain
        options.parallel = self.args.led_parallel
        options.row_address_type = self.args.led_row_addr_type
        options.multiplexing = self.args.led_multiplexing
        options.pwm_bits = self.args.led_pwm_bits
        options.brightness = self.args.led_brightness
        options.pwm_lsb_nanoseconds = self.args.led_pwm_lsb_nanoseconds
        options.led_rgb_sequence = self.args.led_rgb_sequence
        options.pixel_mapper_config = self.args.led_pixel_mapper
        if self.args.led_show_refresh:
            options.show_refresh_rate = 1

        if self.args.led_slowdown_gpio != None:
            options.gpio_slowdown = self.args.led_slowdown_gpio
        options.disable_hardware_pulsing = True

        self.matrix = RGBMatrix(options=options)

        try:
            # Start loop
            print("Press CTRL-C to stop sample")
            self.run()
        except KeyboardInterrupt:
            print("Exiting\n")
            sys.exit(0)

        return True
Esempio n. 7
0
    def __init__(self, options, font=defaultFont):
        self._logger = LogManager.get_logger(__name__)
        self._logger.debug("Initializing display with '{0}'".format(options))

        matrix_options = RGBMatrixOptions()

        matrix_options.hardware_mapping = options.led_gpio_mapping
        matrix_options.rows = options.led_rows
        matrix_options.cols = options.led_cols
        matrix_options.chain_length = options.led_chain
        matrix_options.parallel = options.led_parallel
        matrix_options.row_address_type = options.led_row_addr_type
        matrix_options.multiplexing = options.led_multiplexing
        matrix_options.pwm_bits = options.led_pwm_bits
        matrix_options.brightness = options.led_brightness
        matrix_options.pwm_lsb_nanoseconds = options.led_pwm_lsb_nanoseconds
        matrix_options.led_rgb_sequence = options.led_rgb_sequence
        matrix_options.show_refresh_rate = options.led_show_refresh
        matrix_options.gpio_slowdown = options.led_slowdown_gpio
        matrix_options.disable_hardware_pulsing = options.led_no_hardware_pulse

        self._matrix = RGBMatrix(options = matrix_options)
        self._offscreen_canvas = self._matrix.CreateFrameCanvas()

        self._font = font
Esempio n. 8
0
    def process(self):
        self.args = self.parser.parse_args()

        options = RGBMatrixOptions()

        if self.args.led_gpio_mapping is not None:
            options.hardware_mapping = self.args.led_gpio_mapping
        options.rows = self.args.led_rows
        options.cols = self.args.led_cols
        options.chain_length = self.args.led_chain
        options.parallel = self.args.led_parallel
        options.row_address_type = self.args.led_row_addr_type
        options.multiplexing = self.args.led_multiplexing
        options.pwm_bits = self.args.led_pwm_bits
        options.brightness = self.args.led_brightness
        options.pwm_lsb_nanoseconds = self.args.led_pwm_lsb_nanoseconds
        options.led_rgb_sequence = self.args.led_rgb_sequence
        options.pixel_mapper_config = self.args.led_pixel_mapper
        if self.args.led_show_refresh:
            options.show_refresh_rate = 1

        if self.args.led_slowdown_gpio is not None:
            options.gpio_slowdown = self.args.led_slowdown_gpio
        if self.args.led_no_hardware_pulse:
            options.disable_hardware_pulsing = True

        self.matrix = RGBMatrix(options=options)

        return True
Esempio n. 9
0
    def init_matrix(self):
        args = self.parser.parse_args()

        options = RGBMatrixOptions()

        if args.led_gpio_mapping != None:
            options.hardware_mapping = args.led_gpio_mapping
        options.rows = args.led_rows
        options.cols = args.led_cols
        options.chain_length = args.led_chain
        options.parallel = args.led_parallel
        options.row_address_type = args.led_row_addr_type
        options.multiplexing = args.led_multiplexing
        options.pwm_bits = args.led_pwm_bits
        options.brightness = args.led_brightness
        options.pwm_lsb_nanoseconds = args.led_pwm_lsb_nanoseconds
        options.led_rgb_sequence = args.led_rgb_sequence
        options.pixel_mapper_config = args.led_pixel_mapper
        # Gave error that no options named panel_type existed
        #options.panel_type = args.led_panel_type

        if args.led_show_refresh:
            options.show_refresh_rate = 1

        if args.led_slowdown_gpio != None:
            options.gpio_slowdown = args.led_slowdown_gpio
        if args.led_no_hardware_pulse:
            options.disable_hardware_pulsing = True

        return RGBMatrix(options=options)
Esempio n. 10
0
 def __init__(self, *args, **kwargs):
     o = RGBMatrixOptions()
     o.rows = 16
     o.cols = 32
     o.chain_length = 3
     o.parallel = 3
     o.multiplexing = 8
     o.row_address_type = 0
     o.pwm_lsb_nanoseconds = 100
     o.brightness = 25
     self.matrix = RGBMatrix(options=o)
Esempio n. 11
0
    def __init__(self):
        options = RGBMatrixOptions()
        # TODO MOVE TO CONFIG FILE
        options.hardware_mapping = "adafruit-hat"
        options.disable_hardware_pulsing = True
        options.rows = 16
        options.cols = 32
        options.chain_length = 4
        options.pixel_mapper_config = "U-mapper"
        options.multiplexing = 8  # CORRECT value for 1/4 SCAN PANELS

        self.matrix = RGBMatrix(options=options)
        self.offscreen_canvas = self.matrix.CreateFrameCanvas()
    def __init__(self):
        options = RGBMatrixOptions()
        # TODO MOVE TO CONFIG FILE
        options.hardware_mapping = "adafruit-hat"
        options.disable_hardware_pulsing = True
        options.rows = 16
        options.cols = 32
        # set default brightess to 50% to protect against power spike at turn on
        options.brightness = 50
        options.chain_length = 4
        options.pixel_mapper_config = "U-mapper"
        options.multiplexing = 8  # CORRECT value for 1/4 SCAN PANELS

        self.matrix = RGBMatrix(options=options)
        self.offscreen_canvas = self.matrix.CreateFrameCanvas()
Esempio n. 13
0
 def __init__(self, brightness: int):
     options = RGBMatrixOptions()
     options.brightness = brightness
     options.rows = 32
     options.cols = 64
     options.chain_length = 1
     options.parallel = 1
     options.pwm_bits = 11
     options.hardware_mapping = 'regular'
     options.pwm_lsb_nanoseconds = 130
     options.gpio_slowdown = 1
     options.led_rgb_sequence = 'RGB'
     options.pixel_mapper_config = ''
     options.row_address_type = 0
     options.multiplexing = 0
     self.matrix = RGBMatrix(options=options)
Esempio n. 14
0
    def __init__(self,
                 *,
                 rows=32,
                 columns=64,
                 chain=1,
                 brightness=80,
                 gpio_mapping="adafruit-hat-pwm",
                 parallel=1,
                 pwm_bits=11,
                 panel_type="",
                 rgb_sequence="rgb",
                 show_refresh=False,
                 slowdown_gpio=None,
                 no_hardware_pulse=False,
                 pwm_lsb_nanoseconds=130,
                 row_addr_type=0,
                 multiplexing=0,
                 pixel_mapper=""):
        options = RGBMatrixOptions()
        options.drop_privileges = 0
        options.daemon = 0
        options.hardware_mapping = gpio_mapping
        options.rows = rows
        options.cols = columns
        options.chain_length = chain
        options.parallel = parallel
        options.pwm_bits = pwm_bits
        options.brightness = brightness
        options.panel_type = panel_type
        options.led_rgb_sequence = rgb_sequence
        options.pwm_lsb_nanoseconds = pwm_lsb_nanoseconds
        options.row_address_type = row_addr_type
        options.multiplexing = multiplexing
        options.pixel_mapper_config = pixel_mapper

        if show_refresh:
            options.show_refresh_rate = 1
        if slowdown_gpio is not None:
            options.gpio_slowdown = slowdown_gpio
        if no_hardware_pulse:
            options.disable_hardware_pulsing = True

        self._matrix = RGBMatrix(options=options)
        self._buffer = self._matrix.CreateFrameCanvas()
        self._background = (0, 0, 0)
        self._position = (0, 0)
    def __init__(self):
        print("__init__")

        options = RGBMatrixOptions()
        options.hardware_mapping = "adafruit-hat-pwm"
        options.rows = 32
        options.cols = 64

        options.chain_length = 1
        options.parallel = 1
        options.row_address_type = 0
        options.multiplexing = 0
        options.pwm_bits = 11
        options.brightness = 100
        options.disable_hardware_pulsing = 0
        #options.pwm_lsb_nanoseconds = 130
        options.pwm_lsb_nanoseconds = 500  # 400=Good
        options.led_rgb_sequence = "RGB"
        options.pixel_mapper_config = ""
        options.show_refresh_rate = 0
        options.gpio_slowdown = 0
        options.daemon = 0
        options.drop_privileges = False

        self.matrix = RGBMatrix(options=options)

        self.offscreen_canvas = self.matrix.CreateFrameCanvas()
        self.font = graphics.Font()
        self.fontSmall = graphics.Font()

        # Setup Fonts
        # Get fonts from here: https://github.com/dk/ibm-vio-os2-fonts
        #self.font.LoadFont("../../../fonts/10x20.bdf")
        #self.font.LoadFont("ibm-vio-12x20-r-iso10646-1-20.bdf")

        self.fontSmall.LoadFont(
            "fonts/ibm-vio-6x10-r-iso10646-1-10-modified.bdf")
        self.font.LoadFont("fonts/ibm-vio-12x30-r-iso10646-1-30-modified.bdf")
        #self.font.LoadFont("fonts/ibm-vio-10x21-r-iso10646-1-21.bdf")
        #self.font.LoadFont("fonts/ibm-vio-12x22-r-iso10646-1-22-modified.bdf")
        #self.font.LoadFont("../../../fonts/helvR12.bdf")
        self.matrix.brightness = 100
        #self.textColor = graphics.Color(255, 0, 0)
        logger.info("display adafruit hat init complete")
Esempio n. 16
0
    def setup(self):
        self.args = self.parser.parse_args()

        options = RGBMatrixOptions()

        if self.args.led_gpio_mapping != None:
            options.hardware_mapping = self.args.led_gpio_mapping

        options.rows = self.args.led_rows
        options.cols = self.args.led_cols
        options.chain_length = self.args.led_chain
        options.parallel = self.args.led_parallel
        options.pwm_bits = self.args.led_pwm_bits
        options.brightness = self.args.led_brightness
        options.pwm_lsb_nanoseconds = self.args.led_pwm_lsb_nanoseconds
        options.led_rgb_sequence = self.args.led_rgb_sequence
        options.pixel_mapper_config = self.args.led_pixel_mapper

        options.row_address_type = 0
        options.multiplexing = 0
        options.show_refresh_rate = 0
        options.disable_hardware_pulsing = 0

        if self.args.led_show_refresh:
            options.show_refresh_rate = 1

        # ラズパイ判別
        model = subprocess.run(["cat", "/proc/device-tree/model"],
                               encoding='utf-8',
                               stdout=subprocess.PIPE)
        # Pi4の場合, SetImageのunsafeを有効, gpio速度低下
        if "Raspberry Pi 4" in model.stdout:
            self.unsafe = False

            if self.args.led_slowdown_gpio < 2:
                options.gpio_slowdown = 3
            else:
                options.gpio_slowdown = self.args.led_slowdown_gpio

        else:
            self.unsafe = True
            options.gpio_slowdown = self.args.led_slowdown_gpio

        self.matrix = RGBMatrix(options=options)
Esempio n. 17
0
    def process(self):
        """Process command-line input and initiate the RGB matrix with
           those options before calling the subclass code."""
        self.args = self.parser.parse_args()

        options = RGBMatrixOptions()

        if self.args.led_gpio_mapping is not None:
            options.hardware_mapping = self.args.led_gpio_mapping
        options.rows = self.args.led_rows
        options.cols = self.args.led_cols
        options.chain_length = self.args.led_chain
        options.parallel = self.args.led_parallel
        options.row_address_type = self.args.led_row_addr_type
        options.multiplexing = self.args.led_multiplexing
        options.pwm_bits = self.args.led_pwm_bits
        options.brightness = self.args.led_brightness
        options.pwm_lsb_nanoseconds = self.args.led_pwm_lsb_nanoseconds
        options.led_rgb_sequence = self.args.led_rgb_sequence
        options.pixel_mapper_config = self.args.led_pixel_mapper
        if self.args.led_show_refresh:
            options.show_refresh_rate = 1

        if self.args.led_slowdown_gpio is not None:
            options.gpio_slowdown = self.args.led_slowdown_gpio
        if self.args.led_no_hardware_pulse:
            options.disable_hardware_pulsing = True

        # Don't drop root status; lets us maintain I2C access, etc.
        # For some reason this isn't working from command line.
        options.drop_privileges = False

        signal.signal(signal.SIGTERM, self.signal_handler)
        signal.signal(signal.SIGINT, self.signal_handler)

        self.matrix = RGBMatrix(options=options)

        try:
            self.run()
        except KeyboardInterrupt:
            sys.exit(0)

        return True
Esempio n. 18
0
    def run (self):
        options = RGBMatrixOptions()
        options.rows = 32
        options.cols = 64
        options.chain_length = 1
        options.parallel = 1
        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"
        self.matrix = RGBMatrix(options = options)

        double_buffer = self.matrix.CreateFrameCanvas()
        self.width = double_buffer.width
        self.height = double_buffer.height
        self.canvas = Image.new("RGB", (self.width, self.height))
        self.draw = ImageDraw.Draw(self.canvas)
        self.set_level(self.level)

        while True:
            self.error = None
            t = time()

            self.current_mode.runframe(t)

            ## if there was an error, set visual indicator
            if self.error:
                self.canvas.putpixel((63, 0), self.error.color)

            ## write canvas to matrix
            ##
            double_buffer.SetImage(self.canvas)
            double_buffer = self.matrix.SwapOnVSync(double_buffer)

            ## write led strip
            ##
            self.wave.update(t) ##XXX: maybe also need modes for the led strip
            self.ledstrip.strip.show(self.ledstrip.buffer)

            sleep(0.01)
Esempio n. 19
0
    def __init__(self, sideclass=PiXXLSide):

        assert issubclass(sideclass, PiXXLSide)
        options = RGBMatrixOptions()

        self.settings = default_cube_settings
        self.settings["maxlight"] = self.settings.get("maxlight", 1000000)
        #cube specific defaults:
        options.rows = default_cube_settings["resolution"]
        options.cols = default_cube_settings["resolution"]
        options.chain_length = default_cube_settings["chain_length"]
        options.parallel = default_cube_settings["parallel"]
        options.brightness = default_cube_settings["brightness"]
        options.gpio_slowdown = default_cube_settings["gpio_slowdown"]

        #other led-matrix defaults:
        options.row_address_type = 0
        options.multiplexing = 0
        options.pwm_bits = 11
        options.pwm_lsb_nanoseconds = 130
        options.led_rgb_sequence = "RGB"
        options.pixel_mapper_config = ""
        options.drop_privileges = False

        self.options = options
        self.raw_accel_vector = []
        self.sides = []

        self.rendering = False
        self.time = time.time()

        for sidedata in default_cube_settings["sides"]:
            sidedata["res"] = default_cube_settings["resolution"]
            self.sides.append(sideclass(self, sidedata))

        self.gestureHandlers = []

        self.image = Image.new("RGB",
                               (self.options.chain_length * self.options.cols,
                                self.options.parallel * self.options.rows))

        self.framecouter = 0
Esempio n. 20
0
    def getOptions(self):
        options = RGBMatrixOptions()

        options.hardware_mapping = "regular"
        options.rows = 16
        options.cols = 32
        options.chain_length = 1
        options.parallel = 1
        options.row_address_type = 0
        options.multiplexing = 0
        options.pwm_bits = 11
        options.brightness = 50
        options.pwm_lsb_nanoseconds = 130
        options.led_rgb_sequence = "RGB"
        options.show_refresh_rate = 0
        options.gpio_slowdown = 4
        options.disable_hardware_pulsing = False
        options.scan_mode = 1

        return options
def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing = 6
    options.row_address_type = 0
    options.brightness = 80
    options.rows = number_of_rows_per_panel
    options.cols = number_of_columns_per_panel
    options.chain_length = number_of_panels
    options.parallel = parallel
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "BGR"
    options.gpio_slowdown = 1
    options.pwm_lsb_nanoseconds = 130
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = False
    options.scan_mode = 0
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options
Esempio n. 22
0
def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing = 0
    options.row_address_type = 0
    options.brightness = 100
    options.rows = led_panel_height
    options.cols = led_panel_width
    options.chain_length = 1
    options.parallel = 1
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "RGB"
    options.gpio_slowdown = 3
    options.pwm_lsb_nanoseconds = 150
    options.show_refresh_rate = 0
    options.disable_hardware_pulsing = True
    options.scan_mode = 0
    options.pwm_bits = 11
    options.daemon = 0
    options.drop_privileges = 0
    return options
Esempio n. 23
0
def get_options():
    options = RGBMatrixOptions()
    options.rows = 32
    options.cols = 64
    options.chain_length = 1
    options.parallel = 1
    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.pixel_mapper_config = ""
    options.panel_type = ""
    options.drop_privileges = False

    # optional
    #options.show_refresh_rate = 1
    options.gpio_slowdown = 3  # 1-4
    #options.disable_hardware_pulsing = False
    return options
Esempio n. 24
0
def InitMatrix():
    """Class for calling all graphical functions for the matrix."""
    # OPTIONS
    options = RGBMatrixOptions()
    options.rows = 16
    options.cols = 32
    options.chain_length = 1
    options.parallel = 1
    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.pixel_mapper_config = ""
    options.gpio_slowdown = 3
    options.drop_privileges = 0
    options.daemon = 0
    # Test speed
    # options.show_refresh_rate = 1 #~530HZ on wiimote version

    return RGBMatrix(options=options)
Esempio n. 25
0
    def process(self):
        options = RGBMatrixOptions()

        if self.args['led_gpio_mapping'] is not None:
            options.hardware_mapping = self.args['led_gpio_mapping']

        options.rows = self.args['led_rows']
        options.cols = self.args['led_cols']
        options.chain_length = self.args['led_chain']
        options.parallel = self.args['led_parallel']
        options.row_address_type = self.args['led_row_addr_type']
        options.multiplexing = self.args['led_multiplexing']
        options.pwm_bits = self.args['led_pwm_bits']
        options.brightness = self.args['led_brightness']
        options.pwm_lsb_nanoseconds = self.args['led_pwm_lsb_nanoseconds']
        options.led_rgb_sequence = self.args['led_rgb_sequence']
        options.pixel_mapper_config = self.args['led_pixel_mapper']
        options.panel_type = self.args['led_panel_type']

        if self.args['led_show_refresh']:
            options.show_refresh_rate = 1

        if self.args['led_slowdown_gpio'] is not None:
            options.gpio_slowdown = self.args['led_slowdown_gpio']

        if self.args['led_no_hardware_pulse']:
            options.disable_hardware_pulsing = True

        self.matrix = RGBMatrix(options=options)

        try:
            print('Press CTRL-C to stops')
            self.run()
        except KeyboardInterrupt:
            print('Exiting\n')
            sys.exit(0)

        return True
Esempio n. 26
0
    def process(self):
        self.args = self.parser.parse_args()

        options = RGBMatrixOptions()

        if self.args.led_gpio_mapping != None:
            options.hardware_mapping = self.args.led_gpio_mapping
        options.rows = NUM_ROWS
        options.cols = NUM_COLS
        options.chain_length = CHAIN_LEN
        options.parallel = self.args.led_parallel
        options.row_address_type = self.args.led_row_addr_type
        options.multiplexing = self.args.led_multiplexing
        options.pwm_bits = self.args.led_pwm_bits
        options.brightness = BRIGHTNESS
        options.pwm_lsb_nanoseconds = self.args.led_pwm_lsb_nanoseconds
        options.led_rgb_sequence = self.args.led_rgb_sequence
        options.pixel_mapper_config = self.args.led_pixel_mapper
        # options.panel_type = self.args.led_panel_type

        if self.args.led_show_refresh:
            options.show_refresh_rate = 1

        options.gpio_slowdown = GPIO_SLOWDOWN
        if self.args.led_no_hardware_pulse:
            options.disable_hardware_pulsing = True

        self.matrix = RGBMatrix(options=options)

        try:
            # Start loop
            print("Press CTRL-C to stop sample")
            self.run()
        except KeyboardInterrupt:
            print("Exiting\n")
            sys.exit(0)

        return True
Esempio n. 27
0
    def __init__(self, LEDFormat):
        logging.info('Initialising LEDMatrix')

        options = RGBMatrixOptions()

        options.hardware_mapping = LEDFormat['matrixDriver']
        options.rows = LEDFormat['matrixRows']
        options.cols = LEDFormat['matrixCols']
        options.chain_length = LEDFormat['matrixCount']
        options.pixel_mapper_config = LEDFormat['matrixMapper']

        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.show_refresh_rate = 0

        self.__MatrixID = RGBMatrix(options = options)
        
        self.__MatrixID.Clear()

        xsize = self.__MatrixID.width
        ysize = self.__MatrixID.height

        self.__LEDXSize = xsize
        self.__LEDYSize = ysize

        self.__LEDXMax = xsize - 1
        self.__LEDYMax = ysize - 1

        self.__DrawOnMatrix = True

        self.__MatrixCanvas = Canvas((self.__LEDXSize, self.__LEDYSize))
        self.__FadeMatrixCanvas = Canvas((self.__LEDXSize, self.__LEDYSize))

        self.__MatrixBuffer = self.__MatrixID.CreateFrameCanvas()
Esempio n. 28
0
def rgbmatrix_options():
    options = RGBMatrixOptions()
    options.multiplexing = 1
    options.row_address_type = 0
    options.brightness = 60
    options.rows = 64
    options.cols = 64
    options.chain_length = 1
    options.parallel = 1
    options.hardware_mapping = 'regular'
    options.inverse_colors = False
    options.led_rgb_sequence = "GBR"
    options.gpio_slowdown = 4
    options.pwm_lsb_nanoseconds = 50
    options.show_refresh_rate = 1
    options.disable_hardware_pulsing = False
    options.scan_mode = 1
    options.pwm_bits = 11
    # options.daemon = 0
    # options.drop_privileges = 0
    # options.pixel_mapper_config = "U-mapper;Rotate:90"
    options.pixel_mapper_config = "Rotate:90"
    return RGBMatrix(options=options)
Esempio n. 29
0
def init_leds():
    options = RGBMatrixOptions()

    options.hardware_mapping = 'regular'
    options.rows = 32
    options.cols = 64
    options.chain_length = 1
    options.parallel = 1
    options.row_address_type = 0
    options.multiplexing = 0
    options.brightness = 85
    options.pwm_bits = 8
    options.pwm_lsb_nanoseconds = 130
    options.led_rgb_sequence = 'RGB'
    options.pixel_mapper_config = ''
    options.panel_type = ''
    options.limit_refresh_rate_hz = 0  # no fps limit decreases the cpu usage
    options.show_refresh_rate = 0
    options.gpio_slowdown = 4
    options.disable_hardware_pulsing = False
    options.drop_privileges = False

    return RGBMatrix(options=options)
Esempio n. 30
0
    def __init__(self, gamepad):
        self.gamepad = gamepad
        self.player = SpaceShip()
        self.num_rocks = 10
        self.rocks = []
        for i in range(self.num_rocks):
            self.rocks.append(Rock())

        
        options = RGBMatrixOptions()
        options.hardware_mapping = "regular"
        options.rows = 64
        options.cols = 64
        options.chain_length = 1
        options.parallel = 1
        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.pixel_mapper_config = ""
        self.matrix = RGBMatrix(options = options)
Esempio n. 31
0
    def process(self):
        self.args = self.parser.parse_args()

        options = RGBMatrixOptions()

        if self.args.led_gpio_mapping != None:
          options.hardware_mapping = self.args.led_gpio_mapping
        options.rows = self.args.led_rows
        options.cols = self.args.led_cols
        options.chain_length = self.args.led_chain
        options.parallel = self.args.led_parallel
        options.row_address_type = self.args.led_row_addr_type
        options.multiplexing = self.args.led_multiplexing
        options.pwm_bits = self.args.led_pwm_bits
        options.brightness = self.args.led_brightness
        options.pwm_lsb_nanoseconds = self.args.led_pwm_lsb_nanoseconds
        options.led_rgb_sequence = self.args.led_rgb_sequence
        options.pixel_mapper_config = self.args.led_pixel_mapper
        if self.args.led_show_refresh:
          options.show_refresh_rate = 1

        if self.args.led_slowdown_gpio != None:
            options.gpio_slowdown = self.args.led_slowdown_gpio
        if self.args.led_no_hardware_pulse:
          options.disable_hardware_pulsing = True

        self.matrix = RGBMatrix(options = options)

        try:
            # Start loop
            print("Press CTRL-C to stop sample")
            self.run()
        except KeyboardInterrupt:
            print("Exiting\n")
            sys.exit(0)

        return True
Esempio n. 32
0
import os
import random
import time
import datetime
import numpy as np
import scipy.misc as misc
from rgbmatrix import RGBMatrix, RGBMatrixOptions

dir_path = os.path.dirname(os.path.realpath(__file__))

options = RGBMatrixOptions()
options.rows = 32
options.chain_length = 1
options.parallel = 1
options.hardware_mapping = 'adafruit-hat-pwm'
options.multiplexing = 1
options.pwm_bits = 8
options.scan_mode = 0
options.gpio_slowdown = 1
options.pwm_lsb_nanoseconds = 260
#options.show_refresh_rate = 1
#options.daemon = 1

runthrough_min = 10

matrix = RGBMatrix(options=options)

radius = 12 * 10
start = 160 - radius
diameter = radius * 2
color = (88, 88, 88)
Esempio n. 33
0
def init():
    global toolDraw
    global myFont, myFontSmall, myFontMedium
    global rtcString
    global sec
    global matrix
    global ds3231
    global COMport
    global buffer
    global rtc_str

    time.sleep(5)

    dataFile = open("/home/pi/kristallvelolite/count.txt", "r")
    data = dataFile.readlines()
    for i, temp in enumerate(data):
        record = list(map(int, temp.split()))
        key1 = "today "+str(i+1)
        key2 = "all " + str(i + 1)
        count[key1] = record[0]
        count[key2] = record[1]
    dataFile.close()
    
# Vlad 11.06.2020
    try:
      COMport = serial.Serial(serial_port, serial_speed, timeout=None)
      print(serial_port)
    except:
      COMport = serial.Serial("/dev/ttyUSB1", serial_speed, timeout=None)
      print('ComPort ttyUSB1')
############################## 
    COMport.close()
    COMport.open() #Vlad 11.06.2020
    COMport.reset_input_buffer()

    myFont = ImageFont.truetype(font_name, font_size)
    myFontSmall = ImageFont.truetype(font_name, small_font_size)
    myFontMedium = ImageFont.truetype(font_name, medium_font_size)

    buffer = Image.new("RGB", (768, 32), "black")
    toolDraw = ImageDraw.Draw(buffer)
    print_matrix(0, "   15:19\n 06.06.19", color1, myFontSmall)
    print_matrix(1, str(temperature)+"°C", color1, myFontMedium)
    print_matrix(2, str(count["today 1"]), color1, myFont)
    print_matrix(4, str(count["all 1"]), color2, myFont)
    print_matrix(6, "   15:19\n 06.06.19", color1, myFontSmall)
    print_matrix(7, str(temperature)+"°C", color1, myFontMedium)
    print_matrix(8, str(count["today 2"]), color1, myFont)
    print_matrix(10, str(count["all 2"]), color2, myFont)

    sec = 0

    ds3231 = SDL_DS3231.SDL_DS3231(1, 0x68)
    rtc_str = ds3231.read_str()

    matrix_options = RGBMatrixOptions()
    matrix_options.rows = 32
    matrix_options.cols = 64
    matrix_options.chain_length = 12
    matrix_options.parallel = 1
    matrix_options.multiplexing = 1
    matrix_options.hardware_mapping = 'adafruit-hat'
    matrix_options.gpio_slowdown = 2
    matrix_options.pwm_bits = 1
    #matrix_options.pwm_dither_bits = 1
    matrix_options.brightness = 100
    matrix_options.pwm_lsb_nanoseconds = 350
    matrix = RGBMatrix(options = matrix_options)
    matrix.SetImage(buffer, 0, 0)
Esempio n. 34
0
    first_run = True
    ledpi = LEDPi()
    while not run_once or first_run:
        first_run = False
        matrix = ledpi.display_clock()
        if matrix:
            send_matrix(driver, matrix)
    time.sleep(3)
    driver.Clear()


if __name__ == '__main__':
    logging.basicConfig(
        level=logging.INFO,
        format='%(asctime)s [%(levelname)s] in %(funcName)s: %(message)s')

    parser = argparse.ArgumentParser()
    parser.add_argument('--run-once', action='store_true')
    args = parser.parse_args()

    options = RGBMatrixOptions()
    options.rows = 32
    options.cols = 32
    options.chain_length = 2
    options.parallel = 1
    options.multiplexing = 0
    options.hardware_mapping = 'adafruit-hat-pwm'
    driver = RGBMatrix(options=options)

    main(driver, args.run_once)