#include "DisplayText.h" #include "InovaLedDisplay.h" DisplayText::DisplayText(std::string text, int16_t y, uint16_t color, int16_t alignment) { this->text = text; this->width = text.length() * 6; this->scroll = (this->width > NUM_COL); this->y = y; this->color = color; if(!scroll) { // we only use alignment if we don't have to scroll if(alignment < 0) { this->x = 0; } else if(alignment == 0) { this->x = (NUM_COL - this->width) / 2; } else if(alignment > 0) { this->x = (NUM_COL - this->width); } } else { this->x = NUM_COL; } } const char* DisplayText::getText() { return text.c_str(); } int16_t DisplayText::getX() { return x; } int16_t DisplayText::getY() { return y; } uint16_t DisplayText::getColor() { return color; } void DisplayText::step() { if(scroll) { x--; if(x < -width) { x = NUM_COL; } } }