The Portenta H7 board comes with some interesting features besides the powerful STM32H7 dual core processor.
It's equipped with a ChromArt image processing DMA, combined with a LCD / TFT driver called LTDC - link, able to generate DSI video signals. Combines with a MIPI-DSI/DPI to USB Type-C™ Bridge, ANX7625 it can Generate HDMI video out over USB-c.
H7 Video LibraryThe supporting library is using the LTDC and 2D-DMA features to send a RGB565 screen to the DSI-bridge. - link to the tutorials
Unfortunately Mbed libraries have no features for blending, transparent images, or stable canvas background. This expansion library provides a couple of functions / features that can help you out.
SetupSetup is straight forward :connect the USB-C output to a HDMI-compatible USB-C Bridge / Hub:
Note: Not every Hub seems to work well, so please check the Arduino-Pro website for the best options. Mine is a ACT AC7042, which has a bit of a vertical sync problem, but is stable after an Arduino-pro hard reset after power-up.
Canvas and Alpha ScreenThe setup is currently fixed in the library H7Canvas.h include file. Adapt your video setting there at the moment. The library works with a Opaque Canvas aka Background, in RGB565 16 bit colors, and is blended with an Alpha (ARGB8888) overlay called the Sprite-Canvas. Every frame update this set is send to the DSI interface, and makes the video signal.
The use of a Canvas background (fixed images) and a Sprite Canvas avoids building up a full screen every frame, and adds alpha / transparency to your images., example :
C-code and Demo Examples
The full library is on GitHub and downloadable. There are two Demo's available that show some image moving. Key C-functions are :
CanvasAll_Init() : initialises video with Canvas and Sprite Area. currently not dynamic, but adaptable in the H7Canvas.h setup
CanvasAll_DrawFrames() : draws all frames - Canvas + Transparent Sprite to the current DSI video buffer, and sends buffer for display
Canvas_DrawImage(G_image imagename) : draw G_image to Canvas-buffer
Sprite_DrawImage(G_image imagename) : draw G_image to Sprite-buffer
Printf_Canvas() and Printf_Sprite() : printf-function for graphic text in alpha / transparant style. Graphic text comes in 3 flavors are the moment : 1 standard 12pt, 2 large 18pt, 3 fat 24pt (numbers only)
Sprite_FillRect() and Canvas_FillRect() created rectangular filling with alpha-channel transparency
G_image is an image C-structure object that contains the image data like pixel-type, size and the pointer to the image data. This simplifies the image-draw calls in your program, it supports alpha images (like PNG) in ARGB8888 ARGB1555 ARGB4444. G_image object also contains the x-y coordinates on the screen.
The Sprite overlay and Canvas Background have their own function-calls, and their own coordinate-axis.You can generate C-array images using the C-array generator: a drag and drop BMP/PNG image tool using the USB-drive and convert-function : Github-link
Performace.Demo's run on a 720x480 resolution, 800x600 works ok as well, but going to 1024x720 makes the screen smear, dsi cant keep up with the frame rate it seems- even on stable images - to be improved
Demo's show a screen processing at about 33ms per frame (16 frames a second). This is Sprite-Canvas build up and DMA copying RGB565 and Sprite Canvas to the DSI current buffer. My impression the LTDC of the STM32 should have more features, but the dsi.h library of Mbed might be a bit limited - to be discovered.
SDRAMThere is a 16MByte SDRAM attached to the STM32H7. The Arduino Video Library makes use of the SDRAM.h library, consuming 2 frames of memory (600K - 1.2MB data)
The Canvas library adds additional memory consumption for the Canvas Background and the Sprite-Overlay, total about the same amount of the DSI / Video library.
Serial DebugThere is one issue with USB-C-Video: the USB serial connection is gone. No other USB can be connected using the Mbed Arduino H7 Video Library, not even via the USB-hub.... and that sucks.I'm using my DEBUGF feature to do my serial debugging, and added it to the Serial3 of the H7. IF you have and explansion board, you can using this for text-debugging :
Yes, transaparent fonts are possible. The 2D-DMA supports A8 and A4 images, where your can color in the Font-Color by Register settings.This Library added 3 fonts : 12pt, 18pt and 24pt (numbers only) ub A4 format.You can use them with the Canvas_Printf() or Sprite_Printf() functions.
To Do- Create H7Canvas Class
- Add smaller font - 9 pt
- Add other Alpha-based graph functions, ie circles etc.
- Add resizable images - DONE
- Speed up the Framerate
Comments
Please log in or sign up to comment.