Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2023.9.1: Add height to icon indicator #32

Merged
merged 3 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", "pos", "height"|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 @@ -843,6 +843,7 @@ data:
b: 240
size: 6
pos: 7
height: 1
```

### Local lambdas
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 pos, int height)
{
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", "pos", "height"});
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 pos = 7, int h = 1);
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