Micropython Code Samples for demo 'Theme Night'

Hi do have code samples in micropython for ‘Theme Night’ or ‘Theme Material’. Thxs

Unfortunately the demos are only available in C right now.

@adusur Coverting an example from C to Micropython is, in most cases, very simple and straightforward.

If you have a specific example in C that interests you, please post it here and I’ll show you how to convert it to Micropython.

Hi please let me know how you can help us.

We are willing to pay

Platform ESP32
IDF: Espressif

Previously we wrote in pure c code using ILI9341. We have 3 such screens.

@adusur Please explain.
Do you already have lvgl C code you want to convert to Micropython?
What is the image that you posted? Did you create it with lvgl C code? How ‘Theme’ is related?

We just have pure c-code and we want to get to Python/LittleVGL so that we can make changes easily in future.

We have 2 more screens I will send you. Can you help us convert?
If so what would you charge?.

Thxs

We have issues with fonts and images handling in littleVGL

options-screen-page-001 home-page-001

Here They are

image

We got this far using LittleVGL

I am at aravi255@gmail.com in hangouts ‘adusur’

micropython is ok for us

I can help you understand how to use Micropython, and give you examples of how to convert C to Micropython. The goal is to help the community who is using LittlevGL and improve the Micropython binding itself.

I cannot take this as a job, but I will help you out if you send pieces of code and show us what you did so far, as long as this is done in a public forum and could help others as well.

lv_test_theme_1.c (8.3 KB)

Hi

Here is the sample image and code.
We need help in:

  1. How to convert to micropython
  2. Those Number 23’s are images but we want them in fonts.

Please help Thxs

What did you try so far?
Where did you encounter problems?
Did you read the documentation?
Did you try to run some existing code samples?

I can try to help you, but you first need to make some effort yourself.

Hi

We really would not have asked for help, if you had ‘Theme demo’ sample code is in micropython. We found no help in ‘micropython’ on littleVGL except very very basic button code. Having looked at the site this was my first question in the forum.

I got reply saying no code samples in micropython.

We are new to micropython.

We need one screen demo, after that we will be on our own.

Thxs

There are a few MicroPython examples here: https://github.com/littlevgl/lv_binding_micropython/tree/master/examples

The MicroPython API is automatically generated from the C one. If you read the C documentation and the examples (plus asking @amirgon for help on specific APIs) you should be able to get started fairly quickly.

@adusur,
As @embeddedt mentioned, I recommend looking at the examples on that folder.

You asked for a Micropython example of themes, so here it is:

# Initialize the night theme
night = lv.theme_night_init(10, lv.font_t.cast(None))
lv.theme_set_current(night)

# Create the night slider
slider1 = lv.slider(lv.scr_act());
slider1.set_value(70, False);
slider1.align(lv.scr_act(), lv.ALIGN.CENTER, 0, 0);

# Initialize the alien theme
alien = lv.theme_alien_init(10, lv.font_t.cast(None))
lv.theme_set_current(alien)

# Create the alien slider
slider2 = lv.slider(lv.scr_act());
slider2.set_value(70, False);
slider2.align(slider1, lv.ALIGN.OUT_BOTTOM_MID, 0, 10);

# register event callback
def cb(obj, ev):
    if ev == lv.EVENT.VALUE_CHANGED:
        value = obj.get_value()
        slider1.set_value(value, False)
        slider2.set_value(value, False)

slider1.set_event_cb(cb)
slider2.set_event_cb(cb)

As a bonus, I also added alignment and value-change event handling.

The result looks like this:
image

Regarding images, assuming you have a file system, you can load the file into a micropython byte-array and display it. See this example where the image is an inline byte array but you can also load it from a file.

Regarding large numbers instead of images - you probably need to generate a new font with large enough glyphs.
Today you still can’t load a font on runtime so this would require building Micropython with the new font.

(@kisvegabor/@embeddedt - Any chance to see runtime loading of fonts on v6.1?)

See the new issue for it on GitHub: