
为ESP32触摸屏开发一个浏览器编辑器
要让ESP32 触摸屏 显示自己的界面,通常需要比预期更长的时间。你需要正确的驱动程序、合适的引脚、正常工作的触摸功能以及LVGL的配置,即便如此,你仍需手动编写每一帧画面。为此,我开发了LCD Ultra Pro编辑器,大幅简化了这一过程。它在 浏览器 中运行,因此如果你只是想尝试,无需安装任何软件。
下方的屏幕是编辑器附带的演示项目,你可以打开任意一个并自由修改其中的内容。
你先选择自己的 电路板 ,这样画布就会有正确的尺寸,编辑器也能知道哪些引脚是空闲的。然后你可以将小部件拖到屏幕上,并用鼠标进行移动和调整大小。共有33个标准的LVGL小部件,以及20个现成的智能小部件,例如时钟、每周日程表、天气卡片、PIN锁和MQTT开关。
画布运行的是 浏览器 中的真实LVGL 8.4库,因此你看到的内容就是库所绘制的结果。实时预览功能让你在操作硬件前,可以按下按钮来测试各种规则。当你满意后,可导出一个包含完整Arduino项目的ZIP文件,打开它并使用Arduino IDE烧录到你的 电路板 上。
这正是我最关心的部分。一个外观美观但毫无功能的屏幕没什么用处。因此,编辑器中的逻辑通过几乎像句子一样的规则来构建:当这个按钮被点击时,就开启这个引脚。大约有100种现成的配方可供点击,你也可以修改其中任意一种。如果需要更多功能,还可以将自己编写的C代码添加到某个规则中。
无需编写代码,即可切换引脚、设置PWM、响亮被动蜂鸣器、响应硬件按钮、读取模拟引脚、运行WS2812灯带,并显示DS18B20、SHT3x、BME280、DHT11、DHT22和BH1750传感器的数据。此外,还内置了WiFi设置、网络时间、天气、MQTT以及Home Assistant功能,设备还可运行定时器和每周计划。
Waveshare、Makerfabs、Elecrow、LilyGO、M5Stack、Suntown和Guition等厂商的目录中共有101款开发板,其中60款已具备可导出的显示屏驱动程序。目前仅测试了三款真实硬件版本,分别是Waveshare ESP32-S3-LCD-7B、MaTouch 4.3英寸和MaTouch Rotary 2.1英寸。在这些开发板上,USB Live可在你编辑设计时直接在真实屏幕上显示你的作品,无需编译。编辑器会标记每块开发板的状态,让你清楚看到实际输出效果。如果你尝试其他开发板,非常期待听到你的使用体验。
这是一个开放测试版,因此可能会出现一些bug。它使用的是LVGL 8.4版本,而非9.0版本。对于上述列表之外的传感器,你需要自行编写代码,或者通过MQTT发送其数值。ESP32-P4板虽然已列入目录,但目前尚不能导出。在大多数情况下,你仍需在Arduino IDE中手动编译并刷入项目。
添加这么多板子意味着需要收集大量规格和引脚信息,所以我将所有内容免费发布到网上。共有94个板子页面,以及62个传感器和模块页面,每个页面都包含接线说明、示例代码以及常见故障提示。使用这些内容无需注册账户或编辑器。
最有用的部分是两个平台之间的连接。对于50块板子,传感器页面会告诉你该传感器适配哪个接口,以及在具体板子上应使用哪些引脚。每个部件页面还会标明该部件是否适用于3.3V ESP32引脚。例如HC-SR04传感器会返回5V信号,因此其页面会显示所需的分压电阻值。所有示例代码均可编译,但我尚未在真实硬件上测试过每一块部件,每个页面都提供了源码供你查阅。
本文来源:https://www.21ic.com/a/1016999.html
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。

Developing a browser-based editor for ESP32 touchscreens
Getting an ESP32 touchscreen to display your own interface usually takes longer than expected. You need the right drivers, the proper pins, working touch functionality, and LVGL configuration—and even then, you still have to manually code every frame. To this end, I developed the LCD Ultra Pro editor, which greatly simplifies the process. It runs in the browser, so if you just want to try it out, there is no software to install.
The screens below are demo projects that come with the editor; you can open any of them and freely modify their contents.
You first select your own board, so the canvas has the correct dimensions and the editor knows which pins are free. Then you can drag widgets onto the screen and move and resize them with the mouse. There are 33 standard LVGL widgets, plus 20 ready-made smart widgets such as clocks, weekly schedules, weather cards, PIN locks and MQTT switches.
The canvas runs the real LVGL 8.4 library in the browser, so what you see is exactly what the library draws. The live preview feature lets you press buttons to test various rules before touching any hardware. Once you are satisfied, you can export a ZIP file containing the complete Arduino project, open it, and flash it to your board using the Arduino IDE.
This is the part I care about most. A screen that looks beautiful but has no functionality is useless. So the logic in the editor is built through rules that are almost like sentences: when this button is clicked, turn on this pin. There are about 100 ready-made recipes to click on, and you can modify any of them. If you need more functionality, you can also add your own C code to a rule.
Without writing code, you can toggle pins, set up PWM, sound a passive buzzer, respond to hardware buttons, read analog pins, run WS2812 LED strips, and display data from DS18B20, SHT3x, BME280, DHT11, DHT22 and BH1750 sensors. In addition, WiFi setup, network time, weather, MQTT and Home Assistant features are built in, and the device can also run timers and weekly schedules.
There are 101 development boards in the catalog from manufacturers such as Waveshare, Makerfabs, Elecrow, LilyGO, M5Stack, Suntown and Guition, of which 60 already have exportable display drivers. Currently only three real hardware versions have been tested: the Waveshare ESP32-S3-LCD-7B, the MaTouch 4.3-inch and the MaTouch Rotary 2.1-inch. On these boards, USB Live can show your work directly on the real screen as you edit the design, without any compilation. The editor marks the status of each board so you can clearly see the actual output. If you try other boards, I would love to hear about your experience.
This is an open beta, so there may be some bugs. It uses LVGL version 8.4, not 9.0. For sensors outside the list above, you need to write your own code or send their values via MQTT. Although the ESP32-P4 board is listed in the catalog, it cannot be exported yet. In most cases, you still need to manually compile and flash the project in the Arduino IDE.
Adding so many boards means collecting a large amount of specifications and pin information, so I published everything online for free. There are 94 board pages, plus 62 sensor and module pages, each containing wiring instructions, example code, and common troubleshooting tips. No account or editor registration is required to use these resources.
The most useful part is the connection between the two platforms. For 50 boards, the sensor pages will tell you which interface the sensor fits and which pins to use on a specific board. Each component page also indicates whether the component is suitable for the 3.3V ESP32 pins. For example, the HC-SR04 sensor returns a 5V signal, so its page shows the required voltage divider resistor values. All example code compiles, but I have not tested every component on real hardware; each page provides the source code for you to review.
本文来源:https://www.21ic.com/a/1016999.html
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。