mirror of
https://github.com/esphome/esphome.git
synced 2025-10-08 04:43:46 +01:00
[mipi] Fix rotation handling (#11010)
This commit is contained in:
@@ -343,11 +343,7 @@ class DriverChip:
|
|||||||
)
|
)
|
||||||
offset_height = native_height - height - offset_height
|
offset_height = native_height - height - offset_height
|
||||||
# Swap default dimensions if swap_xy is set, or if rotation is 90/270 and we are not using a buffer
|
# Swap default dimensions if swap_xy is set, or if rotation is 90/270 and we are not using a buffer
|
||||||
rotated = not requires_buffer(config) and config.get(CONF_ROTATION, 0) in (
|
if transform.get(CONF_SWAP_XY) is True:
|
||||||
90,
|
|
||||||
270,
|
|
||||||
)
|
|
||||||
if transform.get(CONF_SWAP_XY) is True or rotated:
|
|
||||||
width, height = height, width
|
width, height = height, width
|
||||||
offset_height, offset_width = offset_width, offset_height
|
offset_height, offset_width = offset_width, offset_height
|
||||||
return width, height, offset_width, offset_height
|
return width, height, offset_width, offset_height
|
||||||
|
@@ -380,25 +380,41 @@ def get_instance(config):
|
|||||||
bus_type = BusTypes[bus_type]
|
bus_type = BusTypes[bus_type]
|
||||||
buffer_type = cg.uint8 if color_depth == 8 else cg.uint16
|
buffer_type = cg.uint8 if color_depth == 8 else cg.uint16
|
||||||
frac = denominator(config)
|
frac = denominator(config)
|
||||||
rotation = DISPLAY_ROTATIONS[
|
rotation = (
|
||||||
0 if model.rotation_as_transform(config) else config.get(CONF_ROTATION, 0)
|
0 if model.rotation_as_transform(config) else config.get(CONF_ROTATION, 0)
|
||||||
]
|
)
|
||||||
templateargs = [
|
templateargs = [
|
||||||
buffer_type,
|
buffer_type,
|
||||||
bufferpixels,
|
bufferpixels,
|
||||||
config[CONF_BYTE_ORDER] == "big_endian",
|
config[CONF_BYTE_ORDER] == "big_endian",
|
||||||
display_pixel_mode,
|
display_pixel_mode,
|
||||||
bus_type,
|
bus_type,
|
||||||
width,
|
|
||||||
height,
|
|
||||||
offset_width,
|
|
||||||
offset_height,
|
|
||||||
]
|
]
|
||||||
# If a buffer is required, use MipiSpiBuffer, otherwise use MipiSpi
|
# If a buffer is required, use MipiSpiBuffer, otherwise use MipiSpi
|
||||||
if requires_buffer(config):
|
if requires_buffer(config):
|
||||||
templateargs.append(rotation)
|
templateargs.extend(
|
||||||
templateargs.append(frac)
|
[
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
offset_width,
|
||||||
|
offset_height,
|
||||||
|
DISPLAY_ROTATIONS[rotation],
|
||||||
|
frac,
|
||||||
|
]
|
||||||
|
)
|
||||||
return MipiSpiBuffer, templateargs
|
return MipiSpiBuffer, templateargs
|
||||||
|
# Swap height and width if the display is rotated 90 or 270 degrees in software
|
||||||
|
if rotation in (90, 270):
|
||||||
|
width, height = height, width
|
||||||
|
offset_width, offset_height = offset_height, offset_width
|
||||||
|
templateargs.extend(
|
||||||
|
[
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
offset_width,
|
||||||
|
offset_height,
|
||||||
|
]
|
||||||
|
)
|
||||||
return MipiSpi, templateargs
|
return MipiSpi, templateargs
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user