diff --git a/adafruit_featherwing/matrix_featherwing.py b/adafruit_featherwing/matrix_featherwing.py index 2c54d68..bbb2205 100755 --- a/adafruit_featherwing/matrix_featherwing.py +++ b/adafruit_featherwing/matrix_featherwing.py @@ -110,11 +110,7 @@ def shift_right(self, rotate=False): :param rotate: (Optional) Rotate the shifted pixels to the left side (default=False) """ - for y in range(0, self.rows): - last_pixel = self._matrix[self.columns - 1, y] if rotate else 0 - for x in range(self.columns - 1, 0, -1): - self._matrix[x, y] = self._matrix[x - 1, y] - self._matrix[0, y] = last_pixel + self._matrix.shift_right(rotate) self._update() def shift_left(self, rotate=False): @@ -123,11 +119,7 @@ def shift_left(self, rotate=False): :param rotate: (Optional) Rotate the shifted pixels to the right side (default=False) """ - for y in range(0, self.rows): - last_pixel = self._matrix[0, y] if rotate else 0 - for x in range(0, self.columns - 1): - self._matrix[x, y] = self._matrix[x + 1, y] - self._matrix[self.columns - 1, y] = last_pixel + self._matrix.shift_left(rotate) self._update() def shift_up(self, rotate=False): @@ -136,11 +128,7 @@ def shift_up(self, rotate=False): :param rotate: (Optional) Rotate the shifted pixels to bottom (default=False) """ - for x in range(0, self.columns): - last_pixel = self._matrix[x, self.rows - 1] if rotate else 0 - for y in range(self.rows - 1, 0, -1): - self._matrix[x, y] = self._matrix[x, y - 1] - self._matrix[x, 0] = last_pixel + self._matrix.shift_up(rotate) self._update() def shift_down(self, rotate=False): @@ -149,11 +137,7 @@ def shift_down(self, rotate=False): :param rotate: (Optional) Rotate the shifted pixels to top (default=False) """ - for x in range(0, self.columns): - last_pixel = self._matrix[x, 0] if rotate else 0 - for y in range(0, self.rows - 1): - self._matrix[x, y] = self._matrix[x, y + 1] - self._matrix[x, self.rows - 1] = last_pixel + self._matrix.shift_down(rotate) self._update() @property diff --git a/adafruit_featherwing/pixelmatrix.py b/adafruit_featherwing/pixelmatrix.py index 17e82b3..d37ebce 100755 --- a/adafruit_featherwing/pixelmatrix.py +++ b/adafruit_featherwing/pixelmatrix.py @@ -76,17 +76,16 @@ def _get_index(self, indices): if not 0 <= indices < self.rows * self.columns: raise ValueError('The index of {} is out of range'.format(indices)) return indices - elif isinstance(indices, slice): + if isinstance(indices, slice): return indices - elif len(indices) == 2: + if len(indices) == 2: x, y = indices if not 0 <= x < self.columns: raise ValueError('The X value of {} is out of range'.format(x)) if not 0 <= y < self.rows: raise ValueError('The Y value of {} is out of range'.format(y)) return y * self.columns + x - else: - raise ValueError('Index must be 1 or 2 number') + raise ValueError('Index must be 1 or 2 number') def _update(self): """ diff --git a/adafruit_featherwing/rtc_featherwing.py b/adafruit_featherwing/rtc_featherwing.py index fe6af74..2e2d28f 100755 --- a/adafruit_featherwing/rtc_featherwing.py +++ b/adafruit_featherwing/rtc_featherwing.py @@ -78,8 +78,7 @@ def _get_time_value(self, unit): now = self._get_now() if unit in now: return now[unit] - else: - raise ValueError('The specified unit of time is invalid') + raise ValueError('The specified unit of time is invalid') def _get_now(self): """