https://github.com/isysxp/lvgl_calculator
A simple calculator using LVGL graphics on an ESP32 board
https://github.com/isysxp/lvgl_calculator
calculator esp32 lvgl
Last synced: 20 days ago
JSON representation
A simple calculator using LVGL graphics on an ESP32 board
- Host: GitHub
- URL: https://github.com/isysxp/lvgl_calculator
- Owner: Isysxp
- Created: 2025-05-28T15:17:23.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-07-26T21:08:49.000Z (10 months ago)
- Last Synced: 2025-07-27T00:28:12.320Z (10 months ago)
- Topics: calculator, esp32, lvgl
- Language: C
- Homepage: https://github.com/Isysxp/LVGL_Calculator
- Size: 265 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LVGL_Calculator
This is a simple calculator for the Arduino environment running on a Waveshare ESP32S3 board. https://www.waveshare.com/wiki/ESP32-S3-Touch-LCD-4.3
The graphics are created using the LVGL/LovyanGFX libraries.these should be imported into the Arduino environment ... see app for versions.
It includes the config files for the EEZ Studio graphics designer system which I think is rather cool. https://www.envox.eu/studio/studio-introduction/
The app consists of three components. The app, a simple expression evaluator which respects operator precedence, the src/ui dircetory which contain the
code generated by the EEZ Studio designer and a file displaystuff.h which is the initialisation code for the display. This is from: https://gitlab.com/chris.willing.waveshare/lvgl-eezstudio-setup
In addition, I have included my copy of lv_conf.h. This file should be placed in the Arduino libraries folder. I refer you to https://docs.lvgl.io/7.11/porting/project.html
for some information about this rather critical file. It contains a large number of configuration elements. So, if you have a working version for your display, make a copy as I have in the app
directory and copy it back to the Arduino libraries folder as needed. The most likley change you may need to make is to the selected fonts near line 364. This would be in the event that
you have selected a font in EEZ Studio for which the setting in lv_conf.h is 0.
It is worth reading the EEZ Studio section on events and how to manage them. This app is a reasonable example of this in the the action_button_clicked(...) function is called asynchronously
from the LVGL idle loop in the loop() function. The function calls in this app show how to find the event source widget and its properties or directly reference a specific widget.
I hope this app gives some insight into what is quite a daunting process of creating and event driven graphics apps for the ESP32.
Ian Schofield May 2025
This update adds a mouse cursor to the app. There are a number of methods for sending data to an LVGL application. In this case, I have selected the UDP option.
This is very similar to sending data via a serial port but does not require a formal connection process. Ideally, one would connect a BLE mouse but
this can get rather involved and this example is by far the simplest method. In essence, the app creates a UDP listener on port 1000 and any UDP source
may send an 8 byte message formatted as 2 32bit integers, the X and Y coordinates for the cursor and a mouse click indicator when the X coordinate is negative.
An example VB.Net app is included in the Mouse_Xmit directory.
In addition, this update also allows for the use of a USB mouse using the EspUsbHost library:https://github.com/tanakamasayuki/EspUsbHost
To plug in a USB mouse firstly, USB CDC on boot should be disabled. Upload and USB mode should be set to TinyUSB.
Plug the mouse into the port marked USB ... you may need an OTG adapter like this one: https://www.amazon.co.uk/dp/B0872VN39L?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1
The library does not parse the USB mouse descriptors so you may need to edit the file C:\Users\\Documents\Arduino\libraries\EspUsbHostLVGL-master\src\EspUsbHost.cpp
This file copies the values from the USB data buffer into a report buffer which is used to determine the button state and the mouse movement.
I have set things up according to the 'standard' format of a mouse message. But, your mouse might not work correctly.
Try changing the data buffer offsets at lines 578-580 in the file as above.
Ian Schofield July 2025