Skip to content

Commit

Permalink
2023.9.1: Add Height to Icon Indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjswan committed Dec 23, 2023
1 parent f165e0c commit f141494
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ Numerous features are accessible with services from home assistant and lambdas t
|`icon_prognosis_screen_rgb`|"icon_name", "text", "prognosis", "lifetime", "screen_time", "default_font", "r", "g", "b"|show an icon, text, and a prognosis bar consisting of 24 dots of specified colors|
|`set_adv_clock_color`|"hr", "hg", "hb", "mr", "mg", "mb", "sr", "sg", "sb"|available only in **advanced clock mode** `advanced_clock: true`, allows you to set the color for the Hours (hr, hg, hb), Minutes (mr, mg, mb) and Spacer (sr, sg, sb), color is set by analogy with `r,g,b`. If the color is set as `black`, the standard color is used (see `set_clock_color`).|
|`set_clock_infotext_color`|"left_r", "left_g", "left_b", "right_r", "right_g", "right_b","default_font","y_offset"|set the special color for left and right char on info text on `icon clock` screen, work only in **advanced clock mode**|
|`show_icon_indicator`|"r", "g", "b", "size", "pos"|shows the line indicator in the Icons area on the specified screens, in the specified color and at the specified vertical position|
|`show_icon_indicator`|"r", "g", "b", "size", "height", "pos"|shows the line indicator in the Icons area on the specified screens, in the specified color and at the specified vertical position|
|`hide_icon_indicator`|none|hides the icon indicator|
|`expand_icon_to_9`|"mode"|Extends the icon display on the clock screen and date screen by one line (9 pixels wide). Mode 0 (default) - do not expand. Mode 1 - expand only on the clock screen. Mode 2 - expand only on the date screen. Mode 3 - expand on the screen with clock and on the screen with date. [More info](https://github.com/lubeda/EspHoMaTriXv2/pull/179)|

Expand Down Expand Up @@ -842,6 +842,7 @@ data:
g: 240
b: 240
size: 6
height: 1
pos: 7
```

Expand Down
38 changes: 29 additions & 9 deletions components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace esphome
this->display_lindicator = 0;
this->display_icon_indicator = 0;
this->icon_indicator_y_pos = 7;
this->icon_indicator_height = 1;
this->icon_to_9 = 0;
this->display_alarm = 0;
this->clock_time = 10;
Expand Down Expand Up @@ -80,14 +81,15 @@ namespace esphome
}
}

void EHMTX::show_icon_indicator(int r, int g, int b, int size, int pos)
void EHMTX::show_icon_indicator(int r, int g, int b, int size, int height, int pos)
{
if (size > 0)
{
this->icon_indicator_color = Color((uint8_t)r , (uint8_t)g , (uint8_t)b);
this->display_icon_indicator = size;
this->icon_indicator_height = height;
this->icon_indicator_y_pos = pos;
ESP_LOGD(TAG, "show icon_indicator size: %d r: %d g: %d b: %d pos:", size, r, g, b, pos);
ESP_LOGD(TAG, "show icon_indicator size: %d height: %d r: %d g: %d b: %d pos:", size, height, r, g, b, pos);
}
else
{
Expand Down Expand Up @@ -702,7 +704,7 @@ namespace esphome
register_service(&EHMTX::bitmap_stack, "bitmap_stack", {"icons", "lifetime", "screen_time"});
#endif

register_service(&EHMTX::show_icon_indicator, "show_icon_indicator", {"r", "g", "b", "size", "pos"});
register_service(&EHMTX::show_icon_indicator, "show_icon_indicator", {"r", "g", "b", "size", "height", "pos"});
register_service(&EHMTX::hide_icon_indicator, "hide_icon_indicator");

#ifdef USE_Fireplugin
Expand Down Expand Up @@ -2510,15 +2512,33 @@ namespace esphome
(this->queue[this->screen_pointer]->mode == MODE_ICON_DATE && this->icon_to_9 == 2) ||
(this->icon_to_9 == 3))
{
this->display->line(4 - display_icon_indicator / 2, this->icon_indicator_y_pos,
4 + display_icon_indicator / 2, this->icon_indicator_y_pos,
this->icon_indicator_color);
if (this->display_icon_indicator = 1)
{
this->display->line(4 - display_icon_indicator / 2, this->icon_indicator_y_pos,
4 + display_icon_indicator / 2, this->icon_indicator_y_pos,
this->icon_indicator_color);
}
else
{
this->display->filled_rectangle(4 - display_icon_indicator / 2, this->icon_indicator_y_pos,
this->display_icon_indicator, this->icon_indicator_height,
this->icon_indicator_color);
}
}
else
{
this->display->line(4 - display_icon_indicator / 2, this->icon_indicator_y_pos,
3 + display_icon_indicator / 2, this->icon_indicator_y_pos,
this->icon_indicator_color);
if (this->display_icon_indicator = 1)
{
this->display->line(4 - display_icon_indicator / 2, this->icon_indicator_y_pos,
3 + display_icon_indicator / 2, this->icon_indicator_y_pos,
this->icon_indicator_color);
}
else
{
this->display->filled_rectangle(4 - display_icon_indicator / 2, this->icon_indicator_y_pos,
this->display_icon_indicator, this->icon_indicator_height,
this->icon_indicator_color);
}
}
break;
}
Expand Down
3 changes: 2 additions & 1 deletion components/ehmtxv2/EHMTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ namespace esphome
void dump_config();
bool info_font = true;
int8_t info_y_offset = 0;
int8_t icon_indicator_height = 1;
int8_t icon_indicator_y_pos = 7;
uint8_t icon_to_9 = 0;
#ifdef EHMTXv2_ADV_CLOCK
Expand Down Expand Up @@ -210,7 +211,7 @@ namespace esphome

void show_rindicator(int r = C_RED, int g = C_GREEN, int b = C_BLUE, int s = 3);
void show_lindicator(int r = C_RED, int g = C_GREEN, int b = C_BLUE, int s = 3);
void show_icon_indicator(int r = C_RED, int g = C_GREEN, int b = C_BLUE, int s = 6, int pos = 7);
void show_icon_indicator(int r = C_RED, int g = C_GREEN, int b = C_BLUE, int s = 8, int h = 1, int pos = 7);
void set_text_color(int r = C_RED, int g = C_GREEN, int b = C_BLUE);
void set_today_color(int r = C_RED, int g = C_GREEN, int b = C_BLUE);
void set_weekday_color(int r = CD_RED, int g = CD_GREEN, int b = CD_BLUE);
Expand Down

0 comments on commit f141494

Please sign in to comment.