user-img

Francois MOCQ

  • 1 Projects
  • 2 Followers
  • Dec 16,2024
+ Follow

Images and time in microPython Crowpanel ESP32 1.28”

Find out how to use Elecrow's 1.28” round CrowPanel IPS touchscreen with an ESP32 and microPython in this article. I explain in detail the setup steps, the necessary connections and the libraries to use to get the most out of this innovative screen. You'll also learn how to display images, text and graphics on this touch screen, while exploring the possibilities offered by ESP32. Whether you're a DIY enthusiast or a curious developer, this article will guide you through every step to make your project a success. Don't miss this opportunity to discover a new tool for your electronic creations!

Images and time in microPython Crowpanel ESP32 1.28”
 
  • thumbnail-img
  • thumbnail-img
  • thumbnail-img
  • thumbnail-img
  • thumbnail-img
  • thumbnail-img
  • thumbnail-img
  • thumbnail-img
 

Story

Following the presentation of Elecrow's circular touch screen equipped with an ESP32 C3, I decided to test the display in microPython, using Thonny. In this article, you'll find the steps involved in installing microPython and the first tests.

You'll find the original article in French but with an online translation via Google Traduction here: https://www.framboise314.fr/utilisation-de-lecran-rond-crowpanel-ips-tactile-elecrow-128-pouce-esp32/

Using Elecrow 1.28 inch CrowPanel IPS Touch Round Screen

Installing microPython

We'll start by erasing the Flash memory to start with a "clean" ESP32-C3. I used Python on a Windows 11 PC, as well as Thonny

I created a crowpanel folder and then a Python virtual environment in that folder:

python3 -m venv crowpanel

The virtual environment can then be activated

At the end of use we will exit properly with the  deactivate command , but that is for later, when we are finished.

Then install esptool in this environment

(crowpanel) pi@framboise314:~ $ pip install –upgrade esptool

Then we can erase the Flash memory of the ESP32-C3

(crowpanel) D:\Elecrow_CrowPanel1.28> python -m esptool –COM3 port –chip esp32c3 erase_flash

Finally install microPython (I used the version provided in the Elecrow folder).

(crowpanel) D:\Elecrow_CrowPanel1.28>python -m esptool –COM3 port -b 460800 –before default_reset –after hard_reset –chip esp32c3 write_flash –flash_mode dio –flash_size detect –flash_freq 40m 0x0 MicroPython-1.28-Demo\firmware\esp32C3_1.2.4_micropython.bin

We have finished preparing the ESP32-C3 in Python, you can exit the virtual environment

(crowpanel) pi@framboise314:~ $ deactivate

You can now download the demos

https://www.elecrow.com/download/product/CrowPanel/ESP32-HMI/1.28-DIS12824D/MicroPython-1.28-Demo.zip

then unzip the archive

microPython with Thonny

We can then launch Thonny

And we end up with the microPython prompt that we just installed on the ESP32c3, ready to work…

The examples are provided by Elecrow and this is what I tested.

Test of the RTC clock with time display in the console. FYI, arrived from Elecrow a good week ago, the screen is always at the exact time.


Testing the "user" button the console indicates when the button is pressed.

Buzzer test. I also tested the vibrator, then wrote a program to customize the display:

Final program

In the gc9a01.py library you can add the colors you are interested in

self.pink = 0x10c6
self.yellow= 0xffe0

Finally I cleared the display (black screen) and used the button on the watch to display the time on demand…

This is the assembly of several demo programs provided by Elecrow, with a little home-made adjustment… I also added some colors in the screen library, we are in BGR on 16 bits 😉

Video player
 
 
00:00
 
00:15
 
 
 

Afterwards, we can modify the program to leave the screen on for 2 or 3 seconds when we press... I'll let you have fun.

Add images

Switch from BMP to RGB565

The BMP format is rather complex with a header and colors coded on 3 bytes (RGB) or 24 bits.
To display on the CrowPanel screen we need a raw data file in RGB565 format without header.

First step prepare a 240x240px bmp file (I took my logo) and transform it from .bmp to RGB565. I used this program https://github.com/liyanboy74/bmp24-to-rgb565 that I compiled on a Raspberry Pi 5 which was also used to convert the files to RGB565.

Then just launch the Bmp24ToRGB565 program. Enter the name of the .bmp file WITHOUT THE EXTENSION (here bluemarble) then n and it generates a .h file which contains…

Here bluemarble is an array of uint16_t values ​​( uint16_t is a data type representing positive integer values ​​on 16 bits). It is an array of 240*240 elements, which means that it can contain 57,600 uint16_t values.
But that is not what we need, we just need the data. In addition here they are in hexadecimal characters. So I wrote a bit of program in Python to "clean" this file (keep only the bytes) and write them in binary in another file which will be the one we will send to the screen, finally to the screen framebuffer!

Program conv_bmp_565.py

To run this program:

python conv_bmp_565.py bluemarble.h bluemarble.bin
Binary file 'bluemarble.bin' created successfully.

Finally, to display this file on the screen, I added a function to the microPython library provided by Elecrow ( gc9a01.py ) in the microPython demo folder. Add this function in the class LCD_1inch28(framebuf.FrameBuffer):

The one-time display produced an error (probably due to the size of memory used) by doing a block display it works and it is also fast… The following program is identical to the previous one, but we display the logo and we switch to the time display when we press the button.

The display program becomes:

Video player
 
 
00:00
 
00:46
 
 
 

and with several images:

The end of the program becomes

and we get:

Video player
 
 
00:00
 
00:51
 
 
 

Video

Video player
 
 
00:00
 
00:56
 
 
 

Conclusion

For a screen that costs less than $14 we have interesting possibilities. I haven't tested Wifi or BT yet, but we can imagine making our own watch, stopwatch, displaying information etc... enough to have fun for cheap.

Images and time in microPython Crowpanel ESP32 1.28”

Find out how to use Elecrow's 1.28” round CrowPanel IPS touchscreen with an ESP32 and microPython in this article. I explain in detail the setup steps, the necessary connections and the libraries to use to get the most out of this innovative screen. You'll also learn how to display images, text and graphics on this touch screen, while exploring the possibilities offered by ESP32. Whether you're a DIY enthusiast or a curious developer, this article will guide you through every step to make your project a success. Don't miss this opportunity to discover a new tool for your electronic creations!

389
 
6
0
0

Share your project on social media to expand its influence! Get more people to support it.

  • Comments( 0 )
  • Like( 6 )
/1000
Upload a photo:
You can only upload 1 files in total. Each file cannot exceed 2MB. Supports JPG, JPEG, GIF, PNG, BMP

You May Also Like

View All
Add to cart
Board Type : GerberFile :
Layer : Dimensions :
PCB Qty :
Different PCB Design
PCB Thickness : PCB Color :
Surface Finish : Castellated Hole :
Copper Weight : 1 oz Production Time :
Total: US $
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.

PCB Assembly

PCBA Qty: BomFile:
NO. OF UNIQUE PARTS: NO. of Components:
Assembly Cost: US $
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
3dPrintingFile : Size :
Unit : Volumn :
3D Printing Qty : Material :
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
Acrylic Type : AcrylicFile :
Dimensions: Engrave:
Acrylic Qty :
Acrylic Thickness:
Acrylic Color:
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
CNC Milling File : Size:
Unit: Volumn:
CNC Milling Qty : Material:
Type of Aluminum: Surface Finish:
Tolerance:
Surface Roughness:
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
Item Price Qty Subtotal Delete
Total: US $0.00
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.