Page 1 of 1
Populate HTML Text Box form software
Posted:
Mon Jun 27, 2022 8:31 am
by Jim Doe
I am working on a project using a NodeMCU ESP8266 and DFPlayer Mini MP3 Player.
I want to control the MP3 player from a cell phone with the ESP8266 using AP mode.
The software in the ESP8266 has a list of song titles stored as array data in PROGMEM
I would like to send the title of the song playing to a text box in the WEB page hosted by the NodeMCU esp8266.
I have searched and researched all over with no luck.
Plenty of examples on sending from the WEB page to the software but I need to go the other direction.
What method is use for this task?
Re: Populate HTML Text Box form software
Posted:
Wed Jun 29, 2022 6:07 pm
by davydnorris
Most common approach is to have a little bit of javascript on the page that either opens a websocket or polls an endpoint periodically.
Are you actually using NodeMCU with lua or are you using some other programming environment? There are projects out there that show you how to do this for NonOS, RTOS and Arduino
Re: Populate HTML Text Box form software
Posted:
Wed Jun 29, 2022 11:08 pm
by Jim Doe
I am using Arduino based development.
I found a sample project that gets close to what i need .
Using
document.getElementById("outputState").innerHTML = outputStateM;
The problem with this is loading the (outputStateM) variable from an array of strings (song titles) that are created and stored outside the scope of the <script>.
Can Javascript access arrays stored globally in the C code section?
Re: Populate HTML Text Box form software
Posted:
Thu Jun 30, 2022 8:19 pm
by Jim Doe
I have found examples that are close to what I need but I have not found a method to output text strings created in the scope of the Arduino C code to the JavaScript.
I have tried to create the strings in the JavaScript without success. It will only allow a few strings in the JavaScript with out causing other compiler errors.
This seems to be the direction to go but...
document.getElementById("outputState").innerHTML = outputStateM;
I need to set (outputStateM) to the text string to display.
Strings are created like this:
const char string_0[] PROGMEM = "Make A Selection" ;
const char string_1[] PROGMEM = "Young Girl" ;
const char string_2[] PROGMEM = "Lady Willpower" ;
const char string_3[] PROGMEM = "Bad, Bad Leroy Brown" ;
const char string_4[] PROGMEM = "You Don't Mess Around With Jim" ;
const char string_5[] PROGMEM = "I Got A Name" ;
const char string_6[] PROGMEM = "I'll Have To Say I Love You In A Song" ;
const char string_7[] PROGMEM = "Operator" ;
const char string_8[] PROGMEM = "Time In A Bottle" ;
const char string_9[] PROGMEM = "It's a Long Way There" ;