How to stop scrolling text on OLED display?

Im using Digispark ATTiny85 with 128x32 OLED display and I want to scroll my text up and down with 2 buttons. Im using Tiny4kOLED library and don't really know what should i do to get it to work as I want.
This is my code:

#include <Tiny4kOLED.h>
#define OG 1
#define OD 4
unsigned int i = 1;

void setup() {
  pinMode(OG,INPUT);
  pinMode(OD,INPUT);
  }


void loop() {
  if(millis() == 200){
    oled.begin();
    oled.setRotation(0);
    oled.setFont(FONT6X8);    
    oled.clear();
  } 
  oled.setCursor(0,0);
  oled.print("TEXT");

  if(digitalRead(OG) == HIGH && digitalRead(OD) == HIGH) {delay(150); i++;}
  
  if(i%2 == 0) {
    oled.on();
  }
  if(i%2 == 1) {
    oled.off();
  }

  if(digitalRead(OD) == HIGH && digitalRead(OG) == LOW){
    oled.scrollLeftOffset(7,1,7,1);
    oled.setVerticalScrollArea(11, 50);
    oled.activateScroll();    
  }
  if(digitalRead(OD) == LOW){
    oled.scrollLeftOffset(0,0,0,0);
    oled.setVerticalScrollArea(11, 50);
  }
} 

OG and OD are P1 and P4 pins on board and theyre getting read as they should. After connecting OD to 5v text is moving downwards but strange dots starts showing up and when its released text is not stoping in the postion it was but it goes all the way to the top.

add to last code block in the loop():

oled.deactivateScroll();

You can always find all library command in library source code.

It seems like oled.deactivateScroll exists in library but it don't stop in the middle of text. It still goes to start.

please show your code with this line inserted.

void loop() {
  if(millis() == 200){
    oled.begin();
    oled.setRotation(0);
    oled.setFont(FONT6X8);    
    oled.clear();
  } 
  oled.setCursor(0,0);
  oled.print("Text");
 

  if(digitalRead(OG) == HIGH && digitalRead(OD) == HIGH) {delay(300); i++;}
  
  if(i%2 == 0) {
    oled.on();
  }
  if(i%2 == 1) {
    oled.off();
  }

  if(digitalRead(OD) == HIGH && digitalRead(OG) == LOW){
    oled.scrollLeftOffset(7,1,8,1);
    oled.setVerticalScrollArea(0, 200);
    oled.activateScroll();    
  }
  if(digitalRead(OD) == LOW){
    oled.scrollLeftOffset(0,0,0,0);
    oled.setVerticalScrollArea(0, 10);
    oled.deactivateScroll();
  }
} 

Also i tried without Offset and Scroll Area

Please show how your OD and OG knobs are connected. Do you use pullup or pulldown?

I just connect 5v to pin without any resistors

try adding the resistor 2K-10K between OD and GND.

PS I don't know how the `oled.deactivateScroll() should work. Perhaps it do not just stop the scroll, but return the text to start position....

Okay I will try it

I hope not

I soldered 10K resistor between gnd and OD but nothing changed

try to comment these Offset and ScrollArea lines:

If this won't help - no more ideas, sorry

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.