diff --git a/README.md b/README.md index b17268e..ffb4a5f 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ You can call this from e.g. the [developer tools service](https://my.home-assist clock_screen => {"lifetime", "screen_time", "default_font", "r", "g", "b"} rainbow_clock_screen => {"lifetime", "screen_time", "default_font"} date_screen => {"lifetime", "screen_time", "default_font", "r", "g", "b"} +rainbow_date_screen => {"lifetime", "screen_time", "default_font"} ``` ###### Lambda @@ -479,8 +480,6 @@ ehmtxv2: **id** (required, ID): Manually specify the ID used for code generation and in service definitions. -**hold_time** (optional, seconds): extends the display time of the current screen in seconds (default=20). Used in services or automations, see `hold_screen` - **date_format** (optional, string): formats the date display with [strftime syntax](https://esphome.io/components/time.html?highlight=strftime), defaults `"%d.%m."` (use `"%m.%d."` for the US) **show_seconds** (optional, boolean): toggle an indicator for seconds while the clock is displayed (default: false) @@ -542,6 +541,38 @@ See [icon details](#icons-and-animations) A lot of features are accessible with actions, you can use in your YAML. +### Public functions/services + |service|parameter|result| + |---|---|---|---| + `status`|none|write some status information to the esphome logs| + `display_on`|none|turn display off| + `display_off`|none|turn display on| + `hold_screen`|none|show the screen that is currently displayed for the number of seconds longer| + `hide_indicator`|none|hides the indicator| + `hide_gauge`|none|hides the gauge| + `hide_alarm`|none|hides the alarm| + `show_gauge"`|"percent", "r", "g", "b"|set the heught of the gauge according to the percentage in the given color| + `show_alarm`|"r", "g", "b", "size"|shows the color with the given size in the upper right corner| + `show_indicator`|"r", "g", "b", "size"|shows the color with the given size in the lower right corner| + + `clock_color`|"r", "g", "b"|set the default color for the clock/date display| + `today_color"`|"r", "g", "b"|set the special color for today in the day of week line| + `weekday_color"`|"r", "g", "b"|set the default color in the day of week line| + + `del_screen`|"icon_name", "mode"|deletes the specified icon screen from the queue, the [mode](#modes) is a filter| + `force_screen`|"icon_name", "mode"|displayes the seleted the specified icon screen from the queue, the [mode](#modes) is a filter| + + `full_screen`|"icon_name", "lifetime", "screen_time"|show the specified icon as fullscreen| + `icon_screen`|"icon_name", "text", "lifetime", "screen_time", "default_font", "r", "g", "b"|show the specified icon with text| + `rainbow_icon_screen`|"icon_name", "text", "lifetime", "screen_time", "default_font"|show the specified icon with text in rainbow color| + `text_screen`|"text", "lifetime", "screen_time", "default_font", "r", "g", "b"|show the specified text| + `rainbow_text_screen`|"text", "lifetime", "screen_time", "default_font"|show the specified text in rainbow colors| + `clock_screen`|"lifetime", "screen_time", "default_font", "r", "g", "b"|show the clock| + `rainbow_clock_screen`|"lifetime", "screen_time", "default_font"|show the clock in rainbow color| + `blank_screen`|"lifetime", "screen_time"|"show" an empty screen| + `date_screen`|"lifetime", "screen_time", "default_font", "r", "g", "b"|show the date| + `brightness`|"value"|set the display brightness| + ### Local actions/lambdas #### Add screen to your display queue @@ -681,6 +712,8 @@ For example, if you have multiple icons named weather_sunny, weather_rain & weat - ```icon_name```: Icon `id` defined in the YAML (see installation) - ```mode```: The mode is for internal purposes use `5` for icon_screen +##### modes + |mode|value| |----|----| |MODE_BLANK|1| @@ -689,6 +722,10 @@ For example, if you have multiple icons named weather_sunny, weather_rain & weat | MODE_FULL_SCREEN | 4| |MODE_ICONSCREEN | 5| |MODE_TEXT | 6| +|MODE_RAINBOW_ICON | 7| +|MODE_RAINBOW_TEXT |8| +| MODE_RAINBOW_CLOCK | 9| +| MODE_RAINBOW_DATE | 10| **(D)** Service **display_on** / **display_off** @@ -733,7 +770,7 @@ binary_sensor: Service **hold_screen** -Displays the current screen for a configured amount (see **hold_time**) (default=20) seconds longer. +Displays the current screen for a configured amount (see **hold_time**) (default=30) seconds longer. e.g. on the Ulanzi TC001 @@ -745,7 +782,7 @@ binary_sensor: inverted: true on_press: lambda: - id(rgb8x32)->hold_screen(); + id(rgb8x32)->hold_screen(120); ``` **(D)** Service **status** diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 7f697ca..e6fa054 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -9,6 +9,7 @@ namespace esphome this->display_indicator = 0; this->display_alarm = 0; this->clock_time = 10; + this->hold_time = 10; this->icon_count = 0; this->hue_ = 0; this->text_color = Color(C_RED, C_GREEN, C_BLUE); @@ -158,7 +159,7 @@ namespace esphome register_service(&EHMTX::get_status, "status"); register_service(&EHMTX::set_display_on, "display_on"); register_service(&EHMTX::set_display_off, "display_off"); - register_service(&EHMTX::hold_screen, "hold_screen"); + register_service(&EHMTX::hold_screen, "hold_screen", {"time"}); register_service(&EHMTX::hide_indicator, "hide_indicator"); register_service(&EHMTX::hide_gauge, "hide_gauge"); register_service(&EHMTX::hide_alarm, "hide_alarm"); @@ -385,9 +386,10 @@ namespace esphome this->next_action_time = this->clock->now().timestamp - 1; } - void EHMTX::hold_screen() + void EHMTX::hold_screen(int time) { this->next_action_time += this->hold_time; + this->hold_time = time; } void EHMTX::get_status() @@ -765,11 +767,6 @@ namespace esphome this->clock_time = t; } - void EHMTX::set_hold_time(uint16_t t) - { - this->hold_time = t; - } - void EHMTX::set_scroll_count(uint8_t c) { this->scroll_count = c; diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index e32c1ab..8abf226 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -23,7 +23,7 @@ const uint8_t TEXTSTARTOFFSET = (32 - 8); const uint16_t TICKINTERVAL = 1000; // each 1000ms static const char *const EHMTX_VERSION = "Version: 2023.5.0 beta"; static const char *const TAG = "EHMTXv2"; -enum show_mode : uint8_t { MODE_EMPTY = 0,MODE_BLANK = 1, MODE_CLOCK = 2, MODE_DATE = 3, MODE_FULL_SCREEN = 4, MODE_ICONSCREEN = 5, MODE_TEXT = 6 , MODE_RAINBOW_ICON = 7,MODE_RAINBOW_TEXT = 8, MODE_RAINBOW_CLOCK = 9 }; +enum show_mode : uint8_t { MODE_EMPTY = 0,MODE_BLANK = 1, MODE_CLOCK = 2, MODE_DATE = 3, MODE_FULL_SCREEN = 4, MODE_ICONSCREEN = 5, MODE_TEXT = 6 , MODE_RAINBOW_ICON = 7,MODE_RAINBOW_TEXT = 8, MODE_RAINBOW_CLOCK = 9,MODE_RAINBOW_DATE=10 }; namespace esphome { @@ -99,7 +99,7 @@ namespace esphome void get_status(); void queue_status(); void skip_screen(); - void hold_screen(); + void hold_screen(int t=30); void set_display(addressable_light::AddressableLightDisplay *disp); void set_hold_time(uint16_t t=30); diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index 32c1173..c3eeec7 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -52,6 +52,9 @@ namespace esphome case MODE_RAINBOW_CLOCK: ESP_LOGD(TAG, "queue: clock for %d sec", this->screen_time); break; + case MODE_RAINBOW_DATE: + ESP_LOGD(TAG, "queue: date for %d sec", this->screen_time); + break; default: ESP_LOGD(TAG, "queue: UPPS"); break; @@ -141,17 +144,21 @@ namespace esphome this->config_->display->print(15 + xoffset, yoffset, font, this->config_->alarm_color, display::TextAlign::BASELINE_CENTER, "!t!"); } break; + case MODE_RAINBOW_DATE: case MODE_DATE: if (this->config_->clock->now().timestamp > 6000) // valid time { + color_ = (this->mode == MODE_RAINBOW_DATE) ? this->config_->rainbow_color : this->text_color; time_t ts = this->config_->clock->now().timestamp; - this->config_->display->strftime(xoffset + 15, yoffset, font, this->text_color, display::TextAlign::BASELINE_CENTER, this->config_->date_fmt.c_str(), + this->config_->display->strftime(xoffset + 15, yoffset, font, color_, display::TextAlign::BASELINE_CENTER, this->config_->date_fmt.c_str(), this->config_->clock->now()); if ((this->config_->clock->now().second % 2 == 0) && this->config_->show_seconds) { this->config_->display->draw_pixel_at(0, 0, this->config_->clock_color); } - this->config_->draw_day_of_week(); + if (this->mode != MODE_RAINBOW_DATE){ + this->config_->draw_day_of_week(); + } } else { diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index f6a5b06..6d5bbe9 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -59,7 +59,6 @@ CONF_ICONS = "icons" CONF_SHOWDOW = "show_dow" CONF_SHOWDATE = "show_date" CONF_FRAMEDURATION = "frame_duration" -CONF_HOLD_TIME = "hold_time" CONF_SCROLLCOUNT = "scroll_count" CONF_MATRIXCOMPONENT = "matrix_component" CONF_HTML = "icons2html" @@ -127,9 +126,6 @@ EHMTX_SCHEMA = cv.Schema({ cv.Optional( CONF_special_FONT_YOFFSET, default="6" ): cv.templatable(cv.int_range(min=-32, max=32)), - cv.Optional( - CONF_HOLD_TIME, default="20" - ): cv.templatable(cv.int_range(min=0, max=3600)), cv.Optional(CONF_SCROLLINTERVAL, default="80" ): cv.templatable(cv.positive_int), cv.Optional(CONF_RAINBOWINTERVAL, default="32" @@ -394,7 +390,6 @@ async def to_code(config): cg.add(var.set_time_format(config[CONF_TIME_FORMAT])) cg.add(var.set_date_format(config[CONF_DATE_FORMAT])) cg.add(var.set_show_day_of_week(config[CONF_SHOWDOW])) - cg.add(var.set_hold_time(config[CONF_HOLD_TIME])) cg.add(var.set_show_date(config[CONF_SHOWDATE])) cg.add(var.set_show_seconds(config[CONF_SHOW_SECONDS])) cg.add(var.set_default_font_offset(config[CONF_DEFAULT_FONT_XOFFSET], config[CONF_DEFAULT_FONT_YOFFSET] )) diff --git a/copy2esphome/ulanzi-easy.yaml b/copy2esphome/ulanzi-easy.yaml index cf45ba9..a890794 100644 --- a/copy2esphome/ulanzi-easy.yaml +++ b/copy2esphome/ulanzi-easy.yaml @@ -222,7 +222,6 @@ display: ehmtxv2: id: rgb8x32 - hold_time: 30 icons2html: true default_font_yoffset: 6 matrix_component: ehmtx_display diff --git a/images/events.png b/images/events.png new file mode 100644 index 0000000..43bb5f8 Binary files /dev/null and b/images/events.png differ