From c150e21a49560759497515a1d715e9490815f560 Mon Sep 17 00:00:00 2001 From: "Andrew J.Swan" Date: Fri, 7 Jun 2024 00:00:13 +0300 Subject: [PATCH] 2024.6.1: Add **flip_flop_speed** (optional, int): Set flip_flop_clock speed. (default: 2, range 1..10). --- README.md | 2 ++ components/ehmtxv2/EHMTX.cpp | 4 ++-- components/ehmtxv2/__init__.py | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1c03cb1..6b9fef3 100644 --- a/README.md +++ b/README.md @@ -908,6 +908,8 @@ ehmtxv2: **flip_flop_clock** (optional, boolean): Enables or disables flip_flop_clock clock mode. (default: false), works only in **advanced_clock** mode. +**flip_flop_speed** (optional, int): Set flip_flop_clock speed. (default: 2, range 1..10), works only in **advanced_clock** mode. + **advanced_bitmap** (optional, boolean): Enables or disables advanced bitmap mode. (default: false) [More info](#advanced-bitmap-mode) **default_font_yoffset** (optional, pixel): yoffset the text is aligned BASELINE_LEFT, the baseline defaults to `6` diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 30f1501..29c8955 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -2608,7 +2608,7 @@ namespace esphome #ifdef EHMTXv2_FLIP_FLOP bool step = false; - uint8_t y = ystep / 2; + uint8_t y = ystep / EHMTXv2_FLIP_FLOP_SPEED; if (i == 0) // Hours { @@ -2708,7 +2708,7 @@ namespace esphome if (step) { ystep++; - if (ystep == 16) + if (ystep == 8 * EHMTXv2_FLIP_FLOP_SPEED) { hours = h; minutes = m; diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index bdb561e..6d97d69 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -97,6 +97,7 @@ def rgb565_888(v565): CONF_VERTICAL = "vertical_scroll" CONF_CLOCK = "advanced_clock" CONF_FLIP_FLOP = "flip_flop_clock" +CONF_FLIP_FLOP_SPEED = "flip_flop_speed" CONF_BITMAP = "advanced_bitmap" CONF_BOOTLOGO = "boot_logo" CONF_BOOTLOGOMODE = "boot_logo_mode" @@ -173,6 +174,9 @@ def rgb565_888(v565): cv.Optional( CONF_FLIP_FLOP, default=False ): cv.boolean, + cv.Optional( + CONF_FLIP_FLOP_SPEED, default="2" + ): cv.templatable(cv.int_range(min=1, max=10)), cv.Optional( CONF_BITMAP, default=False ): cv.boolean, @@ -616,6 +620,9 @@ def thumbnails(frames): if config[CONF_CLOCK] and config[CONF_FLIP_FLOP]: cg.add_define("EHMTXv2_FLIP_FLOP") logging.info(f"[X] Flip Flop clock mode") + if config[CONF_FLIP_FLOP_SPEED]: + cg.add_define("EHMTXv2_FLIP_FLOP_SPEED", config[CONF_FLIP_FLOP_SPEED]) + logging.info(f"[X] Flip Flop Speed " + str(config[CONF_FLIP_FLOP_SPEED])) if config[CONF_BITMAP]: cg.add_define("EHMTXv2_ADV_BITMAP")