acid-drop

- Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.acid.vegas/-c.git
Log | Files | Refs | Archive | README | LICENSE

commit c1eedf3183260e6c6c85c36dcd3beda62bdc1b16
parent 07474dcd0d95adf54ab4d3f6c2175179445c73ac
Author: acidvegas <acid.vegas@acid.vegas>
Date: Mon, 27 May 2024 16:49:03 -0400

Added scrolling input text so we can type beyond the width of the screen

Diffstat:
Msrc/main.ino | 18+++++++++++++++---

1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/main.ino b/src/main.ino
@@ -209,13 +209,13 @@ void turnOffScreen() {
     Serial.println("Screen turned off");
     tft.writecommand(TFT_DISPOFF); // Turn off display
     tft.writecommand(TFT_SLPIN);   // Put display into sleep mode
-    digitalWrite(TFT_BL, LOW);     // Turn off the backlight (Assuming TFT_BL is the backlight pin)
+    digitalWrite(TFT_BL, LOW);     // Turn off the backlight
     screenOn = false;
 }
 
 void turnOnScreen() {
     Serial.println("Screen turned on");
-    digitalWrite(TFT_BL, HIGH);    // Turn on the backlight (Assuming TFT_BL is the backlight pin)
+    digitalWrite(TFT_BL, HIGH);    // Turn on the backlight
     tft.writecommand(TFT_SLPOUT);  // Wake up display from sleep mode
     tft.writecommand(TFT_DISPON);  // Turn on display
     screenOn = true;
@@ -665,9 +665,21 @@ void displayInputLine() {
     tft.setCursor(0, SCREEN_HEIGHT - INPUT_LINE_HEIGHT);
     tft.setTextColor(TFT_WHITE);
     tft.setTextSize(1);
-    tft.print("> " + inputBuffer);
+
+    int inputWidth = SCREEN_WIDTH - tft.textWidth("> ");
+    String displayInput = inputBuffer;
+    int displayWidth = tft.textWidth(displayInput);
+
+    // Scrolling input text
+    while (displayWidth > inputWidth) {
+        displayInput = displayInput.substring(1);
+        displayWidth = tft.textWidth(displayInput);
+    }
+
+    tft.print("> " + displayInput);
 }
 
+
 void displayCenteredText(String text) {
     tft.fillScreen(TFT_BLACK);
     tft.setTextDatum(MC_DATUM);