2.23inch OLED HAT scrolling by OLED RDS Fm radio

Hello!

I try to build a OLED RDS Fm radio. I have used a 2.23inch OLED HAT with SSD1305, so i need use this lib: Adafruit_SSD1305. But here comes my problem, this library wont have scrolling function. So i try use a method what i have found this forum:

OLED scrolling to certain X position

But because RDS data sometimes empty, need some delay to receive i have used a ,,passflag" method with checking NULL value. But this kills the without library type scrolling, displayed text jumping during running or the loop slowing down the ,,manual" scrolling . My code currently looks like this:

#include <SI470X.h>
#include <Adafruit_SSD1305.h>

#define RESET_PIN 14 // On Arduino Atmega328 based board, this pin is labeled as A0 (14 means digital pin instead analog)

#define OLED_CLK 13
#define OLED_MOSI 11
#define OLED_CS 10
#define OLED_DC 8
#define OLED_RESET 9

const int next = 7;
const int next2 = 1;
int passflag1 = 0;
int passflag2 = 0;

char *rdsMsg;
char *stationName;

Adafruit_SSD1305 display(128, 32, &SPI, OLED_DC, OLED_RESET, OLED_CS, 7000000UL);
SI470X rx;

void setup() {
  pinMode(next, INPUT);
  pinMode(next2 , INPUT);
  digitalWrite(next, HIGH);
  digitalWrite(next2, LOW);   
  
  display.begin(0x3C);
  display.clearDisplay();
  display.setTextSize(2);
  display.setCursor(0,0);
  display.setTextColor(WHITE);
  display.setTextWrap(false);
  
  rx.setup(RESET_PIN, A4 /* SDA pin  for Arduino ATmega328 */);
  rx.setRDS(true); // Turns RDS on
  rx.setVolume(15);
  delay(500);

  // Select a station
  rx.setFrequency(9630);

  // Enables SDR
  rx.setRds(true);
  rx.setRdsMode(1);
  rx.setMono(false);
}

void loop() {  

if (digitalRead(next)==LOW){
  rx.setFrequency(10160);
  display.clearDisplay();
}

if (digitalRead(next2)==LOW){
  rx.setFrequency(9630);
  display.clearDisplay();
}

if (rx.getRdsReady() && (rx.getRdsText0A() != NULL) && passflag2 == 0 )
  {
  display.clearDisplay();
  display.setCursor(0,10);
  stationName = rx.getRdsText0A();    
  display.print(stationName); 
  display.display();  
    passflag1 = passflag1 + 1 ;
   }

if (passflag1 == 150){
  display.clearDisplay();
  passflag1 = 0;
  passflag2 = 60;
}

if (passflag2 > 1)
{
  if (rx.getRdsReady() && (rx.getRdsText2A() != NULL) && passflag1 == 0)
  {
 
    display.clearDisplay();
    display.setCursor(0,10);
    rdsMsg = rx.getRdsText2A();    
    display.print(rdsMsg); 
    display.display();
    passflag2 = passflag2 - 1 ;
  } 
 
    if (passflag2 == 1){
    display.clearDisplay();
    passflag2 = 0;
    }  
  }
}
      
   
  

I need help by mod my code, creating a unique display scrolling, because i have failed in this:(

The final result what i want to see, first display station name scroll few sec, after display station message both stored in char array. Or i can be happy if i can display scrolled the two character array summa.

There's no information in those words. "It doesn't work" is another useless description. Be more precise! What happens and how does it not follow Your intention?

Im not developer, but i try my best. In current state im unable to display scrolled the stationName and the rdsMsg char arrays. If im try use the included topic solution the result will be choppy, because both rds char arrays sometimes is null or shorter. I will not have any problem if the required oled library have scroll feature, but just ssd1306 library have this function.

I have found currently a workaround in a older LCD project:

  if (rdsText != NULL) {
    display.setCursor(0, RDS_INFO_TEXT_LINE_Y);
    for (int8_t i = rdsTextScrollPosition; i < rdsTextScrollPosition + (-1) * RDS_SCROLL_POSITION_BEGIN + 1; i++) {
      if ((i >= strlen(rdsText)) || (i < 0)) {
        display.print(' ');
         display.display(); 
      } else {
        display.print(rdsText[i]);
         display.display(); 
      }
    }
    rdsTextScrollPosition++;
    if ((rdsTextScrollPosition >= strlen(rdsText)) && (rdsTextScrollPosition > 0)) {
      rdsTextScrollPosition = RDS_SCROLL_POSITION_BEGIN;
    }
  }

But currently im still unable make one big char* array from stationName + rdsMsg char* arrays and display scrolled as one big char array. Maybe because sometimes both NULL, im not sure.

So i have two questions:

There is any better way scroll these arrays?

I try make one big array (from stationName + rdsMsg) (more practicaly like against try display two variable) using this example code, but not working, why? :


strcpy(RDS, stationName );
strcat(RDS,  rdsText); 

You use emotional descriptions that doesn't make sense to me.

Null or shorter... What is shown on the display?

Try it. No chance I can judge about it,

Required result: getting constant displayed, scrolled text.

Current status, if using the included topic method - ,,manual programed scrolling": choppy text.

Choppy text definiction: text what displayed only partly, position jumping, missing characters or scroll too slow with these loops. Sometimes we can see ,,parts" of the char array, or missing some chars and so try the display scroll. This result reason is simple: both rds data can be empty and received slowly.

However not 100% perfect, slow, but the second included method works.

More defined question just for you, i hope you will like, but let me know if this for you is too emotional, im realy n00b in programing and asking programing questions.

I have two arrays, one for station name, one for message what contains the track played the radio:

char *rdsMsg;
char *stationName;

Both can be sometimes NULL, because RDS data sometimes comes, sometimes not.

How can i make sum/one bigger array from these two, knowinging sometimes in loop both value can be NULL or received partly (just first two, or first x characters - so need constant update)?

Test for NULL and fill the arrays with spaces when that happens. Then display the arrays "as usual".

thank you for the help, i will try write this in code and integrate in my code.

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