diff --git a/components/ehmtxv2/EHMTX.cpp b/components/ehmtxv2/EHMTX.cpp index 62464c8..45c3945 100644 --- a/components/ehmtxv2/EHMTX.cpp +++ b/components/ehmtxv2/EHMTX.cpp @@ -361,7 +361,7 @@ namespace esphome } void EHMTX::tick() { - this->hue_++; + this->hue_++; if (this->hue_ == 360) { this->hue_ = 0; @@ -369,6 +369,25 @@ namespace esphome float red, green, blue; esphome::hsv_to_rgb(this->hue_, 0.8, 0.8, red, green, blue); this->rainbow_color = Color(uint8_t(255 * red), uint8_t(255 * green), uint8_t(255 * blue)); + + this->scroll_step++; + + switch (this->queue[this->screen_pointer]->mode) + { + case MODE_ICON_SCREEN: + case MODE_RAINBOW_ICON: + if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 8) { + this->scroll_step = 0; + } + break; + case MODE_RAINBOW_TEXT: + case MODE_TEXT_SCREEN: + if (this->scroll_step > this->queue[this->screen_pointer]->pixels_ + 31) { + this->scroll_step = 0; + } + break; + } + time_t ts = this->clock->now().timestamp; if (this->is_running) @@ -384,6 +403,7 @@ namespace esphome if (this->screen_pointer != MAXQUEUE) { this->queue[this->screen_pointer]->shiftx_ = 0; + this->scroll_step=0; 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) { diff --git a/components/ehmtxv2/EHMTX.h b/components/ehmtxv2/EHMTX.h index 9dff312..f01855b 100644 --- a/components/ehmtxv2/EHMTX.h +++ b/components/ehmtxv2/EHMTX.h @@ -70,6 +70,7 @@ namespace esphome bool rtl; uint8_t gauge_value; uint16_t clock_time; + uint16_t scroll_step; uint8_t scroll_count; void remove_expired_queue_element(); uint8_t find_oldest_queue_element(); diff --git a/components/ehmtxv2/EHMTX_queue.cpp b/components/ehmtxv2/EHMTX_queue.cpp index ae23ddc..0b0fdc6 100644 --- a/components/ehmtxv2/EHMTX_queue.cpp +++ b/components/ehmtxv2/EHMTX_queue.cpp @@ -142,6 +142,7 @@ namespace esphome if (this->shiftx_ > this->pixels_ + 32) { this->shiftx_ = 0; + } this->config_->last_scroll_time = millis(); } @@ -236,8 +237,6 @@ namespace esphome else { this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, this->text.c_str()); - // this->config_->display->print(this->centerx_ + TEXTSCROLLSTART - this->shiftx_ + extraoffset + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, - // this->text.c_str()); } if (this->config_->display_gauge) { @@ -263,7 +262,7 @@ namespace esphome extraoffset += 2; } color_ = (this->mode == MODE_RAINBOW_TEXT) ? this->config_->rainbow_color : this->text_color; - this->config_->display->print(this->centerx_ - this->shiftx_ + xoffset + extraoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, + this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, this->text.c_str()); break; default: @@ -301,7 +300,7 @@ namespace esphome switch (this->mode) { case MODE_RAINBOW_TEXT: - case MODE_TEXT_SCREEN: + case MODE_TEXT_SCREEN: if (this->pixels_ < 32) { this->screen_time_ = screen_time;