So i want to display a long string of text, so long that it would trail off the screen. I made it so that the text stopped wrapping with display.setTextWrap(false);
however, now when I try to scroll the text none of the text, which supposedly should be somewhere off the screen to the right, is being displayed. The string cuts off at "Hello WOrrr" and then just scrolls that part of the text again and again for 10000ms
The OLED scroll functions aren't quite as snazzy as one might expect; they just rotate the contents of the frame buffer, there's no larger "playfield" to move about.
Instead, it's necessary to re-draw each frame, keeping track of the text X position and moving it left each time. Like this:
Thank you, that works great. I was about to write something like that, but I hesitated because I though the functionality was in function provided by the library. Have a great day :]
Hello- I was happy to find some example code for scrolling and I quickly converted it to use the SSD_1351 library since I am using a 1.5" OLED. I also make the "x" variables work on the y-axis enabling vertical scrolling. I want the code to display a series of lines at once, but to my frustration changing the variables didn't change the amount the string scrolled up, it just stayed at 1 pixel. Do you know how I can modify the code so it changes the amount it moves up the screen each refresh?
// Screen dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 128 // Change this to 96 for 1.27" OLED.
// You can use any (4 or) 5 pins
#define SCLK_PIN 11
#define MOSI_PIN 12
#define DC_PIN 10
#define CS_PIN 8
#define RST_PIN 9
// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define ARDUBLUE 0x00CC
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <SPI.h>
// Option 1: use any pins but a little slower
Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, CS_PIN, DC_PIN, MOSI_PIN, SCLK_PIN, RST_PIN);
// Option 2: must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
//Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, &SPI, CS_PIN, DC_PIN, RST_PIN);
float p = 3.1415926;
//---------------------------------------------------------------------------------------------------------------------------
char message[] = "Hello WOrrrrrllllllllllllllllllllllllllllldddd";
int y, minY;
void setup() {
tft.begin();
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.setTextWrap(false);
y = tft.height()+10;// so it starts out at the point on the screen, not below
minY = -12 * strlen(message); // 12 = 6 pixels/character * text size 2
}
void loop() {
delay(1000);
tft.fillScreen(BLACK);
tft.setCursor(0, y);
tft.print(message);
if(--y< minY) y = tft.height();
}