codemee / ESPWebServer

24 stars 3 forks source link

How to have ESPWebServer.py report messages to onboard display #3

Open CyberSpiderPrime opened 2 years ago

CyberSpiderPrime commented 2 years ago

I am fairly new to MicroPython/Python but have been programming in several languages for years.

Device: Lilygo ESP32 TTGO with T-Display (on-board display)

firmware with ST7789 driver(s) https://github.com/russhughes/st7789_mpy (MicroPython v1.18-128-g2ea21abae-dirty on 2022-02-12; TTGO T-Display with ESP32) ST7789 config file for T-Display https://github.com/russhughes/st7789_mpy/tree/master/examples/configs/tdisplay_esp32

webserver software (from here) https://github.com/codemee/ESPWebServer

my copy of TestWebServer.py is modified to work in AP (private network) mode and to use the on-board display to display IP address. I would like this to also handle messages from ESPWebServer.py.

Currently, ESPWebServer.py is unmodified in regards to its reporting (serial monitor, print()). This, of course, requires you to have another device connected to see the messages (computer, smartphone with usb serial software, etc.). This is fine for testing, not so much for stand alone operation.

How would I get ESPWebServer.py to notify its importer (TestWebServer.py in this case) that A) it has a message, B) type (general/error/etc.) and C) the message's content so that the importer could process the message (example: "ERROR" and "file $name$ not found"; "General" and "file $name$ found"; "Status", "GPIO## is set HIGH")?

Option: can ESPWebServer.py be written/rewritten to be a standalone program (ESPWebServer-Standalone.py?, no need for TestWebServer.py), therefore handling all reporting requests itself (with print() at first then I could add my modifications to that)?

codemee commented 2 years ago

I suggest you fork ESPWebServer and add a error handler object parameter with default value of None to begin(). If this error handler object is None, report errors to serial as usual. If the error handler object is not None, it should have its custom print() method to report error.

In this wey, you can pass your own error handler object to get all he errors.

CyberSpiderPrime commented 2 years ago

Thank you for answering.

I merged ESPWebServer.py, TestWebServer.py, the tft firmware/driver/script, and an uptime timer I created to test battery life and everything is working now. The salvaged flat battery runs for about 4.5 to 5hrs before it dies.

Since this is only going to be a portable webserver (the next maybe a web based device controller), I figure I want the programming to be as flat as possible. Next feature to add is SD Card support (using an micro SD to SD adapter, I got a lot of these) to save memory and computer file transfers.

On Wed, Jul 13, 2022, 8:58 AM 黃昕暐 @.***> wrote:

I suggest you fork ESPWebServer and add a error handler object parameter with default value of None to begin(). If this error handler object is None, report errors to serial as usual. If the error handler object is not None, it should have its custom print() method to report error.

In this wey, you can pass your own error handler object to get all he errors.

— Reply to this email directly, view it on GitHub https://github.com/codemee/ESPWebServer/issues/3#issuecomment-1183191474, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD5SF5DERJYWXRXBX2HQDOLVT24NXANCNFSM52OBCA5Q . You are receiving this because you authored the thread.Message ID: @.***>

codemee commented 2 years ago

cool.