feat(hal): read display rotation from hardware_config.json
Python CI / test (3.12) (push) Canceled after 0s
Python CI / test (3.13) (push) Canceled after 0s

Load the full hardware config up front rather than only the GPIO section,
so display settings can come from the same file. Adds a rotate parameter
that falls back to display.rotate in the config when not passed
explicitly, and logs the resolved value.

Also bumps the dreader-hal submodule to 64c9177 (use partial draw) and
adds a direct IT8951 example that bypasses the HAL, for isolating display
problems to the driver layer.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-08 22:28:02 +02:00
co-authored by Claude Opus 5
parent f7d59d025f
commit ed05dc9c2d
3 changed files with 134 additions and 13 deletions
+23 -12
View File
@@ -140,6 +140,7 @@ class HardwareDisplayHAL(DisplayHAL):
height: int = 1404,
vcom: float = -2.0,
spi_hz: int = 24_000_000,
rotate: Optional[str] = None,
virtual_display: bool = False,
auto_sleep_display: bool = True,
enable_orientation: bool = True,
@@ -170,8 +171,29 @@ class HardwareDisplayHAL(DisplayHAL):
self.width = width
self.height = height
# Load config from file to get display settings
full_config = None
if config_file or gpio_config is None:
config_path = Path(config_file or "hardware_config.json")
if config_path.exists():
try:
with open(config_path, 'r') as f:
full_config = json.load(f)
logger.info(f"Loaded hardware config from {config_path}")
# Override display parameters from config if not explicitly provided
display_config = full_config.get('display', {})
if rotate is None and 'rotate' in display_config:
rotate = display_config['rotate']
logger.info(f" Using rotate from config: {rotate}")
gpio_config = full_config
except Exception as e:
logger.warning(f"Could not load hardware config from {config_path}: {e}")
logger.info(f"Initializing HardwareDisplayHAL: {width}x{height}")
logger.info(f" VCOM: {vcom}V")
logger.info(f" Rotate: {rotate}")
logger.info(f" Virtual display: {virtual_display}")
logger.info(f" Orientation: {enable_orientation}")
logger.info(f" RTC: {enable_rtc}")
@@ -183,6 +205,7 @@ class HardwareDisplayHAL(DisplayHAL):
height=height,
vcom=vcom,
spi_hz=spi_hz,
rotate=rotate,
virtual_display=virtual_display,
auto_sleep_display=auto_sleep_display,
enable_orientation=enable_orientation,
@@ -195,18 +218,6 @@ class HardwareDisplayHAL(DisplayHAL):
# GPIO button handler (optional)
self.gpio_handler: Optional[GPIOButtonHandler] = None
# Load GPIO config from file if specified
if config_file or gpio_config is None:
config_path = Path(config_file or "hardware_config.json")
if config_path.exists():
try:
with open(config_path, 'r') as f:
full_config = json.load(f)
gpio_config = full_config
logger.info(f"Loaded hardware config from {config_path}")
except Exception as e:
logger.warning(f"Could not load hardware config from {config_path}: {e}")
# Initialize GPIO buttons if configured
if gpio_config and GPIO_BUTTONS_AVAILABLE:
try: