Stop Scrolling the Rectangle and Scroll only the text inside the rectangle

I am using SSD 1306 led Display in my project . I have drawn a rectangle and inside the rectangle a text is written in it .

If I press the reset button in my project i need only the text to be scrolled and the rectangle should disappear .

At present in my code both the rectangle and the text gets scrolled when i press the button .

Kindly help.

Please find my code and other attachments in the attachment section

OLED_BITMAP.ino (3.31 KB)

OLED text scroll.txt (3.28 KB)

Code for the above question is as follows:

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <avr/pgmspace.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define LEFT_BUTTON 13
#define RIGHT_BUTTON 12

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

int lbutton;
int rbutton;

void setup() {
Serial.begin(115200);
pinMode(LEFT_BUTTON,INPUT);
pinMode(RIGHT_BUTTON,INPUT);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F(“SSD1306 allocation failed”));
for(;;);
}
delay(2000); // Pause for 2 seconds

// Clear the buffer.
display.clearDisplay();
display.drawRect(0, 0, 125, 20, WHITE);
display.display();
display.setTextSize(1);
display.setTextWrap(false);
display.setTextColor(WHITE);
display.setCursor(0, 10);
display.println(“SSD1306 OLED DISPLAY TESTING”);
display.display();

}

void loop() {
lbutton = digitalRead(13);
rbutton = digitalRead(12);
if ((lbutton ==0)&&(rbutton ==1))
{
// display.clearDisplay();
display.stopscroll();
display.startscrollleft(0x00, 0x0F);
delay(4000);
display.stopscroll();

}
else if ((lbutton ==1)&&(rbutton ==0))
{
// display.clearDisplay();
display.stopscroll();
display.startscrollright(0x00, 0x0F);
delay(4000);
display.stopscroll();

}

}

Lets pretend you formatted it and put it in code tags…

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <avr/pgmspace.h>


#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define LEFT_BUTTON 13
#define RIGHT_BUTTON 12


Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

int lbutton;
int rbutton;

void setup() {
  Serial.begin(115200);
  pinMode(LEFT_BUTTON, INPUT);
  pinMode(RIGHT_BUTTON, INPUT);
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }
  delay(2000); // Pause for 2 seconds

  // Clear the buffer.
  display.clearDisplay();
  display.drawRect(0, 0, 125, 20, WHITE);
  display.display();
  display.setTextSize(1);
  display.setTextWrap(false);
  display.setTextColor(WHITE);
  display.setCursor(0, 10);
  display.println("SSD1306 OLED DISPLAY TESTING");
  display.display();
}


void loop() {
  lbutton = digitalRead(13);
  rbutton = digitalRead(12);
  if ((lbutton == 0) && (rbutton == 1)) {
    // display.clearDisplay();
    display.stopscroll();
    display.startscrollleft(0x00, 0x0F);
    delay(4000);
    display.stopscroll();
  }
  else if ((lbutton == 1) && (rbutton == 0)) {
    // display.clearDisplay();
    display.stopscroll();
    display.startscrollright(0x00, 0x0F);
    delay(4000);
    display.stopscroll();
  }
}

But it seems that it still won’t compile.

forum_post:13:64: error: no matching function for call to 'Adafruit_SSD1306::Adafruit_SSD1306(int, int, TwoWire*, int)'
 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
                                                                ^

-jim lee