aboutsummaryrefslogtreecommitdiff
path: root/main/DisplayText.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main/DisplayText.cpp')
-rw-r--r--main/DisplayText.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/main/DisplayText.cpp b/main/DisplayText.cpp
new file mode 100644
index 0000000..ceeed86
--- /dev/null
+++ b/main/DisplayText.cpp
@@ -0,0 +1,62 @@
+#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;
+ }
+ }
+}