Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying content of a text file in a tab ?!? #286

Open
MisterButcher opened this issue Jan 10, 2024 · 6 comments
Open

Displaying content of a text file in a tab ?!? #286

MisterButcher opened this issue Jan 10, 2024 · 6 comments
Assignees

Comments

@MisterButcher
Copy link

Hello,

I make this a feature request as I do not rate this an issue ... it is more a question for help.

My sketch is using some ESPUI gui in various tabs controlling a heating device. I would like to add an additional tab which should show the log (a log file) of the ESP sketch which is written to LittleFS. All I tried failed. All I googled did not work (best try was an Iframe solution but whatever I tried the file is only downloaded and not displayed, even if I use small / dummy files).

With the current ESPUI is my request to show a text file achievable at all? If so, could you please give me an example how to do it? Or (if it can be mixed) how to do it in a tab that does not use ESPUI (along with the other ESPUI tabs)?!?

Thanks, Stefan

@MartinMueller2003
Copy link
Collaborator

Is your goal to have the ESPUI give you a text window (super text control) or are you focused on a non ESPUI solution? You can add your own handler for uploading a file using the ESPUI web server and then write your own js script to process the file into a window. That would not need any work from the ESPUI project. If you are asking for a "Log Control" that can be placed on a tab and can be updated by printing to it, that would be an enhancement.

The current text control can be used but you would have to manage content being displayed in your application.

@MisterButcher
Copy link
Author

Thanks for your answer Martin. I do not know which solution is best. You wrote it can be done with the current text control, is it possible to have an example how? I am stuck at the moment. If ESPUI could provide a text window, that would be great ...
Thanks, Stefan

@MartinMueller2003
Copy link
Collaborator

It is not so much a text window as you can write multiple lines to a text control. You would have to manage the displayed lines on the ESP. It is ugly and uses a lot of ram but it works. I think what you are asking for is a control that takes each line written to it and automatically adds it to the end of the current list of text lines already being displayed. This would take some magic on the UI side but it could be implemented as an optional function on the existing text control. It would take a few special operations:

AppendLine
ClearAllLines
ClearOldestLine

etc.

Still mulling this over.

@MartinMueller2003
Copy link
Collaborator

I have added code to ESPUI to allow you to simply specify a file name and then trigger a control update when the file is changed. The UI will read the file and display it. You can adjust color etc just like any other control. Under the hood it uses the text control but instead of taking text, the control uses the output string as a file name. It is a bit of an overload on the field but does not stretch the best practises too far. I still have more testing to do but if you want to see and example, look at the pio gui.ino example in my repo.

https://github.com/MartinMueller2003/ESPUI

@MisterButcher
Copy link
Author

Hello Martin,

thanks for the new feature. I will test it in the next weeks ....

Regards, Stefan

@MartinMueller2003
Copy link
Collaborator

MartinMueller2003 commented Feb 21, 2024

Pull request has been created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants