def testGetMatrixShape8x8(self):
     """ Ensure 8x8 is determined properly. """
     m = matrix_manager.MatrixInterface(led_rows=8, chain_length=1)
     self.assertEqual(m.shape, [self.one])
     self.assertEqual(m.width, 8)
     self.assertEqual(m.height, 8)
     self.assertEqual(m.tile_size, 8)
 def testGetMatrixShape32x16(self):
     """ Ensure 32x16 is determined properly. """
     m = matrix_manager.MatrixInterface(led_rows=16, chain_length=2)
     self.assertEqual(m.shape, [self.two])
     self.assertEqual(m.width, 32)
     self.assertEqual(m.height, 16)
     self.assertEqual(m.tile_size, 16)
 def testGetMatrixShape64x32(self):
     """ Ensure 64x32 is determined properly. """
     m = matrix_manager.MatrixInterface(led_rows=32, chain_length=2)
     self.assertEqual(m.shape, [self.two])
     self.assertEqual(m.width, 64)
     self.assertEqual(m.height, 32)
     self.assertEqual(m.tile_size, 32)
  def __init__(self, tiles, led_rows=32, chain_length=2, write_cycles=2,
               tile_size=None, fps=1, static_lifespan=5):
    """ Initalize tile manager.

    Args:
      tiles: List of BaseTile subclassed objects with data to display.
      led_rows: Integer size of RGB matrix hat. Default: 32.
      chain_length: Integer number of matrix's attached. Default: 2.
      write_cycles: Integer write cycle speed, higher is slower. Default: 2.
      tile_size: Integer minimum square tile size in pixels. Default: None (same
        as led_rows).
      fps: Integer max number of frames to render a second, max 60. Default: 1.
          Raspberry Pi's have limited processing power, so 60 is not
          recommended.
      static_lifespan: Integer number of seconds a static tile should be
          displayed before being cleared. Default: 5 seconds.
      render_pipline: List of Lists (matrix) containing Integer indexes
          representing the tile to display. This matrix shape is generated from
          the matrix_manager.
    """
    self.tiles = tiles
    self.matrix = matrix_manager.MatrixInterface(led_rows,
                                                 chain_length,
                                                 write_cycles,
                                                 tile_size)
    self.fps = fps
    self.static_lifespan = static_lifespan
    self.render_pipeline = self.matrix.shape
    (self.max_tile_width, self.max_tile_height) = self._InitalizeTiles()
    self._current_time = 0.0
    self._previous_time = 0.0
 def testGetMatrixShape64x64SmallTile(self):
     """ Ensure 64x64 with small tiles is determined properly. """
     m = matrix_manager.MatrixInterface(led_rows=64,
                                        chain_length=2,
                                        tile_size=32)
     self.assertEqual(m.shape, [self.two, self.two])
     self.assertEqual(m.width, 64)
     self.assertEqual(m.height, 64)
     self.assertEqual(m.tile_size, 32)
 def setUp(self):
     """ Initalize Matrix Manager test setup. """
     self.matrix = matrix_manager.MatrixInterface()
     self.one = [None]
     self.two = [None, None]