def _rotate(self, buf): """ Rotates tiles in the buffer by the given orientation """ result = [] for i in range(0, self._cascaded * self.NUM_DIGITS, self.NUM_DIGITS): tile = buf[i:i + self.NUM_DIGITS] for _ in range(self._orientation // 90): tile = rotate(tile) result += tile return result
def flush(self): """ For each digit/column, cascade out the contents of the buffer cells to the SPI device. """ # Allow subclasses to pre-process the buffer: they shouldn't # alter it, so make a copy first. buf = self._preprocess_buffer(list(self._buffer)) assert len(buf) == len(self._buffer), "Preprocessed buffer is wrong size" if self._vertical: tmp_buf = [] for x in range(0, self._cascaded): tmp_buf += rotate(buf[x*8:x*8+8]) buf = tmp_buf for posn in range(self.NUM_DIGITS): self._write(self._values(posn, buf))