before scroll_step

pull/16/head
LuBeDa 3 years ago
parent a167b12a45
commit ebb12dccad

@ -361,7 +361,7 @@ namespace esphome
} }
void EHMTX::tick() void EHMTX::tick()
{ {
this->hue_++; this->hue_++;
if (this->hue_ == 360) if (this->hue_ == 360)
{ {
this->hue_ = 0; this->hue_ = 0;
@ -369,6 +369,25 @@ namespace esphome
float red, green, blue; float red, green, blue;
esphome::hsv_to_rgb(this->hue_, 0.8, 0.8, 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->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; time_t ts = this->clock->now().timestamp;
if (this->is_running) if (this->is_running)
@ -384,6 +403,7 @@ namespace esphome
if (this->screen_pointer != MAXQUEUE) if (this->screen_pointer != MAXQUEUE)
{ {
this->queue[this->screen_pointer]->shiftx_ = 0; 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_; 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) if (this->queue[this->screen_pointer]->icon < this->icon_count)
{ {

@ -70,6 +70,7 @@ namespace esphome
bool rtl; bool rtl;
uint8_t gauge_value; uint8_t gauge_value;
uint16_t clock_time; uint16_t clock_time;
uint16_t scroll_step;
uint8_t scroll_count; uint8_t scroll_count;
void remove_expired_queue_element(); void remove_expired_queue_element();
uint8_t find_oldest_queue_element(); uint8_t find_oldest_queue_element();

@ -142,6 +142,7 @@ namespace esphome
if (this->shiftx_ > this->pixels_ + 32) if (this->shiftx_ > this->pixels_ + 32)
{ {
this->shiftx_ = 0; this->shiftx_ = 0;
} }
this->config_->last_scroll_time = millis(); this->config_->last_scroll_time = millis();
} }
@ -236,8 +237,6 @@ namespace esphome
else { else {
this->config_->display->print(this->xpos() + xoffset, 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()); 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) if (this->config_->display_gauge)
{ {
@ -263,7 +262,7 @@ namespace esphome
extraoffset += 2; extraoffset += 2;
} }
color_ = (this->mode == MODE_RAINBOW_TEXT) ? this->config_->rainbow_color : this->text_color; 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()); this->text.c_str());
break; break;
default: default:
@ -301,7 +300,7 @@ namespace esphome
switch (this->mode) switch (this->mode)
{ {
case MODE_RAINBOW_TEXT: case MODE_RAINBOW_TEXT:
case MODE_TEXT_SCREEN: case MODE_TEXT_SCREEN:
if (this->pixels_ < 32) if (this->pixels_ < 32)
{ {
this->screen_time_ = screen_time; this->screen_time_ = screen_time;

Loading…
Cancel
Save