rtl for text

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

@ -98,11 +98,11 @@ namespace esphome
{ {
if (this->pixels_ < width) if (this->pixels_ < width)
{ {
result = startx + ceil((width - this->pixels_) / 2); result = startx + ceil((width - this->pixels_) / 2);
} }
else else
{ {
result = startx - this->config_->scroll_step + width; result = startx - this->config_->scroll_step + width;
} }
} }
return result; return result;
@ -239,8 +239,16 @@ 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->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT, if (this->config_->rtl)
this->text.c_str()); {
this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_RIGHT,
this->text.c_str());
}
else
{
this->config_->display->print(this->xpos() + xoffset, yoffset, font, color_, esphome::display::TextAlign::BASELINE_LEFT,
this->text.c_str());
}
break; break;
default: default:
break; break;
@ -313,7 +321,8 @@ namespace esphome
break; break;
} }
this->scroll_reset = (width - startx) + this->pixels_;; 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); 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