Webradio project - store fast changing received STREAMTITLE

I try build a webradio, but for this i want using a manual scroll (sh1105 oled wont support scroll instruction), because the played song is too long and sometimes changing 15 seconds. This a station ad, what some station use and after we receive again the played song/artist.

But here comes the problem, sometimes scroll need more time to display the received data than the speed of receive this data: scroll wont have enough time to display all string, during scroll will this change.

I need help somehow ignore this change: store this char*/string data and ,,receive" delayed for scroll to give enough time display the full received string.

Basic code sketch looks so, using cs1053 mp3 decoder - vs1053 ext library:

#include "Arduino.h"
#include "WiFi.h"
#include "SPI.h"
//#include "SD.h"
//#include "FS.h"
#include "vs1053_ext.h"

// Digital I/O used
//#define SD_CS        5
#define VS1053_MOSI   23
#define VS1053_MISO   19
#define VS1053_SCK    18
#define VS1053_CS      2
#define VS1053_DCS     4
#define VS1053_DREQ   36

String ssid =     "xxxx";
String password = "xxx";

int volume=15;

VS1053 mp3(VS1053_CS, VS1053_DCS, VS1053_DREQ, VSPI, VS1053_MOSI, VS1053_MISO, VS1053_SCK);

//The setup function is called once at startup of the sketch
void setup() {
    //pinMode(SD_CS, OUTPUT);      digitalWrite(SD_CS, HIGH);
    Serial.begin(115200);
    SPI.begin(VS1053_SCK, VS1053_MISO, VS1053_MOSI);
    //SD.begin(SD_CS);
    WiFi.disconnect();
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid.c_str(), password.c_str());
    while (WiFi.status() != WL_CONNECTED) delay(1500);
    mp3.begin();
    mp3.setVolume(volume);
    mp3.connecttohost("http://live.topfm.hu:8000/radio.mp3"); 
}

void loop()

{
    mp3.loop();
}

void vs1053_showstation(const char *info){          // called from vs1053
    Serial.print("STATION:      ");
    Serial.println(info);                           // Show station name
}
void vs1053_showstreamtitle(const char *info){      // called from vs1053
    Serial.print("STREAMTITLE:  ");
    Serial.println(info);                           // Show title
}

Basic scroll code what im using looks so:

void scrollText(String str) {
  
  scroll_pos--;
  
  int len = str.length() * scroll_char_width;
  if (scroll_pos + len <= SCREEN_WIDTH) scroll_pos += len;

  display.drawString(scroll_pos, scroll_y, str);
  if (scroll_pos > 0)
    display.drawString(scroll_pos - len, scroll_y, str);
  else
    display.drawString(scroll_pos + len, scroll_y, str);
    display.display();
  
}

Received Streamtitle/Artist data looks from Serial terminal window so, here is visible these changes, what makes effect on scroll visibility:

19:55:15.610 -> Kilencvenesek - Csak a legjobbak a 90-es evekbol!
19:55:29.593 -> Squeezer - Get It Right [1997]
19:56:05.588 -> Kilencvenesek - Csak a legjobbak a 90-es evekbol!
19:56:17.601 -> Squeezer - Get It Right [1997]
19:56:53.587 -> Kilencvenesek - Csak a legjobbak a 90-es evekbol!
19:57:05.615 -> Squeezer - Get It Right [1997]

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