Notifications
Clear all

Internet Radio + HD44780 + scroll text

15 Posts
5 Users
2 Likes
842 Views
(@sinc_int)
Member
Joined: 2 years ago
Posts: 4
Topic starter  

Hello

I am using this code ( https://github.com/schreibfaul1/ESP32-audioI2S) to build an internet radio with ESP32.
I added an HD44780 display where I would like to display audio_showstation on line 0 and audio_showstreamtitle on line 1
Everything works fine, but I can't scroll the text on line 1.
here is an example, unfortunately in Polish:

I am looking for help in programming this task.

Regards

SinC


   
Quote
Topic Tags
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2504
 

@sinc_int

I can't guess what the problem is :), can you give us a hint by telling us what, exactly happens (that shouldn't) or what should happen (that doesn't).

Also, post your code so we can see what's happening in there.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@sinc_int I don't understand, you say you can't scroll the text on line 1 but in the YT vid I see it scrolling.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 

@sinc_int

I think you are showing an example of scrolling test in a Sony player and are asking how to programatically scroll text on your home built internet player screen ??

If so the following may help.  Of course you would need to send the text to your internet radio's screen (linked to your ESP32) instead of printf to a terminal screen but I hope the example helps (if thats indeed what you were asking)

 
#include <stdio.h>

char longText[50] = "tell me another one, just like the other one, do ";
char c;

int main(void) {
    int x, txtLen;
    for (txtLen = 0; txtLen < 49; txtLen++) {
       printf("%s\n", longText);
       // remove first character and move the rest to the left
       c = longText[0]; // copy first character
       // move the other characters to the left
       for (x = 0; x < 49; x++) {
           longText[x] = longText[x + 1];
           }
       // copy what was the character to the end
       longText[48] = c;
     }
}

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@byron Wow, I assumed there was a 'scroll' function in the library, didn't know you had to manually do it.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 

@zander

Good point and you are probably correct, but I would expect if there is any scrolling text ability for the particular screen being used to be in the driver library for the screen.  

I usually use python these days and the python library for my dinky little 320 x 240 lcd screen does include the ability scroll text. 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@byron I just posted the example before I saw your post. Yes, it does appear to be a library function.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 

@zander

you are posting too fast for me to keep up, I guess I will have to drink more coffee, or whatever you are on 😀.   I thought you were an old fogey but you are running circles around me. 😮 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@byron That's because one of my legs is shorter.

His answer BTW is to call the autoscroll member of the LCD object. A quick look doesn't tell me how to limit it to just one line, it seems to be the entire display. mylcdobject.autoscroll();

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
frogandtoad reacted
ReplyQuote
(@sinc_int)
Member
Joined: 2 years ago
Posts: 4
Topic starter  

Unfortunately, when I add the scrolling function, the radio is stuttering.

The delay line breaks everything.

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@sinc_int Please use the reply link.

I assume you are referring to the sample code I posted. If so just remove the delay, I think the example is flawed, the auto scroll should happen anyway.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@sinc_int)
Member
Joined: 2 years ago
Posts: 4
Topic starter  
#include "Arduino.h"
#include "WiFi.h"
#include "Audio.h"
#include "WiFiManager.h"
#include "time.h"
#include "LiquidCrystal.h"

//Define display pinout
LiquidCrystal lcd(13, 12, 14, 19, 18, 5);

// Define I2S connections
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26

// Create audio object
Audio audio;

TaskHandle_t Task1, Task2;

String ssid = "MYSSID";
String password = "MYPASSWORD";
char * LargeText = " Understanding code for scrolling text on 20*2 LCD Display. ";
int iLineNumber = 1; // Line number to show your string (Either 0 or 1)
int iCursor = 0;

void setup() {
Serial.begin(115200); // Start Serial Monitor
lcd.begin (20, 2); // Start LCD display

// Setup WiFi in Station mode
WiFi.disconnect();
WiFi.mode(WIFI_STA);
WiFi.begin(ssid.c_str(), password.c_str());

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}

// WiFi Connected, print IP to serial monitor
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("");
lcd.setCursor(0, 0);
lcd.print("IP: ");
lcd.print(WiFi.localIP());
delay(2000);
lcd.clear();
lcd.print("Radio Italo4you");

// Connect MAX98357 I2S Amplifier Module
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(10); // Set thevolume (0-100)
audio.connecttohost("http://s0.radiohost.pl:8018/stream"); //connect to stream

xTaskCreatePinnedToCore( codeForTask1, "stream", 15000, NULL, 2, &Task1, 0);
delay(500); // needed to start-up task1?
xTaskCreatePinnedToCore( codeForTask2, "txt", 15000, NULL, 2, &Task2, 1);
}

void codeForTask1( void * parameter ) {
for (;;) {
audio.loop(); //out radio stream
}
}

void audio_showstreamtitle(const char *info) {
// LargeText = info; // it doesnt work
Serial.print("streamtitle "); Serial.println(info);
}

void UpdateLCDDisplay()
{
int iLenOfLargeText = strlen(LargeText); // Calculate lenght of string.
if (iCursor == (iLenOfLargeText - 1) ){ // Reset variable for rollover effect.
iCursor = 0;
}
//lcd.clear();
lcd.setCursor(0,iLineNumber);
if(iCursor < iLenOfLargeText - 20) // This loop exicuted for normal 20 characters.
{
for (int iChar = iCursor; iChar < iCursor + 20 ; iChar++) {
lcd.print(LargeText[iChar]);
}
}
else
{
for (int iChar = iCursor; iChar < (iLenOfLargeText - 1) ; iChar++){ // This code takes care of printing charecters of current string.
lcd.print(LargeText[iChar]);
}
for (int iChar = 0; iChar <= 20 - (iLenOfLargeText - iCursor); iChar++){ // Reamining charecter will be printed by this loop.
lcd.print(LargeText[iChar]);
}
}
iCursor++;
}

void codeForTask2( void * parameter ) {
for (;;) {
UpdateLCDDisplay(); // Scoll text by 1 character
delay(350); // Change delay to change speed for scrollig text.
}
}
void loop() {
}

This is my code. 

How to display 'info' as 'LagreText'?

 

Regards

SinC


   
ReplyQuote
(@sinc_int)
Member
Joined: 2 years ago
Posts: 4
Topic starter  

I found a solution.

      strcat(LargeText, info);

Thread to be closed.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@sinc_int

Posted by: @sinc_int

I found a solution.

      strcat(LargeText, info);

Thread to be closed.

That is actually a serious error, and if it worked, it's only by chance... that's what "undefined behavior" means in C and C++.

Why not just use Arduino "String" type or the in ESP32, the ISO C++ std::string from #include<string>?

Much safer and easier to handle.

Cheers


   
Ron reacted
ReplyQuote