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
@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.
@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, 360, fairly knowledge in PC plus numerous MPU's & 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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
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)
@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, 360, fairly knowledge in PC plus numerous MPU's & 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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
@sinc_int Here is the sample sketch showing how to do scrolling
// include the library code: #include <LiquidCrystal.h> // initialize the library by associating any needed LCD interface pin // with the arduino pin number it is connected to const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); } void loop() { // set the cursor to (0,0): lcd.setCursor(0, 0); // print from 0 to 9: for (int thisChar = 0; thisChar < 10; thisChar++) { lcd.print(thisChar); delay(500); } // set the cursor to (16,1): lcd.setCursor(16, 1); // set the display to automatically scroll: lcd.autoscroll(); // print from 0 to 9: for (int thisChar = 0; thisChar < 10; thisChar++) { lcd.print(thisChar); delay(500); } // turn off automatic scrolling lcd.noAutoscroll(); // clear screen for the next loop: lcd.clear(); }
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & 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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
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.
@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, 360, fairly knowledge in PC plus numerous MPU's & 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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
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. 😮
@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, 360, fairly knowledge in PC plus numerous MPU's & 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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
Unfortunately, when I add the scrolling function, the radio is stuttering.
The delay line breaks everything.
@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, 360, fairly knowledge in PC plus numerous MPU's & 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.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
#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
I found a solution.
strcat(LargeText, info);
Thread to be closed.
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