Ejemplo n.º 1
0
    def makeImpl(self, test, mask_pattern):
        self.modules_count = self.version * 4 + 17
        self.modules = [None] * self.modules_count

        for row in range(self.modules_count):

            self.modules[row] = [None] * self.modules_count

            for col in range(self.modules_count):
                self.modules[row][col] = None   # (col + row) % 3

        self.setup_position_probe_pattern(0, 0)
        self.setup_position_probe_pattern(self.modules_count - 7, 0)
        self.setup_position_probe_pattern(0, self.modules_count - 7)
        self.sutup_position_adjust_pattern()
        self.setup_timing_pattern()
        self.setup_type_info(test, mask_pattern)

        if self.version >= 7:
            self.setup_type_number(test)

        if self.data_cache is None:
            self.data_cache = util.create_data(
                self.version, self.error_correction, self.data_list)
        self.map_data(self.data_cache, mask_pattern)
Ejemplo n.º 2
0
 def best_fit(self, start=None):
     """
     Find the minimum size required to fit in the data.
     """
     size = start or 1
     while True:
         try:
             self.data_cache = util.create_data(
                 size, self.error_correction, self.data_list)
         except exceptions.DataOverflowError:
             size += 1
         else:
             self.version = size
             return size