removed shiftx

pull/16/head
LuBeDa 3 years ago
parent 31024249c9
commit 67699e952e

@ -2,17 +2,18 @@
## function ## function
- [ ] screen_time on ms sec base
- [ ] scroll left to right
- [ ] seconds point moveable
- [x] alarm on all screens but full screen - [x] alarm on all screens but full screen
- [x] indicator on all screens but full screen and clock - [x] indicator on all screens but full screen and clock
- [x] refreshing an icon screen should extend the display time - [x] refreshing an icon screen should extend the display time
- [ ] scroll left to right
- [x] size of indicator and alarm - [x] size of indicator and alarm
- [x] center text - [x] center text
- [x] alarm independent of screen - [x] alarm independent of screen
- [x] del_screen with * and filter by type, do delete all clocks etc. - [x] del_screen with * and filter by type, do delete all clocks etc.
- [x] force_screen with * and filter by type, do delete all clocks etc. - [x] force_screen with * and filter by type, do delete all clocks etc.
- [x] gauge with color and del_gaugeall clocks etc. - [x] gauge with color and del_gaugeall clocks etc.
- [ ] seconds point moveable
- [x] seconds point to clock screen only - [x] seconds point to clock screen only
- [x] rainbow icon and text - [x] rainbow icon and text
- [x] del_slot still active? - [x] del_slot still active?
@ -22,16 +23,16 @@
## user experience ## user experience
- [ ] blueprints - [ ] blueprints
- [x] Color in blueprints
- [ ] all modes in one blueprint
- [ ] external HTML with more blueprint helpers (icons and modes) - [ ] external HTML with more blueprint helpers (icons and modes)
- [ ] ~~all modes in one blueprint~~
- [x] Color in blueprints
- [x] default values for all functions - [x] default values for all functions
- [x] provide sample font from [url](https://www.pentacom.jp/pentacom/bitfontmaker2/) - [x] provide sample font from [url](https://www.pentacom.jp/pentacom/bitfontmaker2/)
- [x] start animation - [x] start animation
## style ## style
- [ ] in screen rename text_color to color - [x] ~~in screen rename text_color to color~~
- [x] default_font before alarm parameter - [x] default_font before alarm parameter
- [x] screen_time instead of showtime - [x] screen_time instead of showtime
- [x] lifetime instead of durations - [x] lifetime instead of durations

@ -21,6 +21,7 @@ namespace esphome
this->gauge_color = Color(CD_RED, CD_GREEN, CD_BLUE); this->gauge_color = Color(CD_RED, CD_GREEN, CD_BLUE);
this->gauge_value = 0; this->gauge_value = 0;
this->next_action_time = 0; this->next_action_time = 0;
this->last_scroll_time = 0;
this->screen_pointer = MAXQUEUE; this->screen_pointer = MAXQUEUE;
for (uint8_t i = 0; i < MAXQUEUE; i++) for (uint8_t i = 0; i < MAXQUEUE; i++)
@ -370,64 +371,67 @@ namespace esphome
if (this->is_running) if (this->is_running)
{ {
if (millis() - this->last_scroll_time >= this->scroll_interval)
{
this->scroll_step++;
this->last_scroll_time = millis();
if (this->scroll_step > this->queue[this->screen_pointer]->scroll_reset)
{
ESP_LOGD(TAG, "end scroll at: %d",this->scroll_step);
this->scroll_step = 0;
}
}
if (ts > this->next_action_time) if (ts > this->next_action_time)
{ {
this->remove_expired_queue_element(); this->remove_expired_queue_element();
this->screen_pointer = this->find_last_clock(); this->screen_pointer = this->find_last_clock();
this->scroll_step = 0;
if (this->screen_pointer == MAXQUEUE) if (this->screen_pointer == MAXQUEUE)
{ {
this->screen_pointer = find_oldest_queue_element(); this->screen_pointer = find_oldest_queue_element();
} }
if (millis() - this->last_scroll_time >= this->scroll_interval)
{
this->scroll_step++;
this->last_scroll_time = millis();
if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 32) if (this->screen_pointer != MAXQUEUE)
{
this->queue[this->screen_pointer]->last_time = ts + this->queue[this->screen_pointer]->screen_time_;
if (this->queue[this->screen_pointer]->icon < this->icon_count)
{ {
this->scroll_step = 0; this->icons[this->queue[this->screen_pointer]->icon]->set_frame(0);
} }
if (this->screen_pointer != MAXQUEUE) this->next_action_time = this->queue[this->screen_pointer]->last_time;
// Todo switch for Triggers
if (this->queue[this->screen_pointer]->mode == MODE_CLOCK)
{ {
this->scroll_step = 0; for (auto *t : on_next_clock_triggers_)
this->queue[this->screen_pointer]->last_time = ts + this->queue[this->screen_pointer]->screen_time_;
if (this->queue[this->screen_pointer]->icon < this->icon_count)
{ {
this->icons[this->queue[this->screen_pointer]->icon]->set_frame(0); t->process();
}
this->next_action_time = this->queue[this->screen_pointer]->last_time;
// Todo switch for Triggers
if (this->queue[this->screen_pointer]->mode == MODE_CLOCK)
{
for (auto *t : on_next_clock_triggers_)
{
t->process();
}
}
else
{
for (auto *t : on_next_screen_triggers_)
{
t->process(this->queue[this->screen_pointer]->icon_name, this->queue[this->screen_pointer]->text);
}
} }
} }
else else
{ {
ESP_LOGW(TAG, "tick: nothing to do. Restarting clock display!"); for (auto *t : on_next_screen_triggers_)
this->clock_screen(24 * 60, this->clock_time, false, C_RED, C_GREEN, C_BLUE); {
this->date_screen(24 * 60, (int)this->clock_time / 2, false, C_RED, C_GREEN, C_BLUE); t->process(this->queue[this->screen_pointer]->icon_name, this->queue[this->screen_pointer]->text);
this->next_action_time = ts + this->clock_time; }
} }
} }
else
{
ESP_LOGW(TAG, "tick: nothing to do. Restarting clock display!");
this->clock_screen(24 * 60, this->clock_time, false, C_RED, C_GREEN, C_BLUE);
this->date_screen(24 * 60, (int)this->clock_time / 2, false, C_RED, C_GREEN, C_BLUE);
this->next_action_time = ts + this->clock_time;
}
} }
} }
else else
{ {
uint8_t w = (1 + (uint8_t)(32 / 16) * (this->boot_anim / 16)) % 32; uint8_t w = (1 + (uint8_t)(32 / 16) * (this->boot_anim / 16)) % 32;
this->display->rectangle(0, 2, w, 4, this->rainbow_color); // Color(120, 190, 40)); this->display->rectangle(0, 2, w, 4, this->rainbow_color); // Color(120, 190, 40));
this->boot_anim++; this->boot_anim++;
} }
} }
void EHMTX::skip_screen() void EHMTX::skip_screen()

@ -95,6 +95,7 @@ namespace esphome
uint16_t frame_interval; // ms to next_frame() uint16_t frame_interval; // ms to next_frame()
uint16_t clock_interval; uint16_t clock_interval;
uint16_t hold_time; // seconds display of screen_time to extend uint16_t hold_time; // seconds display of screen_time to extend
uint8_t icon_count; // max iconnumber -1 uint8_t icon_count; // max iconnumber -1
unsigned long last_scroll_time; unsigned long last_scroll_time;
unsigned long last_rainbow_time; unsigned long last_rainbow_time;
@ -141,7 +142,6 @@ namespace esphome
void hide_gauge(); void hide_gauge();
void hide_indicator(); void hide_indicator();
void hide_alarm(); void hide_alarm();
void full_screen(std::string icon, int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME); void full_screen(std::string icon, int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME);
void icon_screen(std::string icon, std::string text, int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME,bool default_font=true,int r=C_RED, int g=C_GREEN, int b=C_BLUE); void icon_screen(std::string icon, std::string text, int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME,bool default_font=true,int r=C_RED, int g=C_GREEN, int b=C_BLUE);
void text_screen(std::string text, int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME, bool default_font=true, int r=C_RED, int g=C_GREEN, int b=C_BLUE); void text_screen(std::string text, int lifetime=D_LIFETIME, int screen_time=D_SCREEN_TIME, bool default_font=true, int r=C_RED, int g=C_GREEN, int b=C_BLUE);
@ -182,6 +182,7 @@ namespace esphome
time_t endtime; time_t endtime;
time_t last_time; time_t last_time;
uint8_t icon; uint8_t icon;
uint16_t scroll_reset;
Color text_color; Color text_color;
show_mode mode; show_mode mode;

@ -64,6 +64,7 @@ namespace esphome
{ {
uint8_t width = 32; uint8_t width = 32;
uint8_t startx = 0; uint8_t startx = 0;
int result = 0;
switch (this->mode) switch (this->mode)
{ {
case MODE_RAINBOW_ICON: case MODE_RAINBOW_ICON:
@ -86,24 +87,25 @@ namespace esphome
{ {
if (this->pixels_ < width) if (this->pixels_ < width)
{ {
return 32 - ceil((width - this->pixels_) / 2); result = 32 - ceil((width - this->pixels_) / 2);
} }
else else
{ {
return startx + this->config_->scroll_step; result = startx + this->config_->scroll_step;
} }
} }
else else
{ {
if (this->pixels_ < width) if (this->pixels_ < width)
{ {
return startx + ceil((width - this->pixels_) / 2); result = startx + ceil((width - this->pixels_) / 2);
} }
else else
{ {
return startx - this->config_->scroll_step + width; result = startx - this->config_->scroll_step + width;
} }
} }
return result;
} }
void EHMTX_queue::update_screen() void EHMTX_queue::update_screen()
@ -259,6 +261,11 @@ namespace esphome
{ {
int x, y, w, h; int x, y, w, h;
float display_duration; float display_duration;
uint8_t width = 32;
uint8_t startx = 0;
uint16_t max_steps = 0;
if (this->default_font) if (this->default_font)
{ {
this->config_->display->get_text_bounds(0, 0, text.c_str(), this->config_->default_font, display::TextAlign::LEFT, &x, &y, &w, &h); this->config_->display->get_text_bounds(0, 0, text.c_str(), this->config_->default_font, display::TextAlign::LEFT, &x, &y, &w, &h);
@ -282,12 +289,14 @@ namespace esphome
} }
else else
{ {
display_duration = ceil((28 + (this->config_->scroll_count * (32 + this->pixels_)) * this->config_->scroll_interval) / 1000); max_steps = (this->config_->scroll_count + 1) * (width - startx) + this->config_->scroll_count * this->pixels_;
display_duration = ceil((max_steps * this->config_->scroll_interval) / 1000);
this->screen_time_ = (display_duration > screen_time) ? display_duration : screen_time; this->screen_time_ = (display_duration > screen_time) ? display_duration : screen_time;
} }
break; break;
case MODE_RAINBOW_ICON: case MODE_RAINBOW_ICON:
case MODE_ICON_SCREEN: case MODE_ICON_SCREEN:
startx = 8;
if (this->pixels_ < 23) if (this->pixels_ < 23)
{ {
this->screen_time_ = screen_time; this->screen_time_ = screen_time;
@ -295,7 +304,8 @@ namespace esphome
} }
else else
{ {
display_duration = ceil((this->config_->scroll_count * (TEXTSTARTOFFSET + this->pixels_) * this->config_->scroll_interval) / 1000); max_steps = (this->config_->scroll_count + 1) * (width - startx) + this->config_->scroll_count * this->pixels_;
display_duration = ceil((max_steps * this->config_->scroll_interval) / 1000);
this->screen_time_ = (display_duration > screen_time) ? display_duration : screen_time; this->screen_time_ = (display_duration > screen_time) ? display_duration : screen_time;
} }
break; break;
@ -303,6 +313,8 @@ namespace esphome
break; break;
} }
ESP_LOGD(TAG, "calc_scroll_time: mode: %d text: \"%s\" pixels %d calculated: %d defined: %d", this->mode, text.c_str(), this->pixels_, this->screen_time_, screen_time); this->scroll_reset = (width - startx) + this->pixels_;;
ESP_LOGD(TAG, "calc_scroll_time: mode: %d text: \"%s\" pixels %d calculated: %d defined: %d max_steps: %d", this->mode, text.c_str(), this->pixels_, this->screen_time_, screen_time, this->scroll_reset);
} }
} }

Loading…
Cancel
Save