+
+ if isinstance(refresh_display_command, int):
+ refresh_sequence = bytearray([refresh_display_command, 0])
+ if two_byte_sequence_length:
+ refresh_sequence += bytes([0])
+ elif isinstance(refresh_display_command, ReadableBuffer):
+ refresh_sequence = bytearray(refresh_display_command)
+ else:
+ raise ValueError("Invalid refresh_display_command")
+
+ if write_color_ram_command is None:
+ write_color_ram_command = NO_COMMAND
+
+ if rotation % 90 != 0:
+ raise ValueError("Display rotation must be in 90 degree increments")
+
+ color_depth = 1
+ core_grayscale = True
+
+ if advanced_color_epaper:
+ color_depth = 4
+ grayscale = False
+ core_grayscale = False
+
+ self._core = _DisplayCore(
+ bus=display_bus,
+ width=width,
+ height=height,
+ ram_width=ram_width,
+ ram_height=ram_height,
+ colstart=colstart,
+ rowstart=rowstart,
+ rotation=rotation,
+ color_depth=color_depth,
+ grayscale=core_grayscale,
+ pixels_in_byte_share_row=True,
+ bytes_per_cell=1,
+ reverse_pixels_in_byte=True,
+ reverse_bytes_in_word=True,
+ column_command=set_column_window_command,
+ row_command=set_row_window_command,
+ set_current_column_command=set_current_column_command,
+ set_current_row_command=set_current_row_command,
+ data_as_commands=False,
+ always_toggle_chip_select=always_toggle_chip_select,
+ sh1107_addressing=False,
+ address_little_endian=address_little_endian,
+ )
+
+ if highlight_color != 0x000000:
+ self._core.colorspace.tricolor = True
+ self._core.colorspace.tricolor_hue = ColorConverter._compute_hue(
+ highlight_color
+ )
+ self._core.colorspace.tricolor_luma = ColorConverter._compute_luma(
+ highlight_color
+ )
+ else:
+ self._core.colorspace.tricolor = False
+
+ self._acep = advanced_color_epaper
+ self._core.colorspace.sevencolor = advanced_color_epaper
+ self._write_black_ram_command = write_black_ram_command
+ self._black_bits_inverted = black_bits_inverted
+ self._write_color_ram_command = write_color_ram_command
+ self._color_bits_inverted = color_bits_inverted
+ self._refresh_time = (
+ refresh_time # TODO: Verify we are using seconds instead of ms
+ )
+ self._busy_state = busy_state
+ self._refreshing = False
+ self._milliseconds_per_frame = seconds_per_frame * 1000
+ self._chip_select = (
+ CHIP_SELECT_TOGGLE_EVERY_BYTE
+ if always_toggle_chip_select
+ else CHIP_SELECT_UNTOUCHED
+ )
+ self._grayscale = grayscale
+
+ self._start_sequence = start_sequence
+ self._start_up_time = (
+ start_up_time # TODO: Verify we are using seconds instead of ms
+ )
+ self._stop_sequence = stop_sequence
+ self._refesh_sequence = refresh_sequence
+ self._busy = None
+ self._two_byte_sequence_length = two_byte_sequence_length
+ if busy_pin is not None:
+ self._busy = DigitalInOut(busy_pin)
+ self._busy.switch_to_input()
+
+ # Clear the color memory if it isn't in use
+ if highlight_color == 0x00 and write_color_ram_command != NO_COMMAND:
+ """TODO: Clear"""
+
+ self.show(circuitpython_splash)
+
+ def __new__(cls, *args, **kwargs):
+ from . import ( # pylint: disable=import-outside-toplevel, cyclic-import
+ allocate_display,
+ )
+
+ display_instance = super().__new__(cls)
+ allocate_display(display_instance)
+ return display_instance