1=================
2Tasmota and berry
3=================
4
5What is Tasmota?
6----------------
7
8`Tasmota <https://github.com/arendst/Tasmota>`__ is a widely used
9open-source firmware for ESP8266 and EPS32 based devices. It supports a
10wide variety of devices, sensors and integrations to Home Automation and
11Cloud services. Tasmota firmware is downloaded more than 200,000 times
12each month, and has an active and growing community.
13
14Tasmota provides access to hundreds of supported devices, full support
15of MQTT, HTTP(S), integration with major Home Automation systems, myriad
16of sensors, IR, RF, Zigbee, Bluetooth, AWS IoT, Azure IoT, Alexa and
17many more.
18
19What is Berry?
20--------------
21
22`Berry <https://github.com/berry-lang/berry>`__ is a ultra-lightweight
23dynamically typed embedded scripting language. It is designed for
24lower-performance embedded devices. The interpreter of Berry include a
25one-pass compiler and register-based VM, all the code is written in ANSI
26C99. Berry offers a syntax very similar to Python, and is inspired from
27LUA VM. It is fully integrated in Tasmota
28
29Highlights of Berry
30~~~~~~~~~~~~~~~~~~~
31
32Berry has the following advantages:
33
34- Lightweight: A well-optimized interpreter with very little resources. Ideal for use in microprocessors.
35- Fast: optimized one-pass bytecode compiler and register-based virtual machine.
36- Powerful: supports imperative programming, object-oriented programming, functional programming.
37- Flexible: Berry is a dynamic type script, and it's intended for embedding in applications.
38  It can provide good dynamic scalability for the host system.
39- Simple: simple and natural syntax, support garbage collection, and easy to use FFI (foreign function interface).
40- RAM saving: With compile-time object construction, most of the constant objects are stored
41  in read-only code data segments, so the RAM usage of the interpreter is very low when it starts.
42
43All features are detailed in the `Berry Reference Manual <https://github.com/berry-lang/berry/wiki/Reference>`__
44
45--------------
46
47Why LVGL + Tasmota + Berry?
48---------------------------
49
50In 2021, Tasmota added full support of LVGL for ESP32 based devices. It
51also introduced the Berry scripting language, a small-footprint language
52similar to Python and fully integrated in Tasmota.
53
54A comprehensive mapping of LVGL in Berry language is now available,
55similar to the mapping of MicroPython. It allows to use +98% of all LVGL
56features. It is also possible to write custom widgets in Berry.
57
58Versions supported: LVGL v8.0.2, LodePNG v20201017, Freetype 2.10.4
59
60Tasmota + Berry + LVGL could be used for:
61~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62
63- Fast prototyping GUI.
64- Shortening the cycle of changing and fine-tuning the GUI.
65- Modelling the GUI in a more abstract way by defining reusable composite Widgets, taking
66  advantage of Berry's language features such as Inheritance, Closures, Exception Handling…
67- Make LVGL accessible to a larger audience. No need to know C to create a nice GUI on an embedded system.
68
69A higher level interface compatible with
70`OpenHASP <https://github.com/HASwitchPlate/openHASP>`__
71is also under development.
72
73--------------
74
75So what does it look like?
76--------------------------
77
78TL;DR: Similar to MicroPython, it's very much like the C API, but Object-Oriented for LVGL components.
79
80Let's dive right into an example!
81
82A simple example
83~~~~~~~~~~~~~~~~
84
85.. code-block:: python
86
87   lv.start()                 # start LVGL
88   scr = lv.screen_active()         # get default screen
89   btn = lv.btn(scr)          # create button
90   btn.center()
91   label = lv.label(btn)      # create a label in the button
92   label.set_text("Button")   # set a label to the button
93
94How can I use it?
95-----------------
96
97You can start in less than 10 minutes on a M5Stack or equivalent device
98in less than 10 minutes in this `short tutorial <https://tasmota.github.io/docs/LVGL_in_10_minutes/>`__
99
100Where can I find more information?
101----------------------------------
102
103- `Tasmota Documentation <https://tasmota.github.io/docs/>`__
104- `Berry Documentation <https://github.com/berry-lang/berry/wiki/Reference>`__
105- `Tasmota LVGL Berry documentation <https://tasmota.github.io/docs/LVGL/>`__
106