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.