From c684ecba49ce807dac9df68e43297ee249c5f5c5 Mon Sep 17 00:00:00 2001 From: Joshua King Date: Fri, 6 Mar 2026 14:14:14 -0500 Subject: [PATCH] Refactor display initialization and update configuration for improved stability in Cat Medication Tracker --- esphome/cat-medication-tracker.yaml | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/esphome/cat-medication-tracker.yaml b/esphome/cat-medication-tracker.yaml index 44956df..4bf1255 100644 --- a/esphome/cat-medication-tracker.yaml +++ b/esphome/cat-medication-tracker.yaml @@ -8,12 +8,6 @@ esphome: on_boot: priority: 100 then: - - light.turn_on: - id: backlight - brightness: 100% - - delay: 300ms - - light.turn_off: backlight - - delay: 300ms - light.turn_on: backlight - delay: 300ms - component.update: my_display @@ -70,7 +64,7 @@ display: cs_pin: GPIO15 dc_pin: GPIO2 reset_pin: GPIO4 - # rotation: 0 # Commenting out; overriding MADCTL manually below for better compatibility + rotation: 0 invert_colors: true color_order: bgr data_rate: 10MHz # Reduced from 20MHz to improve stability @@ -80,13 +74,9 @@ display: id: my_display auto_clear_enabled: false update_interval: 2s - color_depth: 18 # Key fix: align with 0x3A 0x66 (18-bit mode) + color_depth: 16 buffer_size: 25% lambda: |- - // Quick test: fill entire screen bright red to confirm display is alive - // Comment out once working - it.fill(Color(255, 0, 0)); - // Colors auto red = Color(255, 0, 0); auto green = Color(0, 200, 0); @@ -95,10 +85,6 @@ display: auto black = Color(0, 0, 0); auto dark_grey = Color(80, 80, 80); - // Force common MADCTL for portrait (try 0x28, 0x48, 0x68, 0x98 if still wrong orientation) - it.command(0x36); - it.data(0x28); // ← Try this first; change to 0x48 / 0x68 etc. if upside-down/mirrored - // Fill background it.fill(light_grey); @@ -147,6 +133,7 @@ display: it.filled_rectangle(reset_x, reset_y, reset_w, reset_h, dark_grey); it.rectangle(reset_x, reset_y, reset_w, reset_h, black); it.printf(reset_x + reset_w/2, reset_y + reset_h/2, id(status_font), white, TextAlign::CENTER, "RESET"); + # XPT2046 Touchscreen touchscreen: - platform: xpt2046