Skip to content

Commit

Permalink
color working
Browse files Browse the repository at this point in the history
  • Loading branch information
lubeda committed Sep 30, 2023
1 parent 30012c5 commit 535f037
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
6 changes: 2 additions & 4 deletions components/ehmtxv2/EHMTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ namespace esphome
register_service(&EHMTX::alert_screen, "alert_screen", {"iconname","text", "screen_time", "default_font", "r", "g", "b"});
register_service(&EHMTX::icon_clock, "icon_clock", {"icon_name", "lifetime", "screen_time", "default_font", "r", "g", "b"});
#ifdef USE_GRAPH
register_service(&EHMTX::graph_screen, "graph_screen", {"lifetime", "screen_time", "r", "g", "b"});
register_service(&EHMTX::graph_screen, "graph_screen", {"lifetime", "screen_time"});
#endif
register_service(&EHMTX::rainbow_icon_screen, "rainbow_icon_screen", {"icon_name", "text", "lifetime", "screen_time", "default_font"});

Expand Down Expand Up @@ -1137,16 +1137,14 @@ void EHMTX::fire_screen( int lifetime, int screen_time)
ESP_LOGD(TAG, "set_graph");
}

void EHMTX::graph_screen(int lifetime, int screen_time,int r,int g,int b)
void EHMTX::graph_screen(int lifetime, int screen_time)
{
ESP_LOGD(TAG, "graph screen: lifetime: %d screen_time: %d", lifetime, screen_time);

EHMTX_queue *screen = this->find_mode_queue_element(MODE_GRAPH_SCREEN);

screen->endtime = this->clock->now().timestamp + lifetime * 60;
screen->mode = MODE_GRAPH_SCREEN;
screen->text_color = Color(r, g, b);
// this->graph->set_line_color(this->text_color);
screen->screen_time_ = screen_time;
for (auto *t : on_add_screen_triggers_)
{
Expand Down
2 changes: 1 addition & 1 deletion components/ehmtxv2/EHMTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ namespace esphome
addressable_light::AddressableLightDisplay *display;
esphome::time::RealTimeClock *clock;
#ifdef USE_GRAPH
void graph_screen(int lifetime = 2 , int screen_time = 20 ,int r= C_RED ,int g=C_GREEN,int b=C_BLUE);
void graph_screen(int lifetime = 2 , int screen_time = 20);
graph::Graph *graph;
#endif

Expand Down
3 changes: 1 addition & 2 deletions components/ehmtxv2/EHMTX_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ namespace esphome
break;
#ifdef USE_GRAPH
case MODE_GRAPH_SCREEN:
// this->config_->display->graph(0,0, this->config_->graph);
this->config_->graph->draw(this->config_->display,0,0, Color(200,100,150));
this->config_->display->graph(0,0, this->config_->graph);
#endif
case MODE_BITMAP_SMALL:
#ifndef USE_ESP8266
Expand Down
23 changes: 16 additions & 7 deletions wiki/using-graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,31 @@

**minimum version:** 2023.9.0

To use graphs on your display you have to add a graph to your yaml, only this graph can be displayed. Depending on your values you should set the loglevel of the graphs component to error.
To use graphs on your display you have to add a graph to your yaml, only this graph can be displayed. Depending on your values you should set the loglevel of the graphs component to error. The Color has to be defined in the YAML.

## Example

```yaml
logger:
level: DEBUG
logs:
graph: error

color:
- id: graph_color
red: 100%
green: 20%
blue: 25%

graph:
- id: ehmtx_graph
sensor: light_sensor
duration: 15min
border: false
line_thickness: 1
width: 32
height: 8

traces:
- sensor: light_sensor
line_thickness: 1
color: graph_color

ehmtxv2:
id: rgb8x32
display_graph: ehmtx_graph
Expand All @@ -30,7 +38,8 @@ ehmtxv2:
The service call is:

```c
id(rgb8x32).graph_screen(10,20,200,130,170);
//void graph_screen(int lifetime , int screen_time);
id(rgb8x32).graph_screen(10,20);
```

0 comments on commit 535f037

Please sign in to comment.